Something like this should be more readable:
```c if (thread->context && !get_error()) { const unsigned int native_flags = contexts[CTX_NATIVE].flags & req->native_flags; const int is_pending = thread->context->status == STATUS_PENDING; const int selected_ctx = ctx_count == 2 && thread->context->regs[CTX_WOW].machine ? CTX_WOW : CTX_NATIVE; unsigned int i;
for (i = 0; i < ctx_count; i++) { context_t *dest_context = &thread->context->regs[i]; unsigned int new_flags = 0;
/* some regs are always set from the native context */ if (i == CTX_NATIVE) new_flags |= native_flags;
/* If context is in a pending state, we don't know if we will use WoW or native * context, so store both and discard irrevelant one in select request. */ if (is_pending || i == selected_ctx) new_flags |= contexts[i].flags & ~native_flags;
if (i == CTX_WOW && !dest_context->machine) { if (!is_pending) continue; /* If pending, lazily initialize machine */ dest_context->machine = thread->process->machine; }
copy_context( dest_context, &contexts[i], new_flags ); dest_context->flags |= flags; } } ```