// File: /workspace/github_c_makefile_star2_O0/TurkeyMcMac[P]ts3d/src/map.c
// Function: map_check_walls
void map_check_walls(struct map *map, d3d_vec_s *pos, d3d_scalar radius)
{
	/* Yes, I know this code repeats itself a lot. */
	// Tile coordinates:
	long x = floor(pos->x), y = floor(pos->y);
	// xs (east, west) and ys (south, north) of 8 tiles around (x, y):
	long west, south, east, north;
	west = floor(pos->x - radius);
	south = floor(pos->y - radius);
	east = floor(pos->x + radius);
	north = floor(pos->y + radius);
	// The wall bits here at (x, y):
	uint8_t here = get_wall_ck(map, x, y);
	if (south < y) {
		// Correct the south side and maybe east/west.
		bool south_corrected = bitat(here, D3D_DNEGY);
		d3d_scalar south_dist = pos->y - floor(pos->y);
		if (south_corrected) pos->y = y + radius;
		if (west < x) {
			// Correct the west.
			if (bitat(here, D3D_DNEGX)) {
				pos->x = x + radius;
			} else if (!south_corrected) {
				// Detect southwest corner collision.
				uint8_t nw = get_wall_ck(map, west, south);
				bool hit_outer_corner = bitat(nw, D3D_DPOSY)
					|| bitat(nw, D3D_DPOSX);
				if (hit_outer_corner) {
					d3d_scalar west_dist = pos->x
						- floor(pos->x);
					// Do correction needing less movement.
					if (south_dist > west_dist) {
						pos->y = y + radius;
					} else {
						pos->x = x + radius;
					}
				}
			}
		} else if (east > x) {
			// Correct the east.
			if (bitat(here, D3D_DPOSX)) {
				pos->x = x + 1.0 - radius;
			} else if (!south_corrected) {
				// Detect southeast corner collision.
				uint8_t ne = get_wall_ck(map, east, south);
				bool hit_outer_corner = bitat(ne, D3D_DPOSY)
					|| bitat(ne, D3D_DNEGX);
				if (hit_outer_corner) {
					// Do correction needing less movement.
					d3d_scalar east_dist = ceil(pos->x)
						- pos->x;
					if (south_dist > east_dist) {
						pos->y = y + radius;
					} else {
						pos->x = x + 1.0 - radius;
					}
				}
			}
		}
	} else if (north > y) {
		// Correct the north side and maybe east/west.
		bool north_corrected = bitat(here, D3D_DPOSY);
		d3d_scalar north_dist = ceil(pos->y) - pos->y;
		if (north_corrected) pos->y = y + 1.0 - radius;
		if (west < x) {
			// Correct the west.
			if (bitat(here, D3D_DNEGX)) {
				pos->x = x + radius;
			} else if (!north_corrected) {
				// Detect northwest corner collision.
				uint8_t sw = get_wall_ck(map, west, north);
				bool hit_outer_corner = bitat(sw, D3D_DNEGY)
					|| bitat(sw, D3D_DPOSX);
				if (hit_outer_corner) {
					d3d_scalar west_dist = pos->x
						- floor(pos->x);
					// Do correction needing less movement.
					if (north_dist > west_dist) {
						pos->y = y + 1.0 - radius;
					} else {
						pos->x = x + radius;
					}
				}
			}
		} else if (east > x) {
			// Correct the east.
			if (bitat(here, D3D_DPOSX)) {
				pos->x = x + 1.0 - radius;
			} else if (!north_corrected) {
				// Detect northeast corner collision.
				uint8_t se = get_wall_ck(map, east, north);
				bool hit_outer_corner = bitat(se, D3D_DNEGY)
					|| bitat(se, D3D_DNEGX);
				if (hit_outer_corner) {
					d3d_scalar east_dist = ceil(pos->x)
						- pos->x;
					if (north_dist > east_dist) {
						pos->y = y + 1.0 - radius;
					} else {
						pos->x = x + 1.0 - radius;
					}
				}
			}
		}
	} else if (west < x) {
		// Correct only the west side.
		if (bitat(here, D3D_DNEGX)) pos->x = x + radius;
	} else if (east > x) {
		// Correct only the east side.
		if (bitat(here, D3D_DPOSX)) pos->x = x + 1.0 - radius;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x68(%rbp)
movq %rsi, -0x70(%rbp)
movsd %xmm0, -0x78(%rbp)
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x2490
cvttsd2si %xmm0, %rax
movq %rax, -0x80(%rbp)
movq -0x70(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x2490
cvttsd2si %xmm0, %rax
movq %rax, -0x88(%rbp)
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
subsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x2490
cvttsd2si %xmm0, %rax
movq %rax, -0x90(%rbp)
movq -0x70(%rbp), %rax
movsd 0x8(%rax), %xmm0
subsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x2490
cvttsd2si %xmm0, %rax
movq %rax, -0x98(%rbp)
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
callq 0x2490
cvttsd2si %xmm0, %rax
movq %rax, -0xa0(%rbp)
movq -0x70(%rbp), %rax
movsd 0x8(%rax), %xmm0
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x2490
cvttsd2si %xmm0, %rax
movq %rax, -0xa8(%rbp)
movq -0x68(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0xb580
movb %al, -0xa9(%rbp)
movq -0x98(%rbp), %rax
cmpq -0x88(%rbp), %rax
jge 0xb1e6
movzbl -0xa9(%rbp), %eax
sarl $0x3, %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0xaa(%rbp)
movq -0x70(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x110(%rbp)
movq -0x70(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
callq 0x2490
movaps %xmm0, %xmm1
movsd -0x110(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
testb $0x1, -0xaa(%rbp)
je 0xaf77
cvtsi2sdq -0x88(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x90(%rbp), %rax
cmpq -0x80(%rbp), %rax
jge 0xb0ac
movzbl -0xa9(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xafb2
cvtsi2sdq -0x80(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb0a7
testb $0x1, -0xaa(%rbp)
jne 0xb0a5
movq -0x68(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0x98(%rbp), %rdx
callq 0xb580
movb %al, -0xb9(%rbp)
movzbl -0xb9(%rbp), %ecx
sarl %ecx
andl $0x1, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x111(%rbp)
jne 0xb00e
movzbl -0xb9(%rbp), %eax
sarl $0x0, %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x111(%rbp)
movb -0x111(%rbp), %al
andb $0x1, %al
movb %al, -0xba(%rbp)
testb $0x1, -0xba(%rbp)
je 0xb0a3
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x120(%rbp)
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
callq 0x2490
movaps %xmm0, %xmm1
movsd -0x120(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xc8(%rbp)
movsd -0xb8(%rbp), %xmm0
ucomisd -0xc8(%rbp), %xmm0
jbe 0xb08e
cvtsi2sdq -0x88(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0xb0a1
cvtsi2sdq -0x80(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb0a3
jmp 0xb0a5
jmp 0xb0a7
jmp 0xb1e1
movq -0xa0(%rbp), %rax
cmpq -0x80(%rbp), %rax
jle 0xb1df
movzbl -0xa9(%rbp), %eax
sarl $0x0, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xb0f3
cvtsi2sdq -0x80(%rbp), %xmm0
movsd 0x5f5b(%rip), %xmm1     # 0x11038
addsd %xmm1, %xmm0
subsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb1dd
testb $0x1, -0xaa(%rbp)
jne 0xb1db
movq -0x68(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
callq 0xb580
movb %al, -0xc9(%rbp)
movzbl -0xc9(%rbp), %ecx
sarl %ecx
andl $0x1, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x121(%rbp)
jne 0xb14f
movzbl -0xc9(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x121(%rbp)
movb -0x121(%rbp), %al
andb $0x1, %al
movb %al, -0xca(%rbp)
testb $0x1, -0xca(%rbp)
je 0xb1d9
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
callq 0x20b0
movq -0x70(%rbp), %rax
subsd (%rax), %xmm0
movsd %xmm0, -0xd8(%rbp)
movsd -0xb8(%rbp), %xmm0
ucomisd -0xd8(%rbp), %xmm0
jbe 0xb1b8
cvtsi2sdq -0x88(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0xb1d7
cvtsi2sdq -0x80(%rbp), %xmm0
movsd 0x5e72(%rip), %xmm1     # 0x11038
addsd %xmm1, %xmm0
subsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb1d9
jmp 0xb1db
jmp 0xb1dd
jmp 0xb1df
jmp 0xb1e1
jmp 0xb56d
movq -0xa8(%rbp), %rax
cmpq -0x88(%rbp), %rax
jle 0xb4f3
movzbl -0xa9(%rbp), %eax
sarl %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, -0xd9(%rbp)
movq -0x70(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x10(%rbp)
movsd -0x10(%rbp), %xmm0
callq 0x20b0
movq -0x70(%rbp), %rax
subsd 0x8(%rax), %xmm0
movsd %xmm0, -0xe8(%rbp)
testb $0x1, -0xd9(%rbp)
je 0xb269
cvtsi2sdq -0x88(%rbp), %xmm0
movsd 0x5de1(%rip), %xmm1     # 0x11038
addsd %xmm1, %xmm0
subsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x90(%rbp), %rax
cmpq -0x80(%rbp), %rax
jge 0xb3af
movzbl -0xa9(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xb2a4
cvtsi2sdq -0x80(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb3aa
testb $0x1, -0xd9(%rbp)
jne 0xb3a8
movq -0x68(%rbp), %rdi
movq -0x90(%rbp), %rsi
movq -0xa8(%rbp), %rdx
callq 0xb580
movb %al, -0xe9(%rbp)
movzbl -0xe9(%rbp), %ecx
sarl $0x3, %ecx
andl $0x1, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x122(%rbp)
jne 0xb301
movzbl -0xe9(%rbp), %eax
sarl $0x0, %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x122(%rbp)
movb -0x122(%rbp), %al
andb $0x1, %al
movb %al, -0xea(%rbp)
testb $0x1, -0xea(%rbp)
je 0xb3a6
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x130(%rbp)
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
callq 0x2490
movaps %xmm0, %xmm1
movsd -0x130(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0xe8(%rbp), %xmm0
ucomisd -0xf8(%rbp), %xmm0
jbe 0xb391
cvtsi2sdq -0x88(%rbp), %xmm0
movsd 0x5cbb(%rip), %xmm1     # 0x11038
addsd %xmm1, %xmm0
subsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0xb3a4
cvtsi2sdq -0x80(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb3a6
jmp 0xb3a8
jmp 0xb3aa
jmp 0xb4f1
movq -0xa0(%rbp), %rax
cmpq -0x80(%rbp), %rax
jle 0xb4ef
movzbl -0xa9(%rbp), %eax
sarl $0x0, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xb3f6
cvtsi2sdq -0x80(%rbp), %xmm0
movsd 0x5c58(%rip), %xmm1     # 0x11038
addsd %xmm1, %xmm0
subsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb4ed
testb $0x1, -0xd9(%rbp)
jne 0xb4eb
movq -0x68(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
callq 0xb580
movb %al, -0xf9(%rbp)
movzbl -0xf9(%rbp), %ecx
sarl $0x3, %ecx
andl $0x1, %ecx
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x131(%rbp)
jne 0xb453
movzbl -0xf9(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x131(%rbp)
movb -0x131(%rbp), %al
andb $0x1, %al
movb %al, -0xfa(%rbp)
testb $0x1, -0xfa(%rbp)
je 0xb4e9
movq -0x70(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
callq 0x20b0
movq -0x70(%rbp), %rax
subsd (%rax), %xmm0
movsd %xmm0, -0x108(%rbp)
movsd -0xe8(%rbp), %xmm0
ucomisd -0x108(%rbp), %xmm0
jbe 0xb4c8
cvtsi2sdq -0x88(%rbp), %xmm0
movsd 0x5b84(%rip), %xmm1     # 0x11038
addsd %xmm1, %xmm0
subsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0xb4e7
cvtsi2sdq -0x80(%rbp), %xmm0
movsd 0x5b62(%rip), %xmm1     # 0x11038
addsd %xmm1, %xmm0
subsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb4e9
jmp 0xb4eb
jmp 0xb4ed
jmp 0xb4ef
jmp 0xb4f1
jmp 0xb56b
movq -0x90(%rbp), %rax
cmpq -0x80(%rbp), %rax
jge 0xb527
movzbl -0xa9(%rbp), %eax
sarl $0x2, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xb525
cvtsi2sdq -0x80(%rbp), %xmm0
addsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb569
movq -0xa0(%rbp), %rax
cmpq -0x80(%rbp), %rax
jle 0xb567
movzbl -0xa9(%rbp), %eax
sarl $0x0, %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xb565
cvtsi2sdq -0x80(%rbp), %xmm0
movsd 0x5ae4(%rip), %xmm1     # 0x11038
addsd %xmm1, %xmm0
subsd -0x78(%rbp), %xmm0
movq -0x70(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0xb567
jmp 0xb569
jmp 0xb56b
jmp 0xb56d
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw %cs:(%rax,%rax)