// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/mbk.c
// Function: render_stos_pp1
static void render_stos_pp1(deark *c, struct pictbank_params *pb)
{
	i64 planesize;
	i64 lump;
	UI num_planes = 2;
	UI bits_per_pixel = 4;
	u8 xbuf[4];

	planesize = pb->width_in_bytes * pb->pseudoheight;

	for(lump=0; lump<pb->height_in_lumps; lump++) {
		i64 col_idx;
		i64 lump_start_srcpos_in_plane;
		i64 lump_start_ypos;
		i64 num_skipped_cols = 0;

		lump_start_srcpos_in_plane = pb->width_in_bytes * pb->lines_per_lump * lump;
		lump_start_ypos = pb->lines_per_lump * lump;

		for(col_idx=0; col_idx<pb->width_in_bytes; col_idx++) {
			i64 col_start_srcpos_in_plane;
			i64 ypos_in_lump;

			// Skip the last 2 of every group of 4 columns. They contain bits
			// associated with the first 2 columns.
			if((col_idx&2)!=0) {
				num_skipped_cols++;
				continue;
			}

			col_start_srcpos_in_plane = lump_start_srcpos_in_plane +
				pb->lines_per_lump*col_idx;

			for(ypos_in_lump=0; ypos_in_lump<pb->lines_per_lump; ypos_in_lump++) {
				UI i;
				UI pn;
				i64 xpos, ypos;

				ypos = lump_start_ypos + ypos_in_lump;

				for(pn=0; pn<num_planes; pn++) {
					xbuf[pn] = dbuf_getbyte(pb->unc_pixels, planesize*pn +
						col_start_srcpos_in_plane + ypos_in_lump);
					xbuf[pn+2] = dbuf_getbyte(pb->unc_pixels, planesize*pn +
						col_start_srcpos_in_plane + 2*pb->lines_per_lump + ypos_in_lump);
				}

				for(i=0; i<8; i++) {
					UI palent;

					palent = 0;
					for(pn=0; pn<bits_per_pixel; pn++) {
						if(xbuf[pn] & (1<<(7-i))) {
							palent |= (1<<pn);
						}
					}

					xpos = (col_idx-num_skipped_cols)*8 + i;
					de_bitmap_setpixel_rgb(pb->img, xpos, ypos, pb->pal[palent]);
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x2, -0x24(%rbp)
movl $0x4, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
imulq 0x28(%rcx), %rax
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jge 0xdd5ed
movq $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
imulq 0x20(%rcx), %rax
imulq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
imulq -0x20(%rbp), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jge 0xdd5da
movq -0x38(%rbp), %rax
andq $0x2, %rax
cmpq $0x0, %rax
je 0xdd44c
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xdd5c9
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x20(%rcx), %rcx
imulq -0x38(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jge 0xdd5c7
movq -0x48(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0xdd509
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x18(%rbp), %rsi
movl -0x68(%rbp), %eax
imulq %rax, %rsi
addq -0x58(%rbp), %rsi
addq -0x60(%rbp), %rsi
callq 0x165060
movb %al, %cl
movl -0x68(%rbp), %eax
movb %cl, -0x2c(%rbp,%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x18(%rbp), %rsi
movl -0x68(%rbp), %eax
imulq %rax, %rsi
addq -0x58(%rbp), %rsi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
shlq %rax
addq %rax, %rsi
addq -0x60(%rbp), %rsi
callq 0x165060
movb %al, %cl
movl -0x68(%rbp), %eax
addl $0x2, %eax
movl %eax, %eax
movb %cl, -0x2c(%rbp,%rax)
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xdd491
movl $0x0, -0x64(%rbp)
cmpl $0x8, -0x64(%rbp)
jae 0xdd5b4
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
cmpl -0x28(%rbp), %eax
jae 0xdd56d
movl -0x68(%rbp), %eax
movzbl -0x2c(%rbp,%rax), %eax
movl $0x7, %ecx
subl -0x64(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0xdd560
movl -0x68(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
orl -0x7c(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0xdd562
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xdd528
movq -0x38(%rbp), %rax
subq -0x50(%rbp), %rax
shlq $0x3, %rax
movl -0x64(%rbp), %ecx
addq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl -0x7c(%rbp), %ecx
movl (%rax,%rcx,4), %ecx
callq 0x16b310
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xdd510
jmp 0xdd5b6
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0xdd46c
jmp 0xdd5c9
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xdd41b
jmp 0xdd5dc
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0xdd3ce
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)