// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/build.c
// Function: adjustmark
int adjustmark(int *xplc, int *yplc, short danumwalls)
{
	int i, dst, dist, dax, day, pointlockdist;

	if (danumwalls < 0)
		danumwalls = numwalls;

	pointlockdist = 0;
	if ((grid > 0) && (gridlock > 0))
		pointlockdist = (128>>grid);

	dist = pointlockdist;
	dax = *xplc;
	day = *yplc;
	for(i=0;i<danumwalls;i++)
	{
		dst = klabs((*xplc)-wall[i].x) + klabs((*yplc)-wall[i].y);
		if (dst < dist)
		{
			dist = dst;
			dax = wall[i].x;
			day = wall[i].y;
		}
	}
	if (dist == pointlockdist)
		if ((gridlock > 0) && (grid > 0))
		{
			dax = ((dax+(1024>>grid))&(0xffffffff<<(11-grid)));
			day = ((day+(1024>>grid))&(0xffffffff<<(11-grid)));
		}

	*xplc = dax;
	*yplc = day;
	return(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %dx, %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
movswl -0x12(%rbp), %eax
cmpl $0x0, %eax
jge 0x25b7e
leaq 0x42be51(%rip), %rax    # 0x4519c8
movw (%rax), %ax
movw %ax, -0x12(%rbp)
movl $0x0, -0x2c(%rbp)
movswl 0xba410(%rip), %eax     # 0xdff9c
cmpl $0x0, %eax
jle 0x25bae
movswl 0xba406(%rip), %eax     # 0xdff9e
cmpl $0x0, %eax
jle 0x25bae
movswl 0xba3f8(%rip), %ecx     # 0xdff9c
movl $0x80, %eax
sarl %cl, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movswl -0x12(%rbp), %ecx
cmpl %ecx, %eax
jge 0x25c75
movq -0x8(%rbp), %rax
movl (%rax), %edi
movslq -0x18(%rbp), %rcx
leaq 0x1cf9c3(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
subl (%rax), %edi
callq 0x2b7f0
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %edi
movslq -0x18(%rbp), %rcx
leaq 0x1cf9a1(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
subl 0x4(%rax), %edi
callq 0x2b7f0
movl %eax, %ecx
movl -0x30(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x25c65
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x1cf96f(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movslq -0x18(%rbp), %rcx
leaq 0x1cf958(%rip), %rax    # 0x1f55b0
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
jmp 0x25c67
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x25bcd
movl -0x20(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x25cf9
movswl 0xba31a(%rip), %eax     # 0xdff9e
cmpl $0x0, %eax
jle 0x25cf7
movswl 0xba30c(%rip), %eax     # 0xdff9c
cmpl $0x0, %eax
jle 0x25cf7
movl -0x24(%rbp), %eax
movswl 0xba2fd(%rip), %ecx     # 0xdff9c
movl $0x400, %edx            # imm = 0x400
sarl %cl, %edx
movl %edx, %ecx
addl %ecx, %eax
movswl 0xba2eb(%rip), %edx     # 0xdff9c
movl $0xb, %ecx
subl %edx, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
movswl 0xba2cc(%rip), %ecx     # 0xdff9c
movl $0x400, %edx            # imm = 0x400
sarl %cl, %edx
movl %edx, %ecx
addl %ecx, %eax
movswl 0xba2ba(%rip), %edx     # 0xdff9c
movl $0xb, %ecx
subl %edx, %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
movl %eax, -0x28(%rbp)
jmp 0x25cf9
movl -0x24(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movl -0x28(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
xorl %eax, %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)