// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/drhalo.c
// Function: de_run_drhalocut
static void de_run_drhalocut(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 pos;
	dbuf *unc_pixels = NULL;
	const char *palfn;
	const char *tmps;

	d = de_malloc(c, sizeof(lctx));

	palfn = de_get_ext_option(c, "file2");
	if(palfn) {
		if(!do_read_pal_file(c, d, palfn)) goto done;
	}

	tmps = de_get_ext_option(c, "drhalocut:pal");
	if(tmps) {
		if(!de_strcmp(tmps, "pc16"))
			d->opt_pal_pc16 = 1;
	}

	pos = 0;
	if(!do_read_header(c, d)) goto done;
	pos += 6;

	unc_pixels = dbuf_create_membuf(c, d->w*d->h, 0x1);
	if(!do_decompress(c, d, pos, unc_pixels)) goto done;

	write_cut_image(c, d, unc_pixels);

done:
	dbuf_close(unc_pixels);
	de_free(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movl $0x478, %esi            # imm = 0x478
callq 0xdecaf
movq %rax, %r14
movq %rax, %r13
leaq 0xc4fdd(%rip), %rsi     # 0x10357c
movq %rbx, %rdi
callq 0xdfa87
testq %rax, %rax
je 0x3e5c2
movq %rbx, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x3f12e
testl %eax, %eax
je 0x3e7f6
leaq 0xcf033(%rip), %rsi     # 0x10d5fc
movq %rbx, %rdi
callq 0xdfa87
testq %rax, %rax
je 0x3e5ee
leaq 0xcf02d(%rip), %rsi     # 0x10d60a
movq %rax, %rdi
callq 0x181a0
testl %eax, %eax
jne 0x3e5ee
movb $0x1, 0x11(%r13)
movq 0x18(%rbx), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
callq 0xe3fa3
movq %rax, (%r13)
movq 0x18(%rbx), %rdi
pushq $0x2
popq %rsi
callq 0xe3fa3
movq %rax, 0x8(%r13)
movq (%r13), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xdf038
movq (%r13), %rsi
movq 0x8(%r13), %rdx
movq %rbx, %rdi
callq 0xe6be1
testl %eax, %eax
je 0x3e880
movq %r14, 0x18(%rsp)
movq 0x8(%r13), %rsi
imulq (%r13), %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0xe59cd
movq %rax, %r12
leaq 0x10(%rsp), %rax
movq $0x6, (%rax)
pushq $0x6
popq %rdx
leaq 0x8(%rsp), %rbp
xorl %r15d, %r15d
movq %r13, 0x20(%rsp)
cmpq 0x8(%r13), %r15
jge 0x3e77b
movq (%r13), %rsi
imulq %r15, %rsi
movq %r12, %rdi
callq 0xe5eb2
movq 0x10(%rsp), %rdx
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %rax
addq $-0x2, %rax
cmpq %rax, %rdx
jg 0x3e77b
movq %r15, 0x30(%rsp)
leaq 0x10(%rsp), %rsi
callq 0xe3fc4
movq %rax, %r13
movq 0x10(%rsp), %r15
movq %r15, 0x8(%rsp)
movq 0x18(%r12), %rax
movq %rax, 0x28(%rsp)
movq %r15, %r14
subq %r15, %r14
cmpq %r13, %r14
jge 0x3e738
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xe3f2a
movl %eax, %ecx
andb $0x7f, %cl
je 0x3e730
movq 0x18(%rbx), %rdi
testb %al, %al
js 0x3e70f
movzbl %al, %r14d
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0xe45f4
addq 0x8(%rsp), %r14
movq %r14, 0x8(%rsp)
jmp 0x3e6cc
movzbl %cl, %r14d
movq %rbp, %rsi
callq 0xe3f2a
movzbl %al, %esi
movq %r12, %rdi
movq %r14, %rdx
callq 0xe5e40
movq 0x8(%rsp), %r14
jmp 0x3e6cc
movq 0x8(%rsp), %r14
subq %r15, %r14
movq 0x18(%r12), %r9
subq 0x28(%rsp), %r9
movq %rbx, %rdi
leaq 0xcef93(%rip), %rsi     # 0x10d6df
movq 0x30(%rsp), %r15
movl %r15d, %edx
movq %r14, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0xdea83
movq 0x10(%rsp), %rdx
addq %r13, %rdx
movq %rdx, 0x10(%rsp)
incq %r15
movq 0x20(%rsp), %r13
jmp 0x3e66f
addq $-0x6, %rdx
movq 0x18(%r12), %rcx
leaq 0xcef30(%rip), %rsi     # 0x10d6bb
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
cmpb $0x0, 0x10(%r13)
jne 0x3e872
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
callq 0xdecaf
movq %rax, %r15
movb $0x0, 0x12(%r13)
andl $0x0, 0x14(%r13)
xorl %r14d, %r14d
movq 0x18(%rsp), %rbp
cmpq 0x18(%r12), %r14
jge 0x3e7fe
movq %r12, %rdi
movq %r14, %rsi
callq 0xe3eb4
cmpb 0x12(%r13), %al
jbe 0x3e7de
movb %al, 0x12(%r13)
movzbl %al, %eax
cmpb $0x0, (%r15,%rax)
jne 0x3e7f1
movb $0x1, (%r15,%rax)
incl 0x14(%r13)
incq %r14
jmp 0x3e7c2
xorl %r12d, %r12d
jmp 0x3e880
movzbl 0x12(%r13), %edx
leaq 0xcef16(%rip), %rsi     # 0x10d720
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
cmpb $0x0, 0x12(%r13)
jne 0x3e820
movb $0x1, 0x12(%r13)
movl 0x14(%r13), %edx
leaq 0xcef0a(%rip), %rsi     # 0x10d735
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movq %r15, %rsi
callq 0xded32
cmpb $0x0, 0x11(%r13)
setne %cl
movb 0x12(%r13), %al
cmpb $0x10, %al
setb %dl
andb %cl, %dl
addq $0x18, %rbp
cmpb $0x1, %dl
jne 0x3e8a2
pushq $0x14
popq %rdi
pushq $0x10
popq %r8
xorl %esi, %esi
xorl %edx, %edx
movq %rbp, %rcx
xorl %r9d, %r9d
callq 0xe1b11
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3f445
movq %r12, %rdi
callq 0xe5591
movq %rbx, %rdi
movq %r13, %rsi
callq 0xded32
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl %al, %esi
incq %rsi
movq %rbp, %rdi
xorl %edx, %edx
callq 0xe87a8
movq (%r13), %rsi
movq 0x8(%r13), %rdx
pushq $0x1
popq %rcx
movq %rbx, %rdi
callq 0xe7437
movq %rax, %r14
movq (%r13), %rcx
andl $0x0, (%rsp)
pushq $0x8
popq %rdx
movq %r12, %rdi
xorl %esi, %esi
movq %rbp, %r8
movq %rax, %r9
callq 0xe7cbc
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0xe70b7
movq %r14, %rdi
callq 0xe7084
jmp 0x3e880