// File: kipa00[P]AplusB-mc/compiler/analyze.cpp
// Function: redstone_into(world const&, int, int, int, int, int, int)
bool redstone_into(const world &w, int x, int y, int z, int ox, int oy, int oz) {
	if (abs(x - ox) + abs(y - oy) + abs(z - oz) != 1) return false;
	if (x == ox && y - 1 == oy && z == oz) return true;
	if (y != oy) return false;

	bool block_upper = is_opaque(w.getXYZ(x, y + 1, z));
#define f(dx,dz) (\
	(w.getXYZ(x + dx, y, z + dz) & BLOCK_ONLY) == REDSTONE_WIRE\
	|| ((w.getXYZ(x + dx, y + 1, z + dz) & BLOCK_ONLY) == REDSTONE_WIRE && !block_upper)\
	|| ((w.getXYZ(x + dx, y - 1, z + dz) & BLOCK_ONLY) == REDSTONE_WIRE && !is_opaque(w.getXYZ(x + dx, y, z + dz)))\
)
	bool east = f(1, 0);
	bool west = f(-1, 0);
	bool south = f(0, 1);
	bool north = f(0, -1);
#undef f
	int flag = east + west + south + north;
	if (!flag) {
		east = west = south = north = true;
	} else if (flag == 1) {
		if (east) west = true;
		else if (west) east = true;
		else if (south) north = true;
		else if (north) south = true;
	}
	if (x + 1 == ox) return east;
	else if (x - 1 == ox) return west;
	else if (z + 1 == oz) return south;
	else if (z - 1 == oz) return north;
	return false;
}

// Assembly:
subq $0x38, %rsp
movl 0x40(%rsp), %eax
movq %rdi, 0x28(%rsp)
movl %esi, 0x24(%rsp)
movl %edx, 0x20(%rsp)
movl %ecx, 0x1c(%rsp)
movl %r8d, 0x18(%rsp)
movl %r9d, 0x14(%rsp)
movl 0x24(%rsp), %eax
subl 0x18(%rsp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl 0x20(%rsp), %ecx
subl 0x14(%rsp), %ecx
movl %ecx, %edx
negl %edx
cmovnsl %edx, %ecx
addl %ecx, %eax
movl 0x1c(%rsp), %ecx
subl 0x40(%rsp), %ecx
movl %ecx, %edx
negl %edx
cmovnsl %edx, %ecx
addl %ecx, %eax
cmpl $0x1, %eax
je 0xa663
movb $0x0, 0x37(%rsp)
jmp 0xab3a
movl 0x24(%rsp), %eax
cmpl 0x18(%rsp), %eax
jne 0xa68e
movl 0x20(%rsp), %eax
subl $0x1, %eax
cmpl 0x14(%rsp), %eax
jne 0xa68e
movl 0x1c(%rsp), %eax
cmpl 0x40(%rsp), %eax
jne 0xa68e
movb $0x1, 0x37(%rsp)
jmp 0xab3a
movl 0x20(%rsp), %eax
cmpl 0x14(%rsp), %eax
je 0xa6a2
movb $0x0, 0x37(%rsp)
jmp 0xab3a
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
movl 0x20(%rsp), %edx
addl $0x1, %edx
movl 0x1c(%rsp), %ecx
callq 0xa120
movzbl %al, %edi
callq 0x12a70
andb $0x1, %al
movb %al, 0x13(%rsp)
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x1, %esi
movl 0x20(%rsp), %edx
movl 0x1c(%rsp), %ecx
addl $0x0, %ecx
callq 0xa120
movzbl %al, %ecx
andl $0xf0, %ecx
movb $0x1, %al
cmpl $0x40, %ecx
movb %al, 0x7(%rsp)
je 0xa79b
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x1, %esi
movl 0x20(%rsp), %edx
addl $0x1, %edx
movl 0x1c(%rsp), %ecx
addl $0x0, %ecx
callq 0xa120
movzbl %al, %eax
andl $0xf0, %eax
cmpl $0x40, %eax
jne 0xa736
movb $0x1, %al
testb $0x1, 0x13(%rsp)
movb %al, 0x7(%rsp)
je 0xa79b
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x1, %esi
movl 0x20(%rsp), %edx
subl $0x1, %edx
movl 0x1c(%rsp), %ecx
addl $0x0, %ecx
callq 0xa120
movzbl %al, %ecx
andl $0xf0, %ecx
xorl %eax, %eax
cmpl $0x40, %ecx
movb %al, 0x6(%rsp)
jne 0xa793
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x1, %esi
movl 0x20(%rsp), %edx
movl 0x1c(%rsp), %ecx
addl $0x0, %ecx
callq 0xa120
movzbl %al, %edi
callq 0x12a70
xorb $-0x1, %al
movb %al, 0x6(%rsp)
movb 0x6(%rsp), %al
movb %al, 0x7(%rsp)
movb 0x7(%rsp), %al
andb $0x1, %al
movb %al, 0x12(%rsp)
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $-0x1, %esi
movl 0x20(%rsp), %edx
movl 0x1c(%rsp), %ecx
addl $0x0, %ecx
callq 0xa120
movzbl %al, %ecx
andl $0xf0, %ecx
movb $0x1, %al
cmpl $0x40, %ecx
movb %al, 0x5(%rsp)
je 0xa877
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $-0x1, %esi
movl 0x20(%rsp), %edx
addl $0x1, %edx
movl 0x1c(%rsp), %ecx
addl $0x0, %ecx
callq 0xa120
movzbl %al, %eax
andl $0xf0, %eax
cmpl $0x40, %eax
jne 0xa812
movb $0x1, %al
testb $0x1, 0x13(%rsp)
movb %al, 0x5(%rsp)
je 0xa877
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $-0x1, %esi
movl 0x20(%rsp), %edx
subl $0x1, %edx
movl 0x1c(%rsp), %ecx
addl $0x0, %ecx
callq 0xa120
movzbl %al, %ecx
andl $0xf0, %ecx
xorl %eax, %eax
cmpl $0x40, %ecx
movb %al, 0x4(%rsp)
jne 0xa86f
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $-0x1, %esi
movl 0x20(%rsp), %edx
movl 0x1c(%rsp), %ecx
addl $0x0, %ecx
callq 0xa120
movzbl %al, %edi
callq 0x12a70
xorb $-0x1, %al
movb %al, 0x4(%rsp)
movb 0x4(%rsp), %al
movb %al, 0x5(%rsp)
movb 0x5(%rsp), %al
andb $0x1, %al
movb %al, 0x11(%rsp)
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x0, %esi
movl 0x20(%rsp), %edx
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
callq 0xa120
movzbl %al, %ecx
andl $0xf0, %ecx
movb $0x1, %al
cmpl $0x40, %ecx
movb %al, 0x3(%rsp)
je 0xa953
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x0, %esi
movl 0x20(%rsp), %edx
addl $0x1, %edx
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
callq 0xa120
movzbl %al, %eax
andl $0xf0, %eax
cmpl $0x40, %eax
jne 0xa8ee
movb $0x1, %al
testb $0x1, 0x13(%rsp)
movb %al, 0x3(%rsp)
je 0xa953
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x0, %esi
movl 0x20(%rsp), %edx
subl $0x1, %edx
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
callq 0xa120
movzbl %al, %ecx
andl $0xf0, %ecx
xorl %eax, %eax
cmpl $0x40, %ecx
movb %al, 0x2(%rsp)
jne 0xa94b
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x0, %esi
movl 0x20(%rsp), %edx
movl 0x1c(%rsp), %ecx
addl $0x1, %ecx
callq 0xa120
movzbl %al, %edi
callq 0x12a70
xorb $-0x1, %al
movb %al, 0x2(%rsp)
movb 0x2(%rsp), %al
movb %al, 0x3(%rsp)
movb 0x3(%rsp), %al
andb $0x1, %al
movb %al, 0x10(%rsp)
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x0, %esi
movl 0x20(%rsp), %edx
movl 0x1c(%rsp), %ecx
addl $-0x1, %ecx
callq 0xa120
movzbl %al, %ecx
andl $0xf0, %ecx
movb $0x1, %al
cmpl $0x40, %ecx
movb %al, 0x1(%rsp)
je 0xaa2c
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x0, %esi
movl 0x20(%rsp), %edx
addl $0x1, %edx
movl 0x1c(%rsp), %ecx
addl $-0x1, %ecx
callq 0xa120
movzbl %al, %eax
andl $0xf0, %eax
cmpl $0x40, %eax
jne 0xa9ca
movb $0x1, %al
testb $0x1, 0x13(%rsp)
movb %al, 0x1(%rsp)
je 0xaa2c
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x0, %esi
movl 0x20(%rsp), %edx
subl $0x1, %edx
movl 0x1c(%rsp), %ecx
addl $-0x1, %ecx
callq 0xa120
movzbl %al, %ecx
andl $0xf0, %ecx
xorl %eax, %eax
cmpl $0x40, %ecx
movb %al, (%rsp)
jne 0xaa25
movq 0x28(%rsp), %rdi
movl 0x24(%rsp), %esi
addl $0x0, %esi
movl 0x20(%rsp), %edx
movl 0x1c(%rsp), %ecx
addl $-0x1, %ecx
callq 0xa120
movzbl %al, %edi
callq 0x12a70
xorb $-0x1, %al
movb %al, (%rsp)
movb (%rsp), %al
movb %al, 0x1(%rsp)
movb 0x1(%rsp), %al
andb $0x1, %al
movb %al, 0xf(%rsp)
movb 0x12(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movb 0x11(%rsp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movb 0x10(%rsp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movb 0xf(%rsp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movl %eax, 0x8(%rsp)
cmpl $0x0, 0x8(%rsp)
jne 0xaa84
movb $0x1, 0xf(%rsp)
movb $0x1, 0x10(%rsp)
movb $0x1, 0x11(%rsp)
movb $0x1, 0x12(%rsp)
jmp 0xaacb
cmpl $0x1, 0x8(%rsp)
jne 0xaac9
testb $0x1, 0x12(%rsp)
je 0xaa99
movb $0x1, 0x11(%rsp)
jmp 0xaac7
testb $0x1, 0x11(%rsp)
je 0xaaa7
movb $0x1, 0x12(%rsp)
jmp 0xaac5
testb $0x1, 0x10(%rsp)
je 0xaab5
movb $0x1, 0xf(%rsp)
jmp 0xaac3
testb $0x1, 0xf(%rsp)
je 0xaac1
movb $0x1, 0x10(%rsp)
jmp 0xaac3
jmp 0xaac5
jmp 0xaac7
jmp 0xaac9
jmp 0xaacb
movl 0x24(%rsp), %eax
addl $0x1, %eax
cmpl 0x18(%rsp), %eax
jne 0xaae4
movb 0x12(%rsp), %al
andb $0x1, %al
movb %al, 0x37(%rsp)
jmp 0xab3a
movl 0x24(%rsp), %eax
subl $0x1, %eax
cmpl 0x18(%rsp), %eax
jne 0xaafd
movb 0x11(%rsp), %al
andb $0x1, %al
movb %al, 0x37(%rsp)
jmp 0xab3a
movl 0x1c(%rsp), %eax
addl $0x1, %eax
cmpl 0x40(%rsp), %eax
jne 0xab16
movb 0x10(%rsp), %al
andb $0x1, %al
movb %al, 0x37(%rsp)
jmp 0xab3a
movl 0x1c(%rsp), %eax
subl $0x1, %eax
cmpl 0x40(%rsp), %eax
jne 0xab2f
movb 0xf(%rsp), %al
andb $0x1, %al
movb %al, 0x37(%rsp)
jmp 0xab3a
jmp 0xab31
jmp 0xab33
jmp 0xab35
movb $0x0, 0x37(%rsp)
movb 0x37(%rsp), %al
andb $0x1, %al
addq $0x38, %rsp
retq
nopw %cs:(%rax,%rax)