// File: /workspace/github_c_makefile_star2_O0/TurkeyMcMac[P]ts3d/src/d3d.c
// Function: draw_column
static void draw_column(
	d3d_camera *cam,
	d3d_vec_s cam_pos,
	d3d_scalar cam_facing,
	const d3d_board *board,
	size_t x)
{
	d3d_direction face;
	const d3d_block_s *block;
	const d3d_texture *drawing;
	d3d_vec_s pos = cam_pos, disp;
	d3d_scalar dist;
	d3d_scalar angle = cam_facing
		+ cam->fov.x * ((d3d_scalar)0.5 - (d3d_scalar)x / cam->width);
	d3d_vec_s dpos = {
		cos(angle) * (d3d_scalar)0.001, sin(angle) * (d3d_scalar)0.001
	};
	block = hit_wall(board, &pos, &dpos, &face, &drawing);
	if (!block) {
		block = &cam->blank_block;
		drawing = block->faces[0];
	}
	disp.x = pos.x - cam_pos.x;
	disp.y = pos.y - cam_pos.y;
	dist = hypot(disp.x, disp.y);
	cam->dists[x] = dist;
	// Choose how far across the wall to get pixels from based on the wall
	// orientation, and put the distance in dimension:
	d3d_scalar dimension;
	switch (face) {
	case D3D_DPOSX:
		dimension = revmod1(pos.y);
		break;
	case D3D_DPOSY:
		dimension = mod1(pos.x);
		break;
	case D3D_DNEGX:
		dimension = mod1(pos.y);
		break;
	case D3D_DNEGY:
	default: // The default case shouldn't be reached.
		dimension = revmod1(pos.x);
		break;
	}
	for (size_t t = 0; t < cam->height; ++t) {
		const d3d_texture *txtr;
		size_t tx, ty;
		// The distance the ray travelled, assuming it hit a vertical
		// wall:
		d3d_scalar dist_y = cam->tans[t] * dist + (d3d_scalar)0.5;
		if (dist_y > (d3d_scalar)0.0 && dist_y < (d3d_scalar)1.0) {
			// A vertical wall was indeed hit
			txtr = drawing;
			tx = dimension * txtr->width;
			ty = txtr->height * ((d3d_scalar)1.0 - dist_y);
		} else {
			// A floor or ceiling was hit instead. The horizontal
			// displacement is adjusted accordingly:
			d3d_scalar newdist =
				(d3d_scalar)0.5 / fabs(cam->tans[t]);
			d3d_vec_s newpos = {
				cam_pos.x + disp.x / dist * newdist,
				cam_pos.y + disp.y / dist * newdist
			};
			size_t bx = newpos.x, by = newpos.y;
			const d3d_block_s *const *top_bot =
				GET(board, blocks, bx, by);
			if (!top_bot) goto no_texture;
			// Ceiling hit if dist_y >= 1, floor hit if
			// dist_y <= 0, and nothing else is possible:
			d3d_direction face =
				dist_y >= (d3d_scalar)1.0 ? D3D_DUP : D3D_DDOWN;
			txtr = (*top_bot)->faces[face];
			if (!txtr) goto no_texture;
			tx = mod1(newpos.x) * txtr->width;
			ty = mod1(newpos.y) * txtr->height;
		}
		const d3d_pixel *tpp = GET(txtr, pixels, tx, ty);
		d3d_pixel tp;
		if (tpp) {
			tp = *tpp;
		} else {
	no_texture:
			tp = camera_empty_pixel(cam);
		}
		*GET(cam, pixels, x, t) = tp;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movsd %xmm0, -0x38(%rbp)
movsd %xmm1, -0x30(%rbp)
movq %rdi, -0x40(%rbp)
movsd %xmm2, -0x48(%rbp)
movq %rsi, -0x50(%rbp)
movq %rdx, -0x58(%rbp)
movups -0x38(%rbp), %xmm0
movaps %xmm0, -0x80(%rbp)
movsd -0x48(%rbp), %xmm1
movq -0x40(%rbp), %rax
movsd (%rax), %xmm0
movq -0x58(%rbp), %xmm3
movaps 0xdf49(%rip), %xmm5     # 0x11070
punpckldq %xmm5, %xmm3    # xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
movapd 0xdf4d(%rip), %xmm4     # 0x11080
subpd %xmm4, %xmm3
movaps %xmm3, %xmm2
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
addsd %xmm2, %xmm3
movq 0x10(%rax), %xmm2
punpckldq %xmm5, %xmm2    # xmm2 = xmm2[0],xmm5[0],xmm2[1],xmm5[1]
subpd %xmm4, %xmm2
movaps %xmm2, %xmm4
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm4, %xmm2
divsd %xmm2, %xmm3
movsd 0xdec2(%rip), %xmm2     # 0x11028
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x2190
movsd 0xde87(%rip), %xmm1     # 0x11020
mulsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
callq 0x2530
movsd 0xde5c(%rip), %xmm1     # 0x11020
mulsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x80(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
leaq -0x5c(%rbp), %rcx
leaq -0x70(%rbp), %r8
callq 0x3e10
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x320e
movq -0x40(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movsd -0x80(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x78(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
movsd -0x90(%rbp), %xmm1
movsd -0x88(%rbp), %xmm0
movsd %xmm1, -0x10(%rbp)
movsd %xmm0, -0x18(%rbp)
movsd -0x10(%rbp), %xmm0
movsd -0x18(%rbp), %xmm1
callq 0x21a0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movq -0x40(%rbp), %rax
movq 0x78(%rax), %rax
movq -0x58(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x5c(%rbp), %eax
movq %rax, -0x130(%rbp)
subq $0x3, %rax
ja 0x32e9
movq -0x130(%rbp), %rax
leaq 0xddfe(%rip), %rcx      # 0x110a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd -0x78(%rbp), %xmm0
callq 0x42d0
movsd %xmm0, -0xb8(%rbp)
jmp 0x32fb
movsd -0x80(%rbp), %xmm0
callq 0x4300
movsd %xmm0, -0xb8(%rbp)
jmp 0x32fb
movsd -0x78(%rbp), %xmm0
callq 0x4300
movsd %xmm0, -0xb8(%rbp)
jmp 0x32fb
jmp 0x32e9
movsd -0x80(%rbp), %xmm0
callq 0x42d0
movsd %xmm0, -0xb8(%rbp)
movq $0x0, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x382e
movq -0x40(%rbp), %rax
movq 0x70(%rax), %rax
movq -0xc0(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd -0x98(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0xdce5(%rip), %xmm1     # 0x11028
addsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0xe0(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x344c
movsd 0xdccc(%rip), %xmm0     # 0x11038
ucomisd -0xe0(%rbp), %xmm0
jbe 0x344c
movq -0x70(%rbp), %rax
movq %rax, -0xc8(%rbp)
movsd -0xb8(%rbp), %xmm0
movq -0xc8(%rbp), %rax
movq (%rax), %xmm1
movaps 0xdcd1(%rip), %xmm3     # 0x11070
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0xdcd5(%rip), %xmm2     # 0x11080
subpd %xmm2, %xmm1
movaps %xmm1, %xmm4
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm4, %xmm1
mulsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0xdc6b(%rip), %xmm1     # 0x11040
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %xmm0
punpckldq %xmm3, %xmm0    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
subpd %xmm2, %xmm0
movaps %xmm0, %xmm2
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm2, %xmm0
movsd -0xe0(%rbp), %xmm3
movsd 0xdc1e(%rip), %xmm2     # 0x11038
subsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
movaps %xmm0, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0xd8(%rbp)
jmp 0x3705
movq -0x40(%rbp), %rax
movq 0x70(%rax), %rax
movq -0xc0(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x8(%rbp)
movaps 0xdba4(%rip), %xmm0     # 0x11010
movsd -0x8(%rbp), %xmm1
pand %xmm0, %xmm1
movsd 0xdbab(%rip), %xmm0     # 0x11028
divsd %xmm1, %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0x38(%rbp), %xmm1
movsd -0x90(%rbp), %xmm0
movsd -0x98(%rbp), %xmm2
divsd %xmm2, %xmm0
movsd -0xe8(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0x30(%rbp), %xmm1
movsd -0x88(%rbp), %xmm0
movsd -0x98(%rbp), %xmm2
divsd %xmm2, %xmm0
movsd -0xe8(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xf0(%rbp)
movsd -0xf8(%rbp), %xmm0
movsd 0xdb45(%rip), %xmm2     # 0x11040
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rcx
cvttsd2si %xmm0, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x100(%rbp)
movsd -0xf0(%rbp), %xmm0
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rcx
cvttsd2si %xmm0, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0x100(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x35a0
movq -0x108(%rbp), %rax
movq -0x50(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x35a0
movq -0x50(%rbp), %rax
addq $0x10, %rax
movq -0x108(%rbp), %rcx
movq -0x50(%rbp), %rdx
movq 0x8(%rdx), %rdx
imulq -0x100(%rbp), %rdx
addq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x138(%rbp)
jmp 0x35ab
xorl %eax, %eax
movq %rax, -0x138(%rbp)
jmp 0x35ab
movq -0x138(%rbp), %rax
movq %rax, -0x110(%rbp)
cmpq $0x0, -0x110(%rbp)
jne 0x35c8
jmp 0x3796
movsd -0xe0(%rbp), %xmm0
movsd 0xda60(%rip), %xmm1     # 0x11038
movl $0x5, %eax
movl $0x4, %ecx
ucomisd %xmm1, %xmm0
cmovael %ecx, %eax
movl %eax, -0x114(%rbp)
movq -0x110(%rbp), %rax
movq (%rax), %rax
movl -0x114(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, -0xc8(%rbp)
jne 0x3619
jmp 0x3796
movsd -0xf8(%rbp), %xmm0
callq 0x4300
movq -0xc8(%rbp), %rax
movq (%rax), %xmm1
movaps 0xda38(%rip), %xmm2     # 0x11070
movaps %xmm2, -0x160(%rbp)
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0xda35(%rip), %xmm2     # 0x11080
movaps %xmm2, -0x150(%rbp)
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0xd9c4(%rip), %xmm1     # 0x11040
movsd %xmm1, -0x140(%rbp)
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0xd0(%rbp)
movsd -0xf0(%rbp), %xmm0
callq 0x4300
movaps -0x160(%rbp), %xmm4
movaps -0x150(%rbp), %xmm3
movsd -0x140(%rbp), %xmm1
movq -0xc8(%rbp), %rax
movq 0x8(%rax), %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
movaps %xmm0, %xmm2
cvttsd2si %xmm2, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rax
movq -0xc8(%rbp), %rcx
cmpq (%rcx), %rax
jae 0x3760
movq -0xd8(%rbp), %rax
movq -0xc8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jae 0x3760
movq -0xc8(%rbp), %rax
addq $0x10, %rax
movq -0xd8(%rbp), %rcx
movq -0xc8(%rbp), %rdx
movq 0x8(%rdx), %rdx
imulq -0xd0(%rbp), %rdx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x168(%rbp)
jmp 0x376b
xorl %eax, %eax
movq %rax, -0x168(%rbp)
jmp 0x376b
movq -0x168(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, -0x120(%rbp)
je 0x3794
movq -0x120(%rbp), %rax
movb (%rax), %al
movb %al, -0x121(%rbp)
jmp 0x37a5
jmp 0x3796
movq -0x40(%rbp), %rdi
callq 0x3df0
movb %al, -0x121(%rbp)
movb -0x121(%rbp), %al
movb %al, -0x169(%rbp)
movq -0x58(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jae 0x37fd
movq -0xc0(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x37fd
movq -0x40(%rbp), %rax
addq $0x80, %rax
movq -0xc0(%rbp), %rcx
movq -0x40(%rbp), %rdx
movq 0x18(%rdx), %rdx
imulq -0x58(%rbp), %rdx
addq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x178(%rbp)
jmp 0x3808
xorl %eax, %eax
movq %rax, -0x178(%rbp)
jmp 0x3808
movb -0x169(%rbp), %cl
movq -0x178(%rbp), %rax
movb %cl, (%rax)
movq -0xc0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc0(%rbp)
jmp 0x3306
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw (%rax,%rax)