// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/packit.c
// Function: de_run_packit
static void de_run_packit(deark *c, de_module_params *mparams)
{
	struct packit_ctx *d = NULL;
	struct packit_md *pmd = NULL;
	i64 pos = 0;
	u32 code;

	d = de_malloc(c, sizeof(struct packit_ctx));
	d->crco_datarsrc = de_crcobj_create(c, DE_CRCOBJ_CRC16_XMODEM);
	d->crco_hdr = de_crcobj_create(c, DE_CRCOBJ_CRC16_XMODEM);

	while(1) {
		code = (u32)de_getu32be(pos);
		if(code==CODE_PEnd) {
			de_dbg(c, "EOF marker at %"I64_FMT, pos);
			goto done;
		}
		if(code>>8 != CODE_PMa) {
			de_err(c, "Expected marker not found at %"I64_FMT, pos);
			goto done;
		}

		if(pmd) {
			packit_destroy_pmd(c, pmd);
			pmd = NULL;
		}

		pmd = de_malloc(c, sizeof(struct packit_md));
		pmd->advf = de_advfile_create(c);

		pmd->marker_pos = pos;
		packit_do_member(c, d, pmd);
		if(d->fatalerrflag) goto done;
		if(pmd->total_encoded_size<1) {
			d->fatalerrflag = 1;
			d->need_errmsg = 1;
			goto done;
		}
		pos += pmd->total_encoded_size;
	}

done:
	if(pmd) {
		packit_destroy_pmd(c, pmd);
	}
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Failed to decode PackIt file");
		}
		de_crcobj_destroy(d->crco_datarsrc);
		de_crcobj_destroy(d->crco_hdr);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %r14
