// File: /workspace/github_c_makefile_star2_O1/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 0xbdd9
movq %rax, %r14
leaq 0xb0d2(%rip), %rdi      # 0xe08a
callq 0x9210
movq %r14, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xc20e
movq %rax, %rbp
movq %rbx, 0x8(%rsp)
movq 0x30(%rbx), %rdi
callq 0xbd3a
movq %rax, %rdi
callq 0x3ea5
movq %rax, %r15
leaq 0xc76e(%rip), %rdi      # 0xf75b
callq 0x9210
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xc20e
movq %rax, %r13
leaq 0xc3b1(%rip), %rdi      # 0xf3ba
callq 0x9210
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xc20e
movq %rax, %r14
leaq 0xb85d(%rip), %rdi      # 0xe882
callq 0x9210
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0xc20e
movq %rax, %r15
leaq 0xb051(%rip), %rax      # 0xe092
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x103a8(%rip), %rbx     # 0x133f8
movq (%rbx), %rax
movq 0x50(%rax), %rax
movl 0x8(%rax), %ecx
movl %ecx, 0x8(%rdi)
movl $0xf0, 0xc(%rdi)
leaq 0xcd99(%rip), %rcx      # 0xfe04
movq %rcx, 0x10(%rdi)
leaq 0x101ba(%rip), %rcx     # 0x13230
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
callq 0xdaa6
leaq 0x10b16(%rip), %rax     # 0x13ba0
movq %rax, %r12
cmpl $0x0, (%rax)
je 0x30de
movq (%rbx), %rax
movq 0x50(%rax), %rax
leaq 0xcd64(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd218
testl %eax, %eax
je 0x30de
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 0xafc6(%rip), %rdi      # 0xe09d
xorl %eax, %eax
callq 0xdb17
cmpl $0x0, (%r12)
je 0x3135
leaq 0x1030c(%rip), %rax     # 0x133f8
movq (%rax), %rax
movq 0x50(%rax), %rax
leaq 0xcd0a(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd218
testl %eax, %eax
je 0x3135
leaq 0x102ea(%rip), %rax     # 0x133f8
movq (%rax), %rax
movq 0x50(%rax), %rax
movl $0xf2, 0xc(%rax)
movq %rbp, %rdi
callq 0x5d30
leaq 0xaf85(%rip), %rdi      # 0xe0b0
movq %rax, %rsi
xorl %eax, %eax
callq 0xdb17
leaq 0xaf7f(%rip), %rdi      # 0xe0bb
callq 0x9210
cmpq %rax, %rbp
je 0x31f4
leaq 0xaf76(%rip), %rdi      # 0xe0c7
callq 0x9210
cmpq %rax, %rbp
je 0x3280
leaq 0xaf8d(%rip), %rdi      # 0xe0f3
callq 0x9210
cmpq %rax, %rbp
jne 0x3260
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 0xff44(%rip), %rsi      # 0x13130
addq %rcx, %rsi
movl %eax, (%rsi,%rdx,4)
jmp 0x3260
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 0xfed7(%rip), %rdx      # 0x13130
addq %rax, %rdx
movl %r13d, (%rdx,%rcx,4)
leaq 0x10(%rsp), %rdi
movl $0x113, 0xc(%rdi)       # imm = 0x113
callq 0xdc2b
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 0x2e03
movl %eax, %ebp
cmpl $0x0, (%r12)
je 0x32e3
leaq 0x10155(%rip), %rax     # 0x133f8
movq (%rax), %rax
movq 0x50(%rax), %rax
leaq 0xcb53(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd218
testl %eax, %eax
je 0x32e3
leaq 0x10133(%rip), %rax     # 0x133f8
movq (%rax), %rax
movq 0x50(%rax), %rax
movl $0xf7, 0xc(%rax)
leaq 0xadf6(%rip), %rdi      # 0xe0d0
movl %ebp, %esi
xorl %eax, %eax
callq 0xdb17
cmpq $0x1bf, %r13            # imm = 0x1BF
je 0x33ae
cmpq $0xbb, %r13
jne 0x3260
cmpl $0x3, %ebp
jne 0x3260
leaq 0xb575(%rip), %rdi      # 0xe882
callq 0x9210
leaq 0x1004f(%rip), %rdi     # 0x13368
movq %rax, %rsi
movq %r15, %rdx
callq 0xc280
movq %rax, %r15
leaq 0xc08c(%rip), %rdi      # 0xf3ba
callq 0x9210
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xc280
movq %rax, %r14
leaq 0xc410(%rip), %rdi      # 0xf75b
callq 0x9210
movl $0x1bf, %edx            # imm = 0x1BF
movq %r14, %rdi
movq %rax, %rsi
callq 0xc280
movq %rax, %r14
cmpl $0x0, (%r12)
leaq 0x10089(%rip), %rbx     # 0x133f8
je 0x345c
movq (%rbx), %rax
movq 0x50(%rax), %rax
leaq 0xca81(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd218
testl %eax, %eax
je 0x345c
movq (%rbx), %rax
movq 0x50(%rax), %rax
movl $0xfe, 0xc(%rax)
leaq 0xad34(%rip), %rdi      # 0xe0dd
jmp 0x3455
addl $-0x4, %ebp
cmpl $-0x3, %ebp
ja 0x3260
leaq 0xb4c1(%rip), %rdi      # 0xe882
callq 0x9210
leaq 0xff9b(%rip), %rdi      # 0x13368
movq %rax, %rsi
movq %r15, %rdx
callq 0xc280
movq %rax, %r15
leaq 0xbfd8(%rip), %rdi      # 0xf3ba
callq 0x9210
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xc280
movq %rax, %r14
leaq 0xc35c(%rip), %rdi      # 0xf75b
callq 0x9210
movl $0xbb, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0xc280
movq %rax, %r14
cmpl $0x0, (%r12)
leaq 0xffd5(%rip), %rbx      # 0x133f8
je 0x345c
movq (%rbx), %rax
movq 0x50(%rax), %rax
leaq 0xc9d1(%rip), %rdi      # 0xfe04
movq %rdi, 0x10(%rax)
callq 0xd218
testl %eax, %eax
je 0x345c
movq (%rbx), %rax
movq 0x50(%rax), %rax
movl $0x107, 0xc(%rax)       # imm = 0x107
leaq 0xac93(%rip), %rdi      # 0xe0e8
xorl %eax, %eax
callq 0xdb17
movq 0x8(%rsp), %rbx
movq 0x30(%rbx), %rdi
callq 0xbd3a
movq %rax, %r15
movq 0x30(%rbx), %rdi
callq 0xbd3a
movq %rax, %rdi
callq 0x3e6c
movq %r15, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x40b4
jmp 0x3260