// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/macrsrc.c
// Function: do_SICN_resource_gallery
static void do_SICN_resource_gallery(deark *c, lctx *d, struct rsrctypeinfo *rti,
	struct rsrcinstanceinfo *rii, i64 pos1, i64 numicons)
{
#define SICN_PER_ROW 16
	de_finfo *fi = NULL;
	i64 ncols, nrows;
	i64 canvas_w, canvas_h;
	de_bitmap *cnv = NULL;
	i64 i;

	fi = de_finfo_create(c);
	set_resource_filename(c, d, fi, rti, rii, "SICN_gallery");

	ncols = (numicons<SICN_PER_ROW) ? numicons : SICN_PER_ROW;
	nrows = (numicons+SICN_PER_ROW-1) / SICN_PER_ROW;
	canvas_w = 1 + ncols*17;
	canvas_h = 1 + nrows*17;

	cnv = de_bitmap_create(c, canvas_w, canvas_h, 3);
	de_bitmap_rect(cnv, 0, 0, cnv->width, cnv->height, DE_MAKE_RGB(32,32,144), 0);

	for(i=0; i<numicons; i++) {
		de_bitmap *img = NULL;

		img = de_bitmap_create(c, 16, 16, 1);
		de_convert_image_bilevel(c->infile, pos1+32*i, 2, img, DE_CVTF_WHITEISZERO);
		de_bitmap_copy_rect(img, cnv, 0, 0, 16, 16,
			1 + 17*(i%SICN_PER_ROW), 1 + 17*(i/SICN_PER_ROW), 0);
		de_bitmap_destroy(img);
	}

	de_bitmap_write_to_file_finfo(cnv, fi, 0);

	de_bitmap_destroy(cnv);
	de_finfo_destroy(c, fi);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %r8
leaq 0xe6330(%rip), %r9      # 0x1bab5b
callq 0xd46c0
cmpq $0x10, -0x30(%rbp)
jge 0xd4841
movq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0xd484c
movl $0x10, %eax
movq %rax, -0x78(%rbp)
jmp 0xd484c
movq -0x78(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
addq $0x10, %rax
subq $0x1, %rax
movl $0x10, %ecx
cqto
idivq %rcx
movq %rax, -0x48(%rbp)
imulq $0x11, -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
imulq $0x11, -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdx
movl $0x3, %ecx
callq 0x16b750
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x60(%rbp), %rax
movq 0x10(%rax), %r8
xorl %eax, %eax
movl %eax, %edx
movl $0xff202090, %r9d       # imm = 0xFF202090
xorl %eax, %eax
movq %rdx, %rsi
movl $0x0, (%rsp)
callq 0x16cdc0
movq $0x0, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0xd49a8
movq $0x0, -0x70(%rbp)
movq -0x8(%rbp), %rdi
movl $0x10, %edx
movl $0x1, %ecx
movq %rdx, %rsi
callq 0x16b750
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x68(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
movq -0x70(%rbp), %rcx
movl $0x2, %edx
movl $0x1, %r8d
callq 0x16bee0
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rax
movl $0x10, %ecx
cqto
idivq %rcx
imulq $0x11, %rdx, %r10
addq $0x1, %r10
movq -0x68(%rbp), %rax
movl $0x10, %ecx
cqto
idivq %rcx
imulq $0x11, %rax, %rax
addq $0x1, %rax
xorl %ecx, %ecx
movl $0x10, %r9d
xorl %edx, %edx
movq %rcx, %rdx
movq %r9, %r8
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x16ce50
movq -0x70(%rbp), %rdi
callq 0x16af60
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0xd48d9
movq -0x60(%rbp), %rdi
movq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x16afa0
movq -0x60(%rbp), %rdi
callq 0x16af60
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x15d260
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)