// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/comicchat.c
// Function: read_image_lowlevel
static void read_image_lowlevel(deark *c, lctx *d, i64 pos1,
	struct image_highlevel_ctx *ih, int itype, u8 direct_to_bmp)
{
	UI magic;
	int saved_indent_level;
	de_dbg_indent_save(c, &saved_indent_level);

	if(pos1==0) goto done;

	de_dbg(c, "[image component at %"I64_FMT"]", pos1);
	de_dbg_indent(c, 1);

	magic = (UI)de_getu16be(pos1);
	de_dbg(c, "sig: 0x%04x", magic);
	if(magic!=0x0101 && magic!=0x2800 && magic!=0x424d) {
		de_err(c, "Image not found at %"I64_FMT, pos1);
		goto done;
	}

	if(magic==0x424d) {
		if(direct_to_bmp) {
			extract_whole_bmp(c, d, c->infile, pos1, ih);
		}
		else {
			read_bmp_to_img(c, d, c->infile, pos1, ih, itype);
		}
	}
	else {
		read_dib_to_img(c, d, pos1, magic, ih, itype, direct_to_bmp);
	}

done:
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movl %r8d, %r15d
movl %ecx, %r12d
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %rbx
leaq 0x18(%rsp), %rsi
callq 0xdebae
testq %r13, %r13
je 0x5dc0f
leaq 0xb8c11(%rip), %rsi     # 0x11654b
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f46
movq %rax, %rbp
leaq 0xb8bfc(%rip), %rsi     # 0x116564
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xde896
cmpl $0x101, %ebp            # imm = 0x101
je 0x5d9b0
cmpl $0x2800, %ebp           # imm = 0x2800
je 0x5d9b0
cmpl $0x424d, %ebp           # imm = 0x424D
jne 0x5dbc4
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
movq %r13, %rdx
movq %r14, %rcx
testb %r15b, %r15b
je 0x5dc2d
callq 0x5df57
jmp 0x5dc0f
movl %r12d, 0xc(%rsp)
movq %r14, 0x10(%rsp)
leaq 0x1c(%rsp), %rsi
movq %rbx, %rdi
callq 0xdebae
movl $0x4b8, %esi            # imm = 0x4B8
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0x30(%rsp), %rsi
leaq 0x50(%rsp), %rdx
leaq 0x68(%rsp), %rcx
movq %rbx, %rdi
callq 0xee7ee
movq %r13, (%rsp)
cmpl $0x101, %ebp            # imm = 0x101
jne 0x5dac8
leaq 0xb8bab(%rip), %rsi     # 0x1165b8
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq %rsp, %r14
addq $0x2, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3fc4
movq %rax, %rbp
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xe3fc4
movq %rax, 0xb0(%r12)
leaq 0xd8562(%rip), %rsi     # 0x135fb8
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0xb0(%r12), %rcx
cmpq $0x100, %rcx            # imm = 0x100
jg 0x5dbeb
testq %rcx, %rcx
jle 0x5daaa
movq 0x18(%rbx), %rsi
movq (%rsp), %rdx
leaq 0xb8(%r12), %r9
subq $0x8, %rsp
pushq $0x3
popq %r8
movq %rbx, %rdi
pushq $0x0
pushq $0x1
pushq $0x100                  # imm = 0x100
callq 0xe79ca
addq $0x20, %rsp
leaq 0x4(,%rbp), %rax
addq %r13, %rax
movq %rax, (%rsp)
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq (%rsp), %r13
movq %r13, 0xa0(%r12)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f46
movq 0xa0(%r12), %rdx
cmpl $0x2800, %eax           # imm = 0x2800
jne 0x5dbda
leaq 0xb8ad7(%rip), %rsi     # 0x1165cd
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0x18(%rbx), %rsi
movq 0xa0(%r12), %rcx
movq 0x18(%rsi), %r8
subq %rcx, %r8
movq %rbx, %rdi
movq %r12, %rdx
xorl %r9d, %r9d
callq 0xebba5
movl %eax, %ebp
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
testl %ebp, %ebp
je 0x5dbeb
cmpq $0x28, 0x18(%r12)
jne 0x5dbeb
cmpq $0x100, 0x50(%r12)      # imm = 0x100
jg 0x5dbeb
cmpl $0x0, 0x98(%r12)
jne 0x5dbeb
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
movq %rbx, %rdi
callq 0xe6be1
testl %eax, %eax
je 0x5dbeb
movq 0x30(%r12), %rax
cmpq $0x1, %rax
setne %cl
movl 0xc(%rsp), %esi
testl %esi, %esi
setle %dl
orb %cl, %dl
jne 0x5dc37
movq $0x2, 0xb0(%r12)
movq %r12, %rdi
addq $0xb8, %rdi
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0xe87a8
jmp 0x5dc76
leaq 0xb89a5(%rip), %rsi     # 0x116570
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xdf2a5
jmp 0x5dc0f
leaq 0xb898f(%rip), %rsi     # 0x116570
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq 0xa8(%r12), %rdi
callq 0xe5591
movq %rbx, %rdi
movq %r12, %rsi
callq 0xded32
movl 0x1c(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movl 0x18(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r12d, %r8d
callq 0x5dfdb
jmp 0x5dc0f
cmpq $0x2, %rax
setne %al
testl %esi, %esi
setne %cl
orb %al, %cl
jne 0x5dc76
cmpq $0x0, 0xb0(%r12)
jne 0x5dc76
movq 0x10(%rsp), %rax
movb $0x1, (%rax)
movq $0x4, 0xb0(%r12)
movaps 0xb86f3(%rip), %xmm0    # 0x116360
movups %xmm0, 0xb8(%r12)
movq 0x18(%r12), %rax
addq 0xa0(%r12), %rax
movq %rsp, %r13
movq %rax, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe40bf
movq %rax, %r14
leaq 0xaa4c7(%rip), %rsi     # 0x108167
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe40bf
movq %rax, %rbp
leaq 0xdfa52(%rip), %rsi     # 0x13d715
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq (%r13), %r13
leaq 0xbaf9b(%rip), %rsi     # 0x118c76
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
movq %r13, %rax
addq %rbp, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0x5dbeb
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe59cd
movq %rax, 0xa8(%r12)
movq 0x18(%rbx), %rcx
leaq 0x30(%rsp), %rdx
movq %rcx, (%rdx)
movq %r13, 0x8(%rdx)
movq %rbp, 0x10(%rdx)
leaq 0x50(%rsp), %rbp
movq %rax, (%rbp)
movq 0x68(%r12), %rsi
movq %r14, %rdi
callq 0xdfb45
movq %rax, 0x10(%rbp)
movb $0x1, 0x8(%rbp)
leaq 0x20(%rsp), %r14
movl $0x1, (%r14)
leaq 0xb7cfd(%rip), %rsi     # 0x115a52
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
leaq 0x68(%rsp), %r13
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movq %rbp, %rdx
movq %r13, %rcx
movq %r14, %r8
callq 0xf38de
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
movq 0xa8(%r12), %rdi
callq 0xe58e8
cmpl $0x0, (%r13)
je 0x5ddc3
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0xee7bc
leaq 0xa9f47(%rip), %rsi     # 0x107cff
movq %rbx, %rdi
movq %rax, %rdx
jmp 0x5dbe4
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe59cd
movq %rax, %r13
movq %rbx, %rdi
movq %rax, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0xec053
movq 0x18(%rbx), %rdi
movq 0x18(%r12), %rdx
movq 0xa0(%r12), %rsi
movq %r13, %rcx
callq 0xe45f4
movq 0x50(%r12), %rbp
testq %rbp, %rbp
cmovleq %r14, %rbp
cmpq %r14, %rbp
je 0x5de51
movzbl 0xb8(%r12,%r14,4), %esi
movq %r13, %rdi
callq 0xe5bc5
movzbl 0xb9(%r12,%r14,4), %esi
movq %r13, %rdi
callq 0xe5bc5
movzbl 0xba(%r12,%r14,4), %esi
movq %r13, %rdi
callq 0xe5bc5
movq %r13, %rdi
xorl %esi, %esi
callq 0xe5bc5
incq %r14
jmp 0x5de0a
movq 0xa8(%r12), %rdi
movq 0x18(%rdi), %rdx
xorl %esi, %esi
movq %r13, %rcx
callq 0xe45f4
movq %r13, %rdi
callq 0xe58e8
movq %rbx, %rdi
movq %r13, %rsi
xorl %edx, %edx
testb %r15b, %r15b
je 0x5de88
movq 0x10(%rsp), %rcx
callq 0x5df57
jmp 0x5de97
movq 0x10(%rsp), %rcx
movl 0xc(%rsp), %r8d
callq 0x5dfdb
movq %r13, %rdi
callq 0xe5591
jmp 0x5dbeb