// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/qtif.c
// Function: do_write_image
static void do_write_image(deark *c, lctx *d)
{
	i64 dsize;

	if(!d->idsc_found) {
		if(!d->fail_gracefully_mode)
			de_err(c, "Missing idsc atom");
		return;
	}

	dsize = (d->idat_data_size>0) ? d->idat_data_size : d->idat_size;
	if(dsize<=0) return;

	if(!de_memcmp(d->cmpr4cc.bytes, "raw ", 4)) {
		do_decode_raw(c, d);
	}
	else if(!de_memcmp(d->cmpr4cc.bytes, "jpeg", 4)) {
		dbuf_create_file_from_slice(c->infile, d->idat_pos, dsize, "jpg", NULL, 0);
		d->decoded_ok = 1;
	}
	else if(!de_memcmp(d->cmpr4cc.bytes, "tiff", 4)) {
		dbuf_create_file_from_slice(c->infile, d->idat_pos, dsize, "tif", NULL, 0);
		d->decoded_ok = 1;
	}
	else if(!de_memcmp(d->cmpr4cc.bytes, "gif ", 4)) {
		dbuf_create_file_from_slice(c->infile, d->idat_pos, dsize, "gif", NULL, 0);
		d->decoded_ok = 1;
	}
	else if(!de_memcmp(d->cmpr4cc.bytes, "png ", 4)) {
		dbuf_create_file_from_slice(c->infile, d->idat_pos, dsize, "png", NULL, 0);
		d->decoded_ok = 1;
	}
	else if(!de_memcmp(d->cmpr4cc.bytes, "kpcd", 4)) { // Kodak Photo CD
		dbuf_create_file_from_slice(c->infile, d->idat_pos, dsize, "pcd", NULL, 0);
		d->decoded_ok = 1;
	}
	else {
		if(d->fail_gracefully_mode) {
			de_dbg(c, "Unsupported compression type: \"%s\"", d->cmpr4cc.id_sanitized_sz);
		}
		else {
			de_err(c, "Unsupported compression type: \"%s\"", d->cmpr4cc.id_sanitized_sz);
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x0, 0x18(%rsi)
je 0xc1888
movq 0x28(%rbx), %rdx
testq %rdx, %rdx
jg 0xc180e
movq 0x10(%rbx), %rdx
testq %rdx, %rdx
jle 0xc1a69
cmpl $0x20776172, 0x30(%rbx) # imm = 0x20776172
je 0xc18b0
cmpl $0x6765706a, 0x30(%rbx) # imm = 0x6765706A
je 0xc18d2
cmpl $0x66666974, 0x30(%rbx) # imm = 0x66666974
je 0xc1907
cmpl $0x20666967, 0x30(%rbx) # imm = 0x20666967
je 0xc191b
cmpl $0x20676e70, 0x30(%rbx) # imm = 0x20676E70
je 0xc1a3a
cmpl $0x6463706b, 0x30(%rbx) # imm = 0x6463706B
je 0xc1a4b
leaq 0x38(%rbx), %rdx
cmpb $0x0, (%rbx)
je 0xc1a78
leaq 0x78b33(%rip), %rsi     # 0x13a3a3
movq %r14, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe8617
cmpb $0x0, (%rbx)
jne 0xc1a69
leaq 0x78ae5(%rip), %rsi     # 0x13a37d
movq %r14, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9295
movq 0x70(%rbx), %rdx
movb (%rbx), %al
cmpq $0x20, %rdx
jne 0xc18e6
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
movq %r14, %rdi
testb %al, %al
je 0xc192f
callq 0xf1d84
jmp 0xc1934
movq 0x18(%r14), %rdi
movq 0x8(%rbx), %rsi
leaq 0x71fd1(%rip), %rcx     # 0x1338b2
jmp 0xc1a5a
testb %al, %al
jne 0xc1a13
leaq 0x78ad1(%rip), %rsi     # 0x13a3c6
xorl %r15d, %r15d
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0xc1a16
movq 0x18(%r14), %rdi
movq 0x8(%rbx), %rsi
leaq 0x88b51(%rip), %rcx     # 0x14a467
jmp 0xc1a5a
movq 0x18(%r14), %rdi
movq 0x8(%rbx), %rsi
leaq 0x5e1ce(%rip), %rcx     # 0x11faf8
jmp 0xc1a5a
callq 0xf1db1
testl %eax, %eax
je 0xc1a13
movq 0x60(%rbx), %rsi
movq 0x68(%rbx), %rdx
movq %r14, %rdi
movl $0x3, %ecx
callq 0xf266a
movq %rax, %r12
movq %r14, %rdi
callq 0xea504
movl $0x2, 0x78(%rax)
movups 0x80(%rbx), %xmm0
movq %rax, (%rsp)
movups %xmm0, 0x80(%rax)
movq 0x28(%rbx), %rax
movq 0x60(%rbx), %rcx
leaq (,%rcx,4), %rdi
movq 0x68(%rbx), %rsi
cqto
idivq %rsi
cmpq %rdi, %rax
cmovgq %rax, %rdi
movq %rdi, 0x8(%rsp)
testq %rsi, %rsi
jle 0xc19fc
movl $0x1, %r15d
xorl %r13d, %r13d
testq %rcx, %rcx
jle 0xc19ef
movq %r15, 0x10(%rsp)
xorl %ebp, %ebp
movq 0x18(%r14), %rdi
movq 0x8(%rbx), %rsi
addq %r15, %rsi
xorl %edx, %edx
callq 0xef42f
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movl %eax, %ecx
callq 0xf24ba
incq %rbp
movq 0x60(%rbx), %rcx
addq $0x4, %r15
cmpq %rcx, %rbp
jl 0xc19b4
movq 0x68(%rbx), %rsi
movq 0x10(%rsp), %r15
incq %r13
addq 0x8(%rsp), %r15
cmpq %rsi, %r13
jl 0xc19a8
movq %r12, %rdi
movq (%rsp), %r15
movq %r15, %rsi
xorl %edx, %edx
callq 0xf22d0
movb $0x1, 0x1(%rbx)
jmp 0xc1a19
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %r12, %rdi
callq 0xf228d
movq %r14, %rdi
movq %r15, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xea50e
movq 0x18(%r14), %rdi
movq 0x8(%rbx), %rsi
leaq 0x66ce7(%rip), %rcx     # 0x128730
jmp 0xc1a5a
movq 0x18(%r14), %rdi
movq 0x8(%rbx), %rsi
leaq 0x78945(%rip), %rcx     # 0x13a39f
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xefd48
movb $0x1, 0x1(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x78924(%rip), %rsi     # 0x13a3a3
movq %r14, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xe9295