// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdi, %rbx
movl $0x478, %esi            # imm = 0x478
callq 0xe969b
movq %rax, %r15
leaq 0xd02b8(%rip), %rsi     # 0x110590
movq %rbx, %rdi
callq 0xea6cb
testq %rax, %rax
je 0x402fb
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x40eda
testl %eax, %eax
je 0x404ce
leaq 0xda2ca(%rip), %rsi     # 0x11a5cc
movq %rbx, %rdi
callq 0xea6cb
testq %rax, %rax
je 0x40327
leaq 0xda2c4(%rip), %rsi     # 0x11a5da
movq %rax, %rdi
callq 0x181a0
testl %eax, %eax
jne 0x40327
movb $0x1, 0x11(%r15)
movq 0x18(%rbx), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
callq 0xef1ca
movq %rax, (%r15)
movq 0x18(%rbx), %rdi
movl $0x2, %esi
callq 0xef1ca
movq %rax, 0x8(%r15)
movq (%r15), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0xe9b05
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0xf241d
testl %eax, %eax
je 0x40606
movq 0x8(%r15), %rsi
imulq (%r15), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0xf0faf
movq %rax, %rbp
movq $0x6, 0x10(%rsp)
cmpq $0x0, 0x8(%r15)
jle 0x40496
xorl %r12d, %r12d
movq %r15, 0x18(%rsp)
movq (%r15), %rsi
imulq %r12, %rsi
movq %rbp, %rdi
callq 0xf152a
movq 0x18(%rbx), %rdi
movq 0x18(%rdi), %rax
addq $-0x2, %rax
cmpq %rax, 0x10(%rsp)
jg 0x40496
leaq 0x10(%rsp), %rsi
callq 0xef1ed
movq %rbp, %rcx
movq %rax, %rbp
movq 0x10(%rsp), %r15
movq %r15, 0x8(%rsp)
movq %rcx, %r13
movq 0x18(%rcx), %rax
movq %rax, 0x20(%rsp)
testq %rbp, %rbp
jle 0x40454
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0xef14d
movl %eax, %ecx
andb $0x7f, %cl
je 0x40454
movq 0x18(%rbx), %rdi
testb %al, %al
js 0x4042b
movzbl %al, %r14d
movq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %r13, %rcx
callq 0xefabc
addq %r14, 0x8(%rsp)
jmp 0x40447
movzbl %cl, %r14d
leaq 0x8(%rsp), %rsi
callq 0xef14d
movzbl %al, %esi
movq %r13, %rdi
movq %r14, %rdx
callq 0xf14bd
movq 0x8(%rsp), %rax
subq %r15, %rax
cmpq %rbp, %rax
jl 0x403f3
movq 0x8(%rsp), %rcx
subq %r15, %rcx
movq 0x18(%r13), %r9
subq 0x20(%rsp), %r9
movq %rbx, %rdi
leaq 0xda240(%rip), %rsi     # 0x11a6af
movl %r12d, %edx
movq %rbp, %r8
xorl %eax, %eax
callq 0xe9461
addq %rbp, 0x10(%rsp)
movq %r13, %rbp
incq %r12
movq 0x18(%rsp), %r15
cmpq 0x8(%r15), %r12
jl 0x403a2
movq 0x10(%rsp), %rdx
addq $-0x6, %rdx
movq 0x18(%rbp), %rcx
leaq 0xda1e1(%rip), %rsi     # 0x11a68b
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0x10(%r15)
je 0x404d5
movq %rbx, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x4120c
jmp 0x40606
xorl %ebp, %ebp
jmp 0x40606
movl $0x100, %esi            # imm = 0x100
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r12
movb $0x0, 0x12(%r15)
movl $0x0, 0x14(%r15)
cmpq $0x0, 0x18(%rbp)
jle 0x4052d
xorl %r13d, %r13d
movq %rbp, %rdi
movq %r13, %rsi
callq 0xef0d5
cmpb 0x12(%r15), %al
jbe 0x40511
movb %al, 0x12(%r15)
movzbl %al, %eax
cmpb $0x0, (%r12,%rax)
jne 0x40524
movb $0x1, (%r12,%rax)
incl 0x14(%r15)
incq %r13
cmpq 0x18(%rbp), %r13
jl 0x404fc
movzbl 0x12(%r15), %edx
leaq 0xda1b7(%rip), %rsi     # 0x11a6f0
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0x12(%r15)
jne 0x4054f
movb $0x1, 0x12(%r15)
movl 0x14(%r15), %edx
leaq 0xda1ab(%rip), %rsi     # 0x11a705
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe9752
cmpb $0x0, 0x11(%r15)
je 0x405a0
cmpb $0xf, 0x12(%r15)
ja 0x405a0
movq %r15, %rcx
addq $0x18, %rcx
movl $0x10, %r8d
movl $0x14, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %r9d, %r9d
callq 0xecbbc
jmp 0x404bb
movq %r15, %r12
addq $0x18, %r12
movzbl 0x12(%r15), %esi
incq %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0xf41f4
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
movl $0x1, %ecx
callq 0xf2cab
movq %rax, %r14
movq (%r15), %rcx
movl $0x0, (%rsp)
movl $0x8, %edx
movq %rbp, %rdi
xorl %esi, %esi
movq %r12, %r8
movq %rax, %r9
callq 0xf35b8
movq %r14, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0xf2923
movq %r14, %rdi
callq 0xf28d4
movq %rbp, %rdi
callq 0xf0b13
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe9752
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq