// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/ilbm.c
// Function: deep_decode_image_unc
static void deep_decode_image_unc(deark *c, struct deep_ctx *d,
	dbuf *f, i64 pos1, i64 len)
{
	i64 i, j;
	i64 pos = pos1;
	UI k;
	UI dst_samples_per_pixel;
	de_bitmap *img = NULL;
	de_finfo *fi = NULL;
	u8 s[5] = {0,0,0,0,0};

	fi = de_finfo_create(c);
	if(d->x_aspect && d->y_aspect) {
		fi->density.code = DE_DENSITY_UNK_UNITS;
		fi->density.ydens = (double)d->x_aspect;
		fi->density.xdens = (double)d->y_aspect;
	}

	dst_samples_per_pixel = d->have_alpha ? 4 : 3;
	img = de_bitmap_create(c, d->width, d->height, dst_samples_per_pixel);

	for(j=0; j<d->height; j++) {
		for(i=0; i<d->width; i++) {
			de_color clr;

			if(pos > pos1+len) {
				de_warn(c, "Premature end of image");
				goto after_image;
			}

			for(k=0; k<(UI)d->num_components; k++) {
				s[d->sample_map[k]] =  dbuf_getbyte_p(f, &pos);
			}
			if(d->have_alpha) {
				clr = DE_MAKE_RGBA(s[0], s[1], s[2], s[3]);
				if(d->is_assoc_alpha) {
					clr = de_unpremultiply_alpha_clr(clr);
				}
			}
			else {
				clr = DE_MAKE_RGB(s[0], s[1], s[2]);
			}
			de_bitmap_setpixel_rgba(img, i, j, clr);
		}
	}

after_image:
	if(d->trans_setting==TRANS_AUTO) {
		de_bitmap_optimize_alpha(img, (0x4|0x02));
	}
	else if(d->trans_setting==TRANS_REMOVE) {
		de_bitmap_remove_alpha(img);
	}
	de_bitmap_write_to_file_finfo(img, fi, DE_CREATEFLAG_OPT_IMAGE);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x5d(%rbp), %rdi
xorl %esi, %esi
movl $0x5, %edx
callq 0x19140
movq -0x8(%rbp), %rdi
callq 0x15d230
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0xb6e2e
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0xb6e2e
movq -0x58(%rbp), %rax
movl $0x1, 0x78(%rax)
movq -0x10(%rbp), %rax
cvtsi2sdq 0x30(%rax), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0x88(%rax)
movq -0x10(%rbp), %rax
cvtsi2sdq 0x38(%rax), %xmm0
movq -0x58(%rbp), %rax
movsd %xmm0, 0x80(%rax)
movq -0x10(%rbp), %rax
movzbl 0x50(%rax), %edx
movl $0x3, %eax
movl $0x4, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdx
movl -0x48(%rbp), %ecx
callq 0x16b750
movq %rax, -0x50(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x28(%rcx), %rax
jge 0xb6fa0
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jge 0xb6f8d
movq -0x40(%rbp), %rax
movq -0x20(%rbp), %rcx
addq -0x28(%rbp), %rcx
cmpq %rcx, %rax
jle 0xb6ec5
movq -0x8(%rbp), %rdi
leaq 0xfe2a2(%rip), %rsi     # 0x1b515b
movb $0x0, %al
callq 0x15bc10
jmp 0xb6fa2
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
cmpl %ecx, %eax
jae 0xb6f07
movq -0x18(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x165170
movb %al, %cl
movq -0x10(%rbp), %rax
movl -0x44(%rbp), %edx
movl 0x94(%rax,%rdx,4), %eax
movb %cl, -0x5d(%rbp,%rax)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xb6ecc
movq -0x10(%rbp), %rax
cmpb $0x0, 0x50(%rax)
je 0xb6f4a
movzbl -0x5a(%rbp), %eax
shll $0x18, %eax
movzbl -0x5d(%rbp), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movzbl -0x5c(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movzbl -0x5b(%rbp), %ecx
orl %ecx, %eax
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x52(%rax)
je 0xb6f48
movl -0x64(%rbp), %edi
callq 0x16d6c0
movl %eax, -0x64(%rbp)
jmp 0xb6f68
movzbl -0x5d(%rbp), %eax
shll $0x10, %eax
orl $0xff000000, %eax       # imm = 0xFF000000
movzbl -0x5c(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movzbl -0x5b(%rbp), %ecx
orl %ecx, %eax
movl %eax, -0x64(%rbp)
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl -0x64(%rbp), %ecx
callq 0x16b350
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0xb6e8b
jmp 0xb6f8f
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xb6e71
jmp 0xb6fa2
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x2, %eax
jne 0xb6fbf
movq -0x50(%rbp), %rdi
movl $0x6, %esi
callq 0x16d190
jmp 0xb6fd7
movq -0x10(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0xb6fd5
movq -0x50(%rbp), %rdi
callq 0x16d070
jmp 0xb6fd7
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl $0x2, %edx
callq 0x16afa0
movq -0x50(%rbp), %rdi
callq 0x16af60
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0x15d260
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)