movl $0x18, %esi
callq 0xe969b
movq %rax, %rbx
movq %r14, %rdi
movl $0x20, %esi
callq 0xeba56
movq %rax, 0x8(%rbx)
movq %r14, %rdi
movl $0x20, %esi
callq 0xeba56
movq %rax, 0x10(%rbx)
movq 0x18(%r14), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
callq 0xef32a
movl $0x0, %ebp
cmpl $0x50456e64, %eax       # imm = 0x50456E64
jne 0xb9ebd
leaq 0x7e155(%rip), %rsi     # 0x137fb5
movq %r14, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xe9226
testq %r15, %r15
je 0xb9e7d
movq %r14, %rdi
movq %r15, %rsi
callq 0xba397
testq %rbx, %rbx
je 0xb9eab
cmpb $0x0, 0x1(%rbx)
je 0xb9e99
leaq 0x7e159(%rip), %rsi     # 0x137fe8
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9df7
movq 0x8(%rbx), %rdi
callq 0xebe1d
movq 0x10(%rbx), %rdi
callq 0xebe1d
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50(%rsp), %r13
xorl %r12d, %r12d
xorl %r15d, %r15d
movq %rbx, 0x20(%rsp)
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x504d6100, %eax       # imm = 0x504D6100
jne 0xba317
testq %r15, %r15
je 0xb9eed
movq %r14, %rdi
movq %r15, %rsi
callq 0xba397
movl $0xf0, %esi
movq %r14, %rdi
callq 0xe969b
movq %rax, %r15
movq %r14, %rdi
callq 0xfca54
movq %rax, 0x38(%r15)
movq %r12, (%r15)
movq (%r15), %rax
addq $0x3, %rax
movq %rax, 0x28(%rsp)
movq %r14, %rdi
movq %rsp, %rsi
callq 0xe958c
movq (%r15), %rdx
movq %r14, %rdi
leaq 0x6c048(%rip), %rsi     # 0x125f78
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%r14), %rdi
leaq 0x28(%rsp), %rsi
callq 0xef14d
movb %al, 0x21(%r15)
movzbl %al, %edx
movq %r14, %rdi
leaq 0x7e0a2(%rip), %rsi     # 0x138005
xorl %eax, %eax
callq 0xe9226
movzbl 0x21(%r15), %eax
cmpl $0x34, %eax
je 0xb9fd3
cmpl $0x67, %eax
jne 0xba0c3
movq 0x18(%r14), %rax
movq %rax, 0x18(%r15)
movq (%r15), %rax
addq $0x4, %rax
movq %rax, 0x10(%r15)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xba3d4
cmpb $0x0, (%rbx)
jne 0xba19c
movq 0xd0(%r15), %rax
movq 0xe0(%r15), %rcx
addq %rcx, %rax
addq $0x64, %rax
movq %rax, 0x8(%r15)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xba73a
jmp 0xba13f
movb $0x1, %bpl
movb %bpl, 0x20(%r15)
movq %r14, %rdi
leaq 0x4(%rsp), %rsi
callq 0xe958c
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf0faf
movq %rax, 0xe8(%r15)
movq %r14, %rdi
leaq 0x30(%rsp), %r13
movq %r13, %rsi
leaq 0x8(%rsp), %rbx
movq %rbx, %rdx
leaq 0x50(%rsp), %rcx
callq 0xfa6e0
movq 0x18(%r14), %rax
movq %rax, 0x30(%rsp)
movq (%r15), %rcx
addq $0x4, %rcx
movq %rcx, 0x38(%rsp)
movq 0x18(%rax), %rax
subq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0xe8(%r15), %rax
movq %rax, 0x8(%rsp)
movb %bpl, 0x10(%rsp)
movq $0x5e, 0x18(%rsp)
movq %r14, %rdi
leaq 0x7e0aa(%rip), %rsi     # 0x138106
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movq %r14, %rdi
movq %r13, %rsi
leaq 0x50(%rsp), %r13
movq %rbx, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0xfbba5
movq 0x8(%rsp), %rdi
callq 0xf0ea4
cmpl $0x0, 0x50(%rsp)
je 0xba0dc
movq %r14, %rdi
movq %r13, %rsi
callq 0xfa6a8
movq %r14, %rdi
leaq 0x5a0c2(%rip), %rsi     # 0x114171
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9df7
movq 0x20(%rsp), %rbx
movb $0x1, (%rbx)
jmp 0xba133
movq %r14, %rdi
leaq 0x7df4e(%rip), %rsi     # 0x13801b
xorl %eax, %eax
callq 0xe9df7
movb $0x1, (%rbx)
jmp 0xba19c
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0xe8(%r15), %rax
movq %rax, 0x18(%r15)
movq $0x0, 0x10(%r15)
movq %r14, %rdi
movq 0x20(%rsp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0xba3d4
cmpb $0x0, (%rbx)
jne 0xba133
movq 0xe0(%r15), %rax
addq 0xd0(%r15), %rax
cmpq $0x2faf081, %rax        # imm = 0x2FAF081
jl 0xba1df
movw $0x101, (%rbx)          # imm = 0x101
movl 0x4(%rsp), %esi
movq %r14, %rdi
callq 0xe9595
cmpb $0x0, (%rbx)
jne 0xba19c
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
movq %rbx, 0x50(%rsp)
movq %r15, 0x58(%rsp)
movq 0x38(%r15), %rax
movq %r13, 0x8(%rax)
movq 0x68(%rax), %rdi
movq 0x40(%r15), %rax
movq 0x18(%rax), %rsi
callq 0xf6969
movq 0x38(%r15), %rdi
movb $0x1, 0x79(%rdi)
movq 0x40(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0xfcaec
movq 0x38(%r15), %rdi
leaq 0x675(%rip), %rax       # 0xba808
movq %rax, 0x60(%rdi)
callq 0xfcb73
movl (%rsp), %esi
movq %r14, %rdi
callq 0xe9595
cmpb $0x0, (%rbx)
jne 0xb9e6d
movq 0x8(%r15), %rbp
testq %rbp, %rbp
jle 0xba330
addq %r12, %rbp
movq 0x18(%r14), %rdi
movq %rbp, %rsi
callq 0xef32a
movq %rbp, %r12
cmpl $0x50456e64, %eax       # imm = 0x50456E64
jne 0xb9ecd
jmp 0xb9e59
movq %r14, %rdi
leaq 0x30(%rsp), %rbp
movq %rbp, %rsi
leaq 0x8(%rsp), %r13
movq %r13, %rdx
leaq 0x50(%rsp), %rcx
callq 0xfa6e0
movq 0xe8(%r15), %rdi
callq 0xf1a5f
movq 0x18(%r14), %rax
movq %rax, 0x30(%rsp)
movq (%r15), %rcx
addq $0x4, %rcx
movq %rcx, 0x38(%rsp)
movq 0x18(%rax), %rax
subq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0xe8(%r15), %rax
movq %rax, 0x8(%rsp)
movb $0x1, 0x10(%rsp)
movq 0xd0(%r15), %rax
movq 0xe0(%r15), %rcx
leaq 0x60(%rax,%rcx), %rax
movq %rax, 0x18(%rsp)
movq %r14, %rdi
leaq 0x7dec1(%rip), %rsi     # 0x13811d
xorl %eax, %eax
callq 0xe9226
movq %r14, %rdi
movl $0x1, %esi
callq 0xe9585
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
leaq 0x50(%rsp), %r13
movq %r13, %rcx
xorl %r8d, %r8d
callq 0xfbba5
movq 0x8(%rsp), %rdi
callq 0xf0ea4
cmpl $0x0, 0x50(%rsp)
je 0xba2be
movq %r14, %rdi
movq %r13, %rsi
callq 0xfa6a8
movq %r14, %rdi
leaq 0x59ec2(%rip), %rsi     # 0x114171
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9df7
jmp 0xba0be
cmpb $0x0, 0x54(%rsp)
je 0xba12e
movq 0x58(%rsp), %rdx
movq 0xe8(%r15), %rax
movq 0x18(%rax), %rcx
movq %r14, %rdi
leaq 0x589a5(%rip), %rsi     # 0x112c88
xorl %eax, %eax
callq 0xe9226
movq 0x58(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x8(%r15)
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xba73a
jmp 0xba133
leaq 0x7dca9(%rip), %rsi     # 0x137fc7
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9df7
jmp 0xb9e6d
movw $0x101, (%rbx)          # imm = 0x101
jmp 0xb9e6d