// File: lotuskip[P]yuxtapa/server/chores.cpp
// Function: (anonymous namespace)::cant_dig_in(Coords const&, e_Dir)
char cant_dig_in(const Coords &c, const e_Dir d)
{
	// Mining requires one of: (A) there is a wall/window/door, (B) there is a blocked
	// boulder, (C) there is a boulder source.
	Tile* tp = Game::curmap->mod_tile(c);
	if(tp->symbol == '#' && tp->flags & TF_WALKTHRU)
		return -1;
	if(tp->symbol == '#' || tp->symbol == '|' || tp->symbol == '-' || tp->symbol == '+'
		|| ((tp->flags & TF_NOCCENT) && any_noccent_at(c, NOE_BLOCK_SOURCE)
			!= noccents[NOE_BLOCK_SOURCE].end()))
		return 0;
	// that was (A) and (C); (B) is more complicated:
	if(tp->flags & TF_OCCUPIED && any_boulder_at(c) != boulders.end())
	{
		Coords pushtarpos = c.in(d);
		Tile *pushtar = Game::curmap->mod_tile(pushtarpos);
		if((tp->flags & TF_SLOWWALK) || (pushtar->flags & TF_OCCUPIED)
			|| !(pushtar->flags & TF_WALKTHRU) || pushtar->symbol == '\\'
			|| ((pushtar->flags & TF_NOCCENT)
			&& any_noccent_at(pushtarpos, NOE_FLAG) != noccents[NOE_FLAG].end()))
			return 0; // cannot push; hence can dig
	}
	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
leaq 0x3d9af(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x3d2d0
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x23, %eax
jne 0x5445e
movq -0x20(%rbp), %rax
movzwl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x5445e
movb $-0x1, -0x1(%rbp)
jmp 0x54684
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %ecx
movb $0x1, %al
cmpl $0x23, %ecx
movb %al, -0x75(%rbp)
je 0x544fa
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %ecx
movb $0x1, %al
cmpl $0x7c, %ecx
movb %al, -0x75(%rbp)
je 0x544fa
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %ecx
movb $0x1, %al
cmpl $0x2d, %ecx
movb %al, -0x75(%rbp)
je 0x544fa
movq -0x20(%rbp), %rax
movsbl 0x2(%rax), %ecx
movb $0x1, %al
cmpl $0x2b, %ecx
movb %al, -0x75(%rbp)
je 0x544fa
movq -0x20(%rbp), %rax
movzwl (%rax), %ecx
andl $0x20, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x76(%rbp)
je 0x544f4
movq -0x10(%rbp), %rdi
movl $0x1, %esi
callq 0x49390
movq %rax, -0x28(%rbp)
leaq 0x3ea59(%rip), %rdi     # 0x92f30
addq $0x18, %rdi
callq 0x3c9d0
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3cdc0
movb %al, -0x76(%rbp)
movb -0x76(%rbp), %al
movb %al, -0x75(%rbp)
movb -0x75(%rbp), %al
testb $0x1, %al
jne 0x54503
jmp 0x5450c
movb $0x0, -0x1(%rbp)
jmp 0x54684
movq -0x20(%rbp), %rax
movzwl (%rax), %ecx
andl $0x40, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x77(%rbp)
je 0x5454d
movq -0x10(%rbp), %rdi
callq 0x495b0
movq %rax, -0x38(%rbp)
leaq 0x3eabc(%rip), %rdi     # 0x92ff0
callq 0x3d190
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3d160
movb %al, -0x77(%rbp)
movb -0x77(%rbp), %al
testb $0x1, %al
jne 0x54559
jmp 0x54680
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x44(%rbp), %rdi
callq 0x60550
leaq 0x3d868(%rip), %rax     # 0x91dd8
movq (%rax), %rdi
leaq -0x44(%rbp), %rsi
callq 0x3d2d0
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
movzwl (%rax), %ecx
andl $0x2, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x78(%rbp)
jne 0x54636
movq -0x50(%rbp), %rax
movzwl (%rax), %ecx
andl $0x40, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x78(%rbp)
jne 0x54636
movq -0x50(%rbp), %rax
movzwl (%rax), %ecx
andl $0x1, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x78(%rbp)
je 0x54636
movq -0x50(%rbp), %rax
movsbl 0x2(%rax), %ecx
movb $0x1, %al
cmpl $0x5c, %ecx
movb %al, -0x78(%rbp)
je 0x54636
movq -0x50(%rbp), %rax
movzwl (%rax), %ecx
andl $0x20, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x79(%rbp)
je 0x54630
leaq -0x44(%rbp), %rdi
movl $0x5, %esi
callq 0x49390
movq %rax, -0x88(%rbp)
jmp 0x54601
movq -0x88(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq 0x3e91d(%rip), %rdi     # 0x92f30
addq $0x78, %rdi
callq 0x3c9d0
movq %rax, -0x70(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3cdc0
movb %al, -0x79(%rbp)
movb -0x79(%rbp), %al
movb %al, -0x78(%rbp)
movb -0x78(%rbp), %al
testb $0x1, %al
jne 0x5463f
jmp 0x54663
movb $0x0, -0x1(%rbp)
movl $0x1, -0x74(%rbp)
jmp 0x5466a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x44(%rbp), %rdi
callq 0x60460
jmp 0x54690
movl $0x0, -0x74(%rbp)
leaq -0x44(%rbp), %rdi
callq 0x60460
movl -0x74(%rbp), %eax
testl %eax, %eax
je 0x5467e
jmp 0x5467c
jmp 0x54684
jmp 0x54680
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x90, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x5920
nopl (%rax)