// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/iff.c
// Function: do_RGFX_RBOD
static void do_RGFX_RBOD(deark *c, struct rgfx_ctx *d, struct de_iffctx *ictx)
{
	int saved_indent_level;
	int bypp = 0;
	de_bitmap *img = NULL;

	de_dbg_indent_save(c, &saved_indent_level);

	if(d->found_RBOD) goto done;
	d->found_RBOD = 1;

	if(!de_good_image_dimensions(c, d->width, d->height)) goto done;

	if(d->rgfx_cmpr_meth==0) {
		d->unc_image = dbuf_open_input_subfile(ictx->f, ictx->chunkctx->dpos,
			ictx->chunkctx->dlen);
	}
	else {
		d->unc_image = dbuf_create_membuf(c, 0, 0);
		do_RGFX_decompress(c, d, ictx);
	}
	if(d->errflag) goto done;

	if(d->bitmaptype==RBMT_BYTECHUNKY8 && d->depth==8 && d->pixelbits==8 && d->found_RCOL) {
		bypp = 3;
	}
	else if(d->bitmaptype==RBMT_3BYTERGB24 && d->depth==24 && d->pixelbits==24) {
		bypp = 3;
	}

	if(bypp==0) {
		de_err(c, "Unsupported image type");
		goto done;
	}

	img = de_bitmap_create(c, d->width,  d->height, bypp);

	if(d->depth==8) {
		de_convert_image_paletted(d->unc_image, 0, 8, d->rowspan, d->pal, img, 0);
	}
	else if(d->depth==24) {
		de_convert_image_rgb(d->unc_image, 0, d->rowspan, 3, img, 0);
	}
	else {
		goto done;
	}

	de_bitmap_write_to_file(img, NULL, 0);

done:
	de_bitmap_destroy(img);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x15b580
movq -0x10(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0xae7ef
jmp 0xae9b6
movq -0x10(%rbp), %rax
movb $0x1, 0x4(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
callq 0x16a850
cmpl $0x0, %eax
jne 0xae81a
jmp 0xae9b6
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0xae85c
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x128(%rax), %rax
movq 0x40(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x128(%rax), %rax
movq 0x48(%rax), %rdx
callq 0x1691b0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0xae887
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x168020
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0xaed50
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0xae895
jmp 0xae9b6
movq -0x10(%rbp), %rax
cmpl $0x1, 0x20(%rax)
jne 0xae8cb
movq -0x10(%rbp), %rax
cmpq $0x8, 0x28(%rax)
jne 0xae8cb
movq -0x10(%rbp), %rax
cmpq $0x8, 0x30(%rax)
jne 0xae8cb
movq -0x10(%rbp), %rax
movzbl 0x3(%rax), %eax
cmpl $0x0, %eax
je 0xae8cb
movl $0x3, -0x20(%rbp)
jmp 0xae8f4
movq -0x10(%rbp), %rax
cmpl $0x2, 0x20(%rax)
jne 0xae8f2
movq -0x10(%rbp), %rax
cmpq $0x18, 0x28(%rax)
jne 0xae8f2
movq -0x10(%rbp), %rax
cmpq $0x18, 0x30(%rax)
jne 0xae8f2
movl $0x3, -0x20(%rbp)
jmp 0xae8f4
cmpl $0x0, -0x20(%rbp)
jne 0xae911
movq -0x8(%rbp), %rdi
leaq 0xf4bbb(%rip), %rsi     # 0x1a34c0
movb $0x0, %al
callq 0x15bfb0
jmp 0xae9b6
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdx
movl -0x20(%rbp), %ecx
callq 0x16b750
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x8, 0x28(%rax)
jne 0xae971
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %r8
addq $0x48, %r8
movq -0x28(%rbp), %r9
xorl %eax, %eax
movl %eax, %esi
movl $0x8, %edx
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x16c520
jmp 0xae9a7
movq -0x10(%rbp), %rax
cmpq $0x18, 0x28(%rax)
jne 0xae9a3
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdx
movq -0x28(%rbp), %r8
xorl %eax, %eax
movl %eax, %esi
movl $0x3, %ecx
xorl %r9d, %r9d
callq 0x16c8b0
jmp 0xae9a5
jmp 0xae9b6
jmp 0xae9a7
movq -0x28(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
xorl %edx, %edx
callq 0x16afd0
movq -0x28(%rbp), %rdi
callq 0x16af60
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x15b5a0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)