// File: /workspace/github_c_makefile_star2_O3/martincameron[P]towntalk/worker.c
// Function: evaluate_result_expression
enum result evaluate_result_expression( struct expression *this,
	struct variables *vars, struct variable *result ) {
	struct expression *parameter = this->parameters;
	struct variable var = { 0, NULL };
	struct worker *work;
	int count, idx;
	char *str;
	enum result ret = evaluate_custom( parameter, &worker_type, vars, &var );
	if( ret ) {
		work = ( struct worker * ) var.string_value;
		if( work->locked == 0 ) {
			vars->func->env->worker = &work->custom;
			await_worker( work, vars->func->env->interrupted );
			vars->func->env->worker = NULL;
			count = work->env.entry_point->num_parameters;
			for( idx = 0; idx < count; idx++ ) {
				if( work->args[ idx ].string_value ) {
					/* Reassociate parameter strings if necessary. */
					str = work->args[ idx ].string_value->string;
					if( work->result.string_value && work->result.string_value->string == str ) {
						assign_variable( &work->args[ idx ], &work->result );
					}
					if( work->exception.string_value && work->exception.string_value->string == str ) {
						assign_variable( &work->args[ idx ], &work->exception );
					}
				}
			}
			if( work->ret == OKAY ) {
				if( work->result.string_value && work->result.string_value->type > ELEMENT ) {
					/* Only strings and elements can safely be assigned from another environment. */
					ret = throw( vars, this, 0, "Values of this type cannot be returned from workers." );
				} else {
					assign_variable( &work->result, result );
				}
			} else if( work->exception.string_value && work->exception.string_value->type > ELEMENT ) {
				ret = throw( vars, this, work->exception.number_value, work->exception.string_value->string );
			} else {
				assign_variable( &work->exception, vars->exception );
				ret = EXCEPTION;
			}
		} else {
			ret = throw( vars, this, 0, "Worker locked." );
		}
		dispose_temporary( &var );
	}
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
movq 0x8(%rdi), %rdi
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rcx
movaps %xmm0, (%rcx)
leaq 0x996b(%rip), %rsi      # 0x19f90
movq %r15, %rdx
callq 0x47d8
testl %eax, %eax
je 0x10662
movq 0x28(%rsp), %r13
cmpb $0x0, 0x3f8(%r13)
je 0x10675
leaq 0x2c8b(%rip), %rcx      # 0x132d2
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3c96
movl %eax, %ebx
leaq 0x20(%rsp), %rdi
callq 0x3a57
jmp 0x10664
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebx
movq %r12, 0x8(%rsp)
movq %r14, (%rsp)
movq 0x18(%r15), %rax
movq 0x40(%rax), %rax
movq $0x0, 0x3a0(%rax)
movq 0x3b8(%r13), %rax
movslq 0x1c(%rax), %rbp
testq %rbp, %rbp
jle 0x10729
leaq 0x3d0(%r13), %rax
movq %rax, 0x18(%rsp)
leaq 0x3e0(%r13), %rax
movq %rax, 0x10(%rsp)
shlq $0x4, %rbp
xorl %r12d, %r12d
movq 0x3c8(%r13), %rdi
movq 0x8(%rdi,%r12), %rax
testq %rax, %rax
je 0x10720
movq 0x8(%rax), %r14
movq 0x3d8(%r13), %rax
testq %rax, %rax
je 0x106fa
cmpq %r14, 0x8(%rax)
jne 0x106fa
addq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x3a65
movq 0x3e8(%r13), %rax
testq %rax, %rax
je 0x10720
cmpq %r14, 0x8(%rax)
jne 0x10720
movq 0x3c8(%r13), %rdi
addq %r12, %rdi
movq 0x10(%rsp), %rsi
callq 0x3a65
addq $0x10, %r12
cmpq %r12, %rbp
jne 0x106c6
cmpl $0x1, 0x418(%r13)
jne 0x10758
movq 0x3d8(%r13), %rax
testq %rax, %rax
movq (%rsp), %rsi
je 0x10785
cmpb $0x2, 0x14(%rax)
jl 0x10785
leaq 0x2b91(%rip), %rcx      # 0x132e1
movq %r15, %rdi
jmp 0x1064d
movq 0x3e8(%r13), %rax
addq $0x3e0, %r13            # imm = 0x3E0
testq %rax, %rax
movq (%rsp), %rsi
je 0x1079e
cmpb $0x2, 0x14(%rax)
jl 0x1079e
movl (%r13), %edx
movq 0x8(%rax), %rcx
movq %r15, %rdi
jmp 0x1064f
addq $0x3d0, %r13            # imm = 0x3D0
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x3a65
jmp 0x10656
movq 0x8(%r15), %rsi
movq %r13, %rdi
callq 0x3a65
xorl %ebx, %ebx
jmp 0x10656