// File: /workspace/github_c_makefile_star2_O3/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 0xbdf9
movq %rax, %r14
leaq 0xb132(%rip), %rdi      # 0xe08a
callq 0x91e7
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xc22e
movq %rax, %rbp
movq %rbx, 0x8(%rsp)
movq 0x30(%rbx), %rdi
callq 0xbd5a
movq %rax, %rdi
callq 0x3e4d
movq %rax, %r15
leaq 0xc7ce(%rip), %rdi      # 0xf75b
callq 0x91e7
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xc22e
movq %rax, %r13
leaq 0xc411(%rip), %rdi      # 0xf3ba
callq 0x91e7
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xc22e
movq %rax, %r14
leaq 0xb8bd(%rip), %rdi      # 0xe882
callq 0x91e7
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xc22e
movq %rax, %r15
leaq 0xb0b1(%rip), %rax      # 0xe092
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x10408(%rip), %rax     # 0x133f8
movq (%rax), %rax
movq 0x50(%rax), %rax
movl 0x8(%rax), %ecx
movl %ecx, 0x8(%rdi)
movl $0xf0, 0xc(%rdi)
leaq 0xcdf9(%rip), %rcx      # 0xfe04
movq %rcx, 0x10(%rdi)
leaq 0x1021a(%rip), %rcx     # 0x13230
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
callq 0xdb0e
leaq 0x10b76(%rip), %r12     # 0x13ba0
cmpl $0x0, (%r12)
je 0x30df
leaq 0x103bc(%rip), %rbx     # 0x133f8
movq (%rbx), %rax
movq 0x50(%rax), %rax
leaq 0xcdba(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd270
testl %eax, %eax
je 0x3088
movq (%rbx), %rax
movq 0x50(%rax), %rax
movl $0xf1, 0xc(%rax)
movq %r14, %rsi
shrq $0x2, %rsi
movq %r15, %rdx
shrq $0x2, %rdx
movq %r13, %rcx
shrq $0x2, %rcx
leaq 0xb01c(%rip), %rdi      # 0xe09d
xorl %eax, %eax
callq 0xdb7f
cmpl $0x0, (%r12)
je 0x30df
leaq 0x10362(%rip), %rax     # 0x133f8
movq (%rax), %rax
movq 0x50(%rax), %rax
leaq 0xcd60(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd270
testl %eax, %eax
je 0x30df
leaq 0x10340(%rip), %rax     # 0x133f8
movq (%rax), %rax
movq 0x50(%rax), %rax
movl $0xf2, 0xc(%rax)
movq %rbp, %rdi
callq 0x5d28
leaq 0xafdb(%rip), %rdi      # 0xe0b0
movq %rax, %rsi
xorl %eax, %eax
callq 0xdb7f
leaq 0xafd5(%rip), %rdi      # 0xe0bb
callq 0x91e7
cmpq %rax, %rbp
je 0x319e
leaq 0xafcc(%rip), %rdi      # 0xe0c7
callq 0x91e7
cmpq %rax, %rbp
je 0x322a
leaq 0xafe3(%rip), %rdi      # 0xe0f3
callq 0x91e7
cmpq %rax, %rbp
jne 0x320a
cmpq $0x1bf, %r13            # imm = 0x1BF
movl $0x2a, %ecx
movl $0x78, %eax
cmovel %ecx, %eax
shrq $0x2, %r14
shrq $0x2, %r15
xorl %ecx, %ecx
testl %r14d, %r14d
movl $0x0, %edx
cmovgl %r14d, %edx
subl %r14d, %edx
movl $0x7, %esi
addl %esi, %edx
andl $-0x8, %edx
addl %r14d, %edx
cmpl $0x8, %edx
movl $0x7, %edi
cmovgel %edx, %edi
movl $0x7ffffff8, %r8d       # imm = 0x7FFFFFF8
andl %r8d, %edi
subl %edi, %edx
testl %r15d, %r15d
cmovgl %r15d, %ecx
subl %r15d, %ecx
addl %esi, %ecx
andl $-0x8, %ecx
addl %r15d, %ecx
cmpl $0x8, %ecx
cmovgel %ecx, %esi
andl %r8d, %esi
subl %esi, %ecx
shlq $0x5, %rcx
leaq 0xff9a(%rip), %rsi      # 0x13130
addq %rcx, %rsi
movl %eax, (%rsi,%rdx,4)
jmp 0x320a
shrq $0x2, %r14
shrq $0x2, %r15
shrq $0x2, %r13
xorl %eax, %eax
testl %r14d, %r14d
movl $0x0, %ecx
cmovgl %r14d, %ecx
subl %r14d, %ecx
movl $0x7, %edx
addl %edx, %ecx
andl $-0x8, %ecx
addl %r14d, %ecx
cmpl $0x8, %ecx
movl $0x7, %esi
cmovgel %ecx, %esi
movl $0x7ffffff8, %edi       # imm = 0x7FFFFFF8
andl %edi, %esi
subl %esi, %ecx
testl %r15d, %r15d
cmovgl %r15d, %eax
subl %r15d, %eax
addl %edx, %eax
andl $-0x8, %eax
addl %r15d, %eax
cmpl $0x8, %eax
cmovgel %eax, %edx
andl %edi, %edx
subl %edx, %eax
shlq $0x5, %rax
leaq 0xff2d(%rip), %rdx      # 0x13130
addq %rax, %rdx
movl %r13d, (%rdx,%rcx,4)
leaq 0x10(%rsp), %rdi
movl $0x113, 0xc(%rdi)       # imm = 0x113
callq 0xdc93
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
shrq $0x2, %rdi
movq %r15, %rsi
shrq $0x2, %rsi
callq 0x2da3
movl %eax, %ebp
cmpl $0x0, (%r12)
je 0x328d
leaq 0x101ab(%rip), %rax     # 0x133f8
movq (%rax), %rax
movq 0x50(%rax), %rax
leaq 0xcba9(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd270
testl %eax, %eax
je 0x328d
leaq 0x10189(%rip), %rax     # 0x133f8
movq (%rax), %rax
movq 0x50(%rax), %rax
movl $0xf7, 0xc(%rax)
leaq 0xae4c(%rip), %rdi      # 0xe0d0
movl %ebp, %esi
xorl %eax, %eax
callq 0xdb7f
cmpq $0x1bf, %r13            # imm = 0x1BF
je 0x3358
cmpq $0xbb, %r13
jne 0x320a
cmpl $0x3, %ebp
jne 0x320a
leaq 0xb5cb(%rip), %rdi      # 0xe882
callq 0x91e7
leaq 0x100a5(%rip), %rdi     # 0x13368
movq %rax, %rsi
movq %r15, %rdx
callq 0xc2a0
movq %rax, %r15
leaq 0xc0e2(%rip), %rdi      # 0xf3ba
callq 0x91e7
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xc2a0
movq %rax, %r14
leaq 0xc466(%rip), %rdi      # 0xf75b
callq 0x91e7
movl $0x1bf, %edx            # imm = 0x1BF
movq %r14, %rdi
movq %rax, %rsi
callq 0xc2a0
movq %rax, %r14
cmpl $0x0, (%r12)
leaq 0x100df(%rip), %r15     # 0x133f8
je 0x3406
movq (%r15), %rax
movq 0x50(%rax), %rax
leaq 0xcad7(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd270
testl %eax, %eax
je 0x3406
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0xfe, 0xc(%rax)
leaq 0xad8a(%rip), %rdi      # 0xe0dd
jmp 0x33ff
addl $-0x4, %ebp
cmpl $-0x3, %ebp
ja 0x320a
leaq 0xb517(%rip), %rdi      # 0xe882
callq 0x91e7
leaq 0xfff1(%rip), %rdi      # 0x13368
movq %rax, %rsi
movq %r15, %rdx
callq 0xc2a0
movq %rax, %r15
leaq 0xc02e(%rip), %rdi      # 0xf3ba
callq 0x91e7
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xc2a0
movq %rax, %r14
leaq 0xc3b2(%rip), %rdi      # 0xf75b
callq 0x91e7
movl $0xbb, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0xc2a0
movq %rax, %r14
cmpl $0x0, (%r12)
leaq 0x1002b(%rip), %r15     # 0x133f8
je 0x3406
movq (%r15), %rax
movq 0x50(%rax), %rax
leaq 0xca27(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd270
testl %eax, %eax
je 0x3406
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x107, 0xc(%rax)       # imm = 0x107
leaq 0xace9(%rip), %rdi      # 0xe0e8
xorl %eax, %eax
callq 0xdb7f
movq 0x8(%rsp), %rbx
movq 0x30(%rbx), %rdi
callq 0xbd5a
movq %rax, %r15
movq 0x30(%rbx), %rdi
callq 0xbd5a
movq %rax, %rdi
callq 0x3e14
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x40a6
jmp 0x320a