// File: /workspace/github_c_makefile_star2_O3/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 0xe8a1c
testq %r13, %r13
je 0x60fb9
leaq 0xc2a37(%rip), %rsi     # 0x12370b
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeeb67
movq %rax, %rbp
leaq 0xc2a20(%rip), %rsi     # 0x123724
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
cmpl $0x101, %ebp            # imm = 0x101
je 0x60d4c
cmpl $0x2800, %ebp           # imm = 0x2800
je 0x60d4c
cmpl $0x424d, %ebp           # imm = 0x424D
jne 0x60f6e
movq 0x18(%rbx), %rsi
movq %rbx, %rdi
movq %r13, %rdx
movq %r14, %rcx
testb %r15b, %r15b
je 0x60fd7
callq 0x6123a
jmp 0x60fb9
movl %r12d, 0xc(%rsp)
movq %r14, 0x18(%rsp)
leaq 0x14(%rsp), %rsi
movq %rbx, %rdi
callq 0xe8a1c
movl $0x4b8, %esi            # imm = 0x4B8
movq %rbx, %rdi
callq 0xe8b2b
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 0xfa1dc
movq %r13, (%rsp)
cmpl $0x101, %ebp            # imm = 0x101
jne 0x60e6a
leaq 0xc29cf(%rip), %rsi     # 0x123778
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %rsp, %r14
addq $0x2, (%r14)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeebeb
movq %rax, %rbp
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeebeb
movq %rax, 0xb0(%r12)
leaq 0xe2614(%rip), %rsi     # 0x143408
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0xb0(%r12), %rcx
cmpq $0x100, %rcx            # imm = 0x100
jg 0x60f95
testq %rcx, %rcx
jle 0x60e4a
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 0xf2cb1
addq $0x20, %rsp
leaq 0x4(,%rbp), %rax
addq %r13, %rax
movq %rax, (%rsp)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq (%rsp), %r13
movq %r13, 0xa0(%r12)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeeb67
movq 0xa0(%r12), %rdx
cmpl $0x2800, %eax           # imm = 0x2800
jne 0x60f84
leaq 0xc28f5(%rip), %rsi     # 0x12378d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
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 0xf7425
movl %eax, %ebp
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
testl %ebp, %ebp
je 0x60f95
cmpq $0x28, 0x18(%r12)
jne 0x60f95
cmpq $0x100, 0x50(%r12)      # imm = 0x100
jg 0x60f95
cmpl $0x0, 0x98(%r12)
jne 0x60f95
movq 0x20(%r12), %rsi
movq 0x28(%r12), %rdx
movq %rbx, %rdi
callq 0xf1db1
testl %eax, %eax
je 0x60f95
movq 0x30(%r12), %rax
cmpq $0x1, %rax
setne %cl
movl 0xc(%rsp), %esi
testl %esi, %esi
setle %dl
orb %cl, %dl
jne 0x60fe1
movq $0x2, 0xb0(%r12)
movq %r12, %rdi
addq $0xb8, %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0xf3bdb
jmp 0x61020
leaq 0xc27bb(%rip), %rsi     # 0x123730
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9295
jmp 0x60fb9
leaq 0xc27a5(%rip), %rsi     # 0x123730
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq 0xa8(%r12), %rdi
callq 0xf052b
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe8be2
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movl 0x10(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r12d, %r8d
callq 0x612be
jmp 0x60fb9
cmpq $0x2, %rax
setne %al
testl %esi, %esi
setne %cl
orb %al, %cl
jne 0x61020
cmpq $0x0, 0xb0(%r12)
jne 0x61020
movq 0x18(%rsp), %rax
movb $0x1, (%rax)
movq $0x4, 0xb0(%r12)
movaps 0xc2509(%rip), %xmm0    # 0x123520
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 0xeed83
movq %rax, %r14
leaq 0xb41a9(%rip), %rsi     # 0x1151f3
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed83
movq %rax, %rbp
leaq 0xe9b78(%rip), %rsi     # 0x14abe5
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq (%r13), %r13
leaq 0xc4df1(%rip), %rsi     # 0x125e76
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r13, %rax
addq %rbp, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0x60f95
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf09c5
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 0xe9c3b
movq %rax, 0x10(%r14)
movb $0x1, 0x8(%r14)
leaq 0x20(%rsp), %r13
movl $0x1, (%r13)
leaq 0xc1b12(%rip), %rsi     # 0x122c12
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
leaq 0x68(%rsp), %rbp
movq %rbx, %rdi
leaq 0x30(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
movq %r13, %r8
callq 0xff757
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0xa8(%r12), %rdi
callq 0xf08ba
cmpl $0x0, (%rbp)
je 0x61171
leaq 0x68(%rsp), %rsi
movq %rbx, %rdi
callq 0xfa1a4
leaq 0xb3bf9(%rip), %rsi     # 0x114d5f
movq %rbx, %rdi
movq %rax, %rdx
jmp 0x60f8e
movzbl %r15b, %r8d
movq %rbx, %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
movl 0xc(%rsp), %ecx
callq 0x614c5
jmp 0x60f95