// File: /workspace/github_c_makefile_star2_O3/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 0xe8b2b
movq %rax, %r14
movq %rax, %r12
leaq 0xd0325(%rip), %rsi     # 0x11057c
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0x4027a
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x40eac
testl %eax, %eax
je 0x40447
leaq 0xda46b(%rip), %rsi     # 0x11a6ec
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0x402a7
leaq 0xda465(%rip), %rsi     # 0x11a6fa
movq %rax, %rdi
callq 0x181a0
testl %eax, %eax
jne 0x402a7
movb $0x1, 0x11(%r12)
movq 0x18(%rbx), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
callq 0xeebc8
movq %rax, (%r12)
movq 0x18(%rbx), %rdi
movl $0x2, %esi
callq 0xeebc8
movq %rax, 0x8(%r12)
movq (%r12), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xe8f88
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %rbx, %rdi
callq 0xf1db1
testl %eax, %eax
je 0x405eb
movq %r14, 0x28(%rsp)
movq 0x8(%r12), %rsi
imulq (%r12), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0xf09c5
movq %rax, %r14
movq $0x6, 0x18(%rsp)
cmpq $0x0, 0x8(%r12)
jle 0x4044f
xorl %r15d, %r15d
movq %r12, 0x30(%rsp)
movq (%r12), %rsi
imulq %r15, %rsi
movq %r14, %rdi
callq 0xf0f27
movq 0x18(%rsp), %r13
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %rax
addq $-0x2, %rax
cmpq %rax, %r13
jg 0x40441
leaq 0x18(%rsp), %rsi
callq 0xeebeb
movq %rax, %r13
movq 0x18(%rsp), %r12
movq %r12, 0x10(%rsp)
movq %r14, %rbp
movq 0x18(%r14), %rax
movq %rax, %r9
movq %r12, %r14
testq %r13, %r13
jle 0x40401
movq %rax, 0x20(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0xeeb4b
movl %eax, %ecx
andb $0x7f, %cl
je 0x403f3
movq 0x18(%rbx), %rdi
testb %al, %al
js 0x403c5
movzbl %al, %r14d
movq 0x10(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0xef481
addq 0x10(%rsp), %r14
movq %r14, 0x10(%rsp)
jmp 0x403e6
movzbl %cl, %r14d
leaq 0x10(%rsp), %rsi
callq 0xeeb4b
movzbl %al, %esi
movq %rbp, %rdi
movq %r14, %rdx
callq 0xf0eba
movq 0x10(%rsp), %r14
movq %r14, %rax
subq %r12, %rax
cmpq %r13, %rax
jl 0x40388
jmp 0x403f8
movq 0x10(%rsp), %r14
movq 0x18(%rbp), %r9
movq 0x20(%rsp), %rax
subq %r12, %r14
subq %rax, %r9
movq %rbx, %rdi
leaq 0xda3be(%rip), %rsi     # 0x11a7cf
movl %r15d, %edx
movq %r14, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0xe889f
addq 0x18(%rsp), %r13
movq %r13, 0x18(%rsp)
incq %r15
movq 0x30(%rsp), %r12
cmpq 0x8(%r12), %r15
movq %rbp, %r14
jl 0x40330
addq $-0x6, %r13
jmp 0x40452
xorl %r15d, %r15d
jmp 0x405eb
xorl %r13d, %r13d
movq 0x18(%r14), %rcx
leaq 0xda34e(%rip), %rsi     # 0x11a7ab
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0x10(%r12)
je 0x4048a
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x411de
movq %r14, %r15
jmp 0x405eb
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
callq 0xe8b2b
movq %rax, %r15
movb $0x0, 0x12(%r12)
movl $0x0, 0x14(%r12)
movq %r14, 0x20(%rsp)
cmpq $0x0, 0x18(%r14)
movq 0x28(%rsp), %r13
jle 0x404fc
xorl %r14d, %r14d
movq 0x20(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0xeead3
cmpb 0x12(%r12), %al
jbe 0x404d9
movb %al, 0x12(%r12)
movzbl %al, %eax
cmpb $0x0, (%r15,%rax)
jne 0x404ed
movb $0x1, (%r15,%rax)
incl 0x14(%r12)
incq %r14
cmpq 0x18(%rbp), %r14
jl 0x404c2
movzbl 0x12(%r12), %ebp
leaq 0xda30d(%rip), %rsi     # 0x11a810
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0x12(%r12)
jne 0x4051d
movb $0x1, 0x12(%r12)
movl 0x14(%r12), %edx
leaq 0xda2fc(%rip), %rsi     # 0x11a825
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe8be2
cmpb $0x0, 0x11(%r12)
setne %cl
movb 0x12(%r12), %al
cmpb $0x10, %al
setb %dl
andb %cl, %dl
addq $0x18, %r13
cmpb $0x1, %dl
movq 0x20(%rsp), %r15
jne 0x4058b
movl $0x10, %r8d
movl $0x14, %edi
xorl %esi, %esi
xorl %edx, %edx
movq %r13, %rcx
xorl %r9d, %r9d
callq 0xec55a
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x411de
jmp 0x405eb
movzbl %al, %esi
incq %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0xf3bdb
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0xf266a
movq %rax, %r14
movq (%r12), %rcx
movl $0x0, (%rsp)
movl $0x8, %edx
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %r8
movq %rax, %r9
callq 0xf2f79
movq %r14, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xf22dc
movq %r14, %rdi
callq 0xf228d
movq %r15, %rdi
callq 0xf052b
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe8be2
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq