// File: /workspace/github_c_makefile_star2_O2/dalnefre[P]kernel_abe/life.c
// Function: cell_actor
BEH_DECL(cell_actor)
{
	CONS* msg = WHAT;
	CONS* request = map_get(msg, ATOM("request"));
/*	CONS* reply_to = map_get(msg, ATOM("reply-to")); */
	CONS* state = MINE;
	CONS* value = map_get(state, ATOM("value"));
	CONS* x = map_get(state, ATOM("x"));
	CONS* y = map_get(state, ATOM("y"));
	
	DBUG_ENTER("cell_actor");
	DBUG_PRINT("", ("x=%d y=%d value=%c", MK_INT(x), MK_INT(y), MK_INT(value)));
	DBUG_PRINT("", ("request=%s", cons_to_str(request)));
	if (request == ATOM("update-grid")) {
		set_grid_value(MK_INT(x), MK_INT(y), MK_INT(value));
	} else if (request == ATOM("gen-next")) {
		int n = count_neighbors(MK_INT(x), MK_INT(y));
		DBUG_PRINT("", ("neighbors=%d", n));
		if (value == NUMBER(EMPTY)) {
			if (n == 3) {
				CONS* state = NIL;
				state = map_put(state, ATOM("y"), y);
				state = map_put(state, ATOM("x"), x);
				state = map_put(state, ATOM("value"), NUMBER(FULL));
				DBUG_PRINT("", ("cell birth"));
				BECOME(THIS, state);
			}
		} else if (value == NUMBER(FULL)) {
			if ((n < 2) || (n > 3)) {
				CONS* state = NIL;
				state = map_put(state, ATOM("y"), y);
				state = map_put(state, ATOM("x"), x);
				state = map_put(state, ATOM("value"), NUMBER(EMPTY));
				DBUG_PRINT("", ("cell death"));
				BECOME(THIS, state);
			}
		}
	} else if (request == ATOM("die")) {
		if (value == NUMBER(FULL)) {
			value = NUMBER('*');
		} else {
			value = NUMBER(DEAD);
		}
		set_grid_value(MK_INT(x), MK_INT(y), MK_INT(value));
	}
	DBUG_RETURN;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
callq 0xb3d2
movq %rax, %r14
leaq 0xb610(%rip), %rdi      # 0xe08a
callq 0x89eb
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xb853
movq %rax, %rbp
movq %rbx, 0x8(%rsp)
movq 0x30(%rbx), %rdi
callq 0xb2c7
movq %rax, %rdi
callq 0x3827
movq %rax, %r15
leaq 0xcc88(%rip), %rdi      # 0xf737
callq 0x89eb
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xb853
movq %rax, %r13
leaq 0xc8cb(%rip), %rdi      # 0xf396
callq 0x89eb
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xb853
movq %rax, %r14
leaq 0xbd77(%rip), %rdi      # 0xe85e
callq 0x89eb
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xb853
movq %rax, %r12
leaq 0xb58f(%rip), %rax      # 0xe092
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x118e6(%rip), %rax     # 0x143f8
movq (%rax), %rax
movq 0x50(%rax), %rax
movl 0x8(%rax), %ecx
movl %ecx, 0x8(%rdi)
movl $0xf0, 0xc(%rdi)
leaq 0xd2b3(%rip), %rcx      # 0xfde0
movq %rcx, 0x10(%rdi)
leaq 0x116f8(%rip), %rcx     # 0x14230
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
callq 0xd145
leaq 0x12054(%rip), %r15     # 0x14ba0
cmpl $0x0, (%r15)
je 0x2bff
leaq 0x1189b(%rip), %rbx     # 0x143f8
movq (%rbx), %rax
movq 0x50(%rax), %rax
leaq 0xd275(%rip), %rdi      # 0xfde0
movq %rdi, 0x10(%rax)
callq 0xc8c0
testl %eax, %eax
je 0x2ba9
movq (%rbx), %rax
movq 0x50(%rax), %rax
movl $0xf1, 0xc(%rax)
movq %r14, %rsi
shrq $0x2, %rsi
movq %r12, %rdx
shrq $0x2, %rdx
movq %r13, %rcx
shrq $0x2, %rcx
leaq 0xb4fb(%rip), %rdi      # 0xe09d
xorl %eax, %eax
callq 0xd1bc
cmpl $0x0, (%r15)
je 0x2bff
leaq 0x11842(%rip), %rax     # 0x143f8
movq (%rax), %rax
movq 0x50(%rax), %rax
leaq 0xd21c(%rip), %rdi      # 0xfde0
movq %rdi, 0x10(%rax)
callq 0xc8c0
testl %eax, %eax
je 0x2bff
leaq 0x11820(%rip), %rax     # 0x143f8
movq (%rax), %rax
movq 0x50(%rax), %rax
movl $0xf2, 0xc(%rax)
movq %rbp, %rdi
callq 0x57d4
leaq 0xb4bb(%rip), %rdi      # 0xe0b0
movq %rax, %rsi
xorl %eax, %eax
callq 0xd1bc
leaq 0xb4b5(%rip), %rdi      # 0xe0bb
callq 0x89eb
cmpq %rax, %rbp
je 0x2c52
leaq 0xb4b0(%rip), %rdi      # 0xe0c7
callq 0x89eb
cmpq %rax, %rbp
je 0x2c8c
leaq 0xb4cb(%rip), %rdi      # 0xe0f3
callq 0x89eb
cmpq %rax, %rbp
jne 0x2c6c
cmpq $0x1bf, %r13            # imm = 0x1BF
pushq $0x2a
popq %rax
pushq $0x78
popq %rdx
cmovel %eax, %edx
shrq $0x2, %r14
shrq $0x2, %r12
movl %r14d, %edi
movl %r12d, %esi
jmp 0x2c67
shrq $0x2, %r14
shrq $0x2, %r12
shrq $0x2, %r13
movl %r14d, %edi
movl %r12d, %esi
movl %r13d, %edx
callq 0x23b1
leaq 0x10(%rsp), %rdi
movl $0x113, 0xc(%rdi)       # imm = 0x113
callq 0xd2be
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
shrq $0x2, %rdi
movq %r12, %rsi
shrq $0x2, %rsi
callq 0x2975
movl %eax, %ebp
cmpl $0x0, (%r15)
je 0x2cee
leaq 0x1174a(%rip), %rax     # 0x143f8
movq (%rax), %rax
movq 0x50(%rax), %rax
leaq 0xd124(%rip), %rdi      # 0xfde0
movq %rdi, 0x10(%rax)
callq 0xc8c0
testl %eax, %eax
je 0x2cee
leaq 0x11728(%rip), %rax     # 0x143f8
movq (%rax), %rax
movq 0x50(%rax), %rax
movl $0xf7, 0xc(%rax)
leaq 0xb3eb(%rip), %rdi      # 0xe0d0
movl %ebp, %esi
xorl %eax, %eax
callq 0xd1bc
cmpq $0x1bf, %r13            # imm = 0x1BF
je 0x2dba
cmpq $0xbb, %r13
jne 0x2c6c
cmpl $0x3, %ebp
jne 0x2c6c
leaq 0xbb46(%rip), %rdi      # 0xe85e
callq 0x89eb
leaq 0x11644(%rip), %rdi     # 0x14368
movq %rax, %rsi
movq %r12, %rdx
callq 0xb8c5
movq %rax, %r12
leaq 0xc65d(%rip), %rdi      # 0xf396
callq 0x89eb
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xb8c5
movq %rax, %r14
leaq 0xc9e1(%rip), %rdi      # 0xf737
callq 0x89eb
movl $0x1bf, %edx            # imm = 0x1BF
movq %r14, %rdi
movq %rax, %rsi
callq 0xb8c5
movq %rax, %r14
cmpl $0x0, (%r15)
leaq 0x1167f(%rip), %r12     # 0x143f8
je 0x2e69
movq (%r12), %rax
movq 0x50(%rax), %rax
leaq 0xd052(%rip), %rdi      # 0xfde0
movq %rdi, 0x10(%rax)
callq 0xc8c0
testl %eax, %eax
je 0x2e69
movq (%r12), %rax
movq 0x50(%rax), %rax
movl $0xfe, 0xc(%rax)
leaq 0xb328(%rip), %rdi      # 0xe0dd
jmp 0x2e62
addl $-0x4, %ebp
cmpl $-0x3, %ebp
ja 0x2c6c
leaq 0xba91(%rip), %rdi      # 0xe85e
callq 0x89eb
leaq 0x1158f(%rip), %rdi     # 0x14368
movq %rax, %rsi
movq %r12, %rdx
callq 0xb8c5
movq %rax, %r12
leaq 0xc5a8(%rip), %rdi      # 0xf396
callq 0x89eb
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xb8c5
movq %rax, %r14
leaq 0xc92c(%rip), %rdi      # 0xf737
callq 0x89eb
movl $0xbb, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0xb8c5
movq %rax, %r14
cmpl $0x0, (%r15)
leaq 0x115ca(%rip), %r12     # 0x143f8
je 0x2e69
movq (%r12), %rax
movq 0x50(%rax), %rax
leaq 0xcfa1(%rip), %rdi      # 0xfde0
movq %rdi, 0x10(%rax)
callq 0xc8c0
testl %eax, %eax
je 0x2e69
movq (%r12), %rax
movq 0x50(%rax), %rax
movl $0x107, 0xc(%rax)       # imm = 0x107
leaq 0xb286(%rip), %rdi      # 0xe0e8
xorl %eax, %eax
callq 0xd1bc
movq 0x8(%rsp), %rbx
movq 0x30(%rbx), %rdi
callq 0xb2c7
movq %rax, %r15
movq 0x30(%rbx), %rdi
callq 0xb2c7
movq %rax, %rdi
callq 0x37f0
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x3be2
jmp 0x2c6c