// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/abk.c
// Function: render_to_bitmap_ham6
static void render_to_bitmap_ham6(dbuf *f, const de_color *pal, de_bitmap *img)
{
	i64 ypos;
	i64 xpos;
	const UI pixshift1 = 4;
	i64 ipos = 0;

	for(ypos=0; ypos<img->height; ypos++) {
		u8 cr, cg, cb;

		cr = DE_COLOR_R(pal[0]) >> pixshift1;
		cg = DE_COLOR_G(pal[0]) >> pixshift1;
		cb = DE_COLOR_B(pal[0]) >> pixshift1;

		for(xpos=0; xpos<img->width; xpos++) {
			u8 pixval;
			u8 pixval_code;
			u8 pixval_color;
			u8 cr2, cg2, cb2;
			de_color clr;

			pixval = dbuf_getbyte_p(f, &ipos);
			pixval_code = pixval >> 4;
			pixval_color = pixval & 0x0f;

			switch(pixval_code) {
			case 0x1: // Modify blue value
				cb = pixval_color;
				break;
			case 0x2: // Modify red value
				cr = pixval_color;
				break;
			case 0x3: // Modify green value
				cg = pixval_color;
				break;
			default: // 0: Use colormap value
				clr = pal[(UI)pixval_color];
				cr = DE_COLOR_R(clr) >> pixshift1;
				cg = DE_COLOR_G(clr) >> pixshift1;
				cb = DE_COLOR_B(clr) >> pixshift1;
				break;
			}

			cr2 = (cr<<4) | cr;
			cg2 = (cg<<4) | cg;
			cb2 = (cb<<4) | cb;
			de_bitmap_setpixel_rgba(img, xpos, ypos, DE_MAKE_RGB(cr2, cg2, cb2));
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x4, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0x1c9af
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x10, %eax
andl $0xff, %eax
movzbl %al, %eax
sarl $0x4, %eax
movb %al, -0x39(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
shrl $0x8, %eax
andl $0xff, %eax
movzbl %al, %eax
sarl $0x4, %eax
movb %al, -0x3a(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
movzbl %al, %eax
sarl $0x4, %eax
movb %al, -0x3b(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x1c99c
movq -0x8(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x165170
movb %al, -0x3c(%rbp)
movzbl -0x3c(%rbp), %eax
shrl $0x4, %eax
movb %al, -0x3d(%rbp)
movb -0x3c(%rbp), %al
andb $0xf, %al
movb %al, -0x3e(%rbp)
movzbl -0x3d(%rbp), %eax
movl %eax, -0x4c(%rbp)
subl $0x1, %eax
je 0x1c8cd
jmp 0x1c8b9
movl -0x4c(%rbp), %eax
subl $0x2, %eax
je 0x1c8d5
jmp 0x1c8c3
movl -0x4c(%rbp), %eax
subl $0x3, %eax
je 0x1c8dd
jmp 0x1c8e5
movb -0x3e(%rbp), %al
movb %al, -0x3b(%rbp)
jmp 0x1c92e
movb -0x3e(%rbp), %al
movb %al, -0x39(%rbp)
jmp 0x1c92e
movb -0x3e(%rbp), %al
movb %al, -0x3a(%rbp)
jmp 0x1c92e
movq -0x10(%rbp), %rax
movzbl -0x3e(%rbp), %ecx
movl %ecx, %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
shrl $0x10, %eax
andl $0xff, %eax
movzbl %al, %eax
sarl $0x4, %eax
movb %al, -0x39(%rbp)
movl -0x48(%rbp), %eax
shrl $0x8, %eax
andl $0xff, %eax
movzbl %al, %eax
sarl $0x4, %eax
movb %al, -0x3a(%rbp)
movl -0x48(%rbp), %eax
andl $0xff, %eax
movzbl %al, %eax
sarl $0x4, %eax
movb %al, -0x3b(%rbp)
movzbl -0x39(%rbp), %eax
shll $0x4, %eax
movzbl -0x39(%rbp), %ecx
orl %ecx, %eax
movb %al, -0x3f(%rbp)
movzbl -0x3a(%rbp), %eax
shll $0x4, %eax
movzbl -0x3a(%rbp), %ecx
orl %ecx, %eax
movb %al, -0x40(%rbp)
movzbl -0x3b(%rbp), %eax
shll $0x4, %eax
movzbl -0x3b(%rbp), %ecx
orl %ecx, %eax
movb %al, -0x41(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
movzbl -0x3f(%rbp), %ecx
shll $0x10, %ecx
orl $0xff000000, %ecx       # imm = 0xFF000000
movzbl -0x40(%rbp), %eax
shll $0x8, %eax
orl %eax, %ecx
movzbl -0x41(%rbp), %eax
orl %eax, %ecx
callq 0x16b350
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x1c877
jmp 0x1c99e
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1c81b
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)