// File: /workspace/github_c_makefile_star2_O1/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 0x10(%rsp), %rsi
callq 0xe958c
testq %r13, %r13
je 0x610fe
leaq 0xc2712(%rip), %rsi     # 0x12352b
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef169
movq %rax, %rbp
leaq 0xc26fb(%rip), %rsi     # 0x123544
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
cmpl $0x101, %ebp            # imm = 0x101
je 0x60e91
cmpl $0x2800, %ebp           # imm = 0x2800
je 0x60e91
cmpl $0x424d, %ebp           # imm = 0x424D
jne 0x610ae
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
movq %r13, %rdx
movq %r14, %rcx
testb %r15b, %r15b
je 0x6111c
callq 0x6137d
jmp 0x610fe
movl %r12d, 0xc(%rsp)
movq %r14, 0x18(%rsp)
leaq 0x14(%rsp), %rsi
movq %rbx, %rdi
callq 0xe958c
movl $0x4b8, %esi            # imm = 0x4B8
movq %rbx, %rdi
callq 0xe969b
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 0xfa6e0
movq %r13, (%rsp)
cmpl $0x101, %ebp            # imm = 0x101
jne 0x60fab
leaq 0xc26aa(%rip), %rsi     # 0x123598
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq %rsp, %r14
addq $0x2, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef1ed
movq %rax, %rbp
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef1ed
movq %rax, 0xb0(%r12)
leaq 0xe1fef(%rip), %rsi     # 0x142f28
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0xb0(%r12), %rcx
cmpq $0x100, %rcx            # imm = 0x100
jg 0x610d5
testq %rcx, %rcx
jle 0x60f8f
movq 0x18(%rbx), %rsi
movq (%rsp), %rdx
leaq 0xb8(%r12), %r9
subq $0x8, %rsp
movl $0x3, %r8d
movq %rbx, %rdi
pushq $0x0
pushq $0x1
pushq $0x100                  # imm = 0x100
callq 0xf32f2
addq $0x20, %rsp
leaq 0x4(,%rbp), %rax
addq %r13, %rax
movq %rax, (%rsp)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq (%rsp), %rsi
movq %rsi, 0xa0(%r12)
movq 0x18(%rbx), %rdi
callq 0xef169
movq 0xa0(%r12), %rdx
cmpl $0x2800, %eax           # imm = 0x2800
jne 0x610c4
leaq 0xc25d3(%rip), %rsi     # 0x1235ad
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
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 0xf7881
movl %eax, %ebp
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
testl %ebp, %ebp
je 0x610d5
cmpq $0x28, 0x18(%r12)
jne 0x610d5
cmpq $0x100, 0x50(%r12)      # imm = 0x100
jg 0x610d5
cmpl $0x0, 0x98(%r12)
jne 0x610d5
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
movq %rbx, %rdi
callq 0xf241d
testl %eax, %eax
je 0x610d5
movq 0x30(%r12), %rax
cmpq $0x1, %rax
setne %cl
movl 0xc(%rsp), %esi
testl %esi, %esi
setle %dl
orb %cl, %dl
jne 0x61126
movq $0x2, 0xb0(%r12)
leaq 0xb8(%r12), %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0xf41f4
jmp 0x61165
leaq 0xc249b(%rip), %rsi     # 0x123550
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9df7
jmp 0x610fe
leaq 0xc2485(%rip), %rsi     # 0x123550
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
testq %r12, %r12
je 0x610f2
movq 0xa8(%r12), %rdi
callq 0xf0b13
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe9752
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movl 0x10(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r12d, %r8d
callq 0x61401
jmp 0x610fe
cmpq $0x2, %rax
setne %al
testl %esi, %esi
setne %cl
orb %al, %cl
jne 0x61165
cmpq $0x0, 0xb0(%r12)
jne 0x61165
movq 0x18(%rsp), %rax
movb $0x1, (%rax)
movq $0x4, 0xb0(%r12)
movaps 0xc21e4(%rip), %xmm0    # 0x123340
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 0xef3a0
movq %rax, %r14
leaq 0xb3fb4(%rip), %rsi     # 0x115143
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef3a0
movq %rax, %rbp
leaq 0xe9483(%rip), %rsi     # 0x14a635
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq (%r13), %r13
leaq 0xc4a7c(%rip), %rsi     # 0x125c46
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, %rax
addq %rbp, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0x610d5
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf0faf
movq %rax, 0xa8(%r12)
movq 0x18(%rbx), %rcx
leaq 0x30(%rsp), %rdx
movq %rcx, (%rdx)
movq %r13, 0x8(%rdx)
movq %rbp, 0x10(%rdx)
movq %r14, %rdi
leaq 0x50(%rsp), %r14
movq %rax, (%r14)
movq 0x68(%r12), %rsi
callq 0xea792
movq %rax, 0x10(%r14)
movb $0x1, 0x8(%r14)
leaq 0x20(%rsp), %r13
movl $0x1, (%r13)
leaq 0xc17c5(%rip), %rsi     # 0x122a0a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
leaq 0x68(%rsp), %rbp
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %r13, %r8
callq 0xffefb
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0xa8(%r12), %rdi
callq 0xf0ea4
cmpl $0x0, (%rbp)
je 0x612b6
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0xfa6a8
leaq 0xb3a04(%rip), %rsi     # 0x114caf
movq %rbx, %rdi
movq %rax, %rdx
jmp 0x610ce
movzbl %r15b, %r8d
movq %rbx, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x6161d
jmp 0x610d5