// File: /workspace/github_c_makefile_star2_O0/martincameron[P]towntalk/worker.c
// Function: execute_lock_statement
static enum result execute_lock_statement( struct statement *this,
	struct variables *vars, struct variable *result ) {
	struct statement *stmt = ( ( struct block_statement * ) this )->if_block;
	struct worker *work = ( struct worker * ) vars->func->env->worker;
	struct variable var = { 0, NULL };
	char *locked = NULL;
	enum result ret = this->source->evaluate( this->source, vars, &var );
	if( ret ) {
		if( is_custom_instance( var.string_value, &worker_type ) ) {
			work = ( struct worker * ) var.string_value;
			locked = &work->locked;
		} else if( work ) {
			locked = &work->worker_locked;
		} else {
			ret = throw( vars, this->source, 0, "Not a worker.");
		}
		if( locked ) {
			if( locked[ 0 ] == 0 && lock_worker( work ) ) {
				locked[ 0 ] = 1;
				while( stmt ) {
					ret = stmt->execute( stmt, vars, result );
					if( ret == OKAY ) {
						stmt = stmt->next;
					} else {
						break;
					}
				}
				locked[ 0 ] = 0;
				if( unlock_worker( work ) == 0 ) {
					locked[ 0 ] = 1;
					ret = throw( vars, this->source, 0, "Unable to unlock worker.");
				}
			} else {
				ret = throw( vars, this->source, 0, "Unable to lock worker.");
			}
		}
		dispose_temporary( &var );
	}
	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x40(%rax), %rax
movq 0x3a0(%rax), %rax
movq %rax, -0x28(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x30f0
movq $0x0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq *%rax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x16ac8
movq -0x30(%rbp), %rdi
leaq 0xb5db(%rip), %rsi      # 0x21f80
callq 0x5580
cmpl $0x0, %eax
je 0x169c7
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $0x3f8, %rax            # imm = 0x3F8
movq %rax, -0x40(%rbp)
jmp 0x169fd
cmpq $0x0, -0x28(%rbp)
je 0x169de
movq -0x28(%rbp), %rax
addq $0x3f9, %rax            # imm = 0x3F9
movq %rax, -0x40(%rbp)
jmp 0x169fb
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
xorl %edx, %edx
leaq 0x5df8(%rip), %rcx      # 0x1c7eb
callq 0x4330
movl %eax, -0x44(%rbp)
jmp 0x169fd
cmpq $0x0, -0x40(%rbp)
je 0x16abf
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x16aa0
movq -0x28(%rbp), %rdi
callq 0x16740
cmpl $0x0, %eax
je 0x16aa0
movq -0x40(%rbp), %rax
movb $0x1, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x16a65
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq *%rax
movl %eax, -0x44(%rbp)
cmpl $0x1, -0x44(%rbp)
jne 0x16a61
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x16a63
jmp 0x16a65
jmp 0x16a2d
movq -0x40(%rbp), %rax
movb $0x0, (%rax)
movq -0x28(%rbp), %rdi
callq 0x16750
cmpl $0x0, %eax
jne 0x16a9e
movq -0x40(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
xorl %edx, %edx
leaq 0x5d63(%rip), %rcx      # 0x1c7f9
callq 0x4330
movl %eax, -0x44(%rbp)
jmp 0x16abd
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
xorl %edx, %edx
leaq 0x5d5d(%rip), %rcx      # 0x1c812
callq 0x4330
movl %eax, -0x44(%rbp)
jmp 0x16abf
leaq -0x38(%rbp), %rdi
callq 0x3ce0
movl -0x44(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)