// File: /workspace/github_c_makefile_star2_O3/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 0xe8b2b
movq %rax, %rbx
movq %r14, %rdi
movl $0x20, %esi
callq 0xeb499
movq %rax, 0x8(%rbx)
movq %r14, %rdi
movl $0x20, %esi
callq 0xeb499
movq %rax, 0x10(%rbx)
movq 0x18(%r14), %rdi
xorl %r15d, %r15d
xorl %esi, %esi
callq 0xeed0d
movl $0x0, %ebp
cmpl $0x50456e64, %eax       # imm = 0x50456E64
jne 0xb92db
leaq 0x7f081(%rip), %rsi     # 0x138341
movq %r14, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xe8617
testq %r15, %r15
jne 0xb974c
jmp 0xb9757
leaq 0x58(%rsp), %r13
xorl %r12d, %r12d
xorl %r15d, %r15d
movq %rbx, 0x28(%rsp)
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x504d6100, %eax       # imm = 0x504D6100
jne 0xb972e
testq %r15, %r15
je 0xb930b
movq %r14, %rdi
movq %r15, %rsi
callq 0xb97f4
movl $0xf0, %esi
movq %r14, %rdi
callq 0xe8b2b
movq %rax, %r15
movq %r14, %rdi
callq 0xfc498
movq %rax, 0x38(%r15)
movq %r12, (%r15)
leaq 0x3(%r12), %rax
movq %rax, 0x30(%rsp)
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0xe8a1c
movq (%r15), %rdx
movq %r14, %rdi
leaq 0x6ce5a(%rip), %rsi     # 0x1261a8
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r14), %rdi
leaq 0x30(%rsp), %rsi
callq 0xeeb4b
movb %al, 0x21(%r15)
movzbl %al, %edx
movq %r14, %rdi
leaq 0x7f010(%rip), %rsi     # 0x138391
xorl %eax, %eax
callq 0xe8617
movzbl 0x21(%r15), %eax
cmpl $0x34, %eax
je 0xb93f1
cmpl $0x67, %eax
jne 0xb94e1
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 0xb9831
cmpb $0x0, (%rbx)
jne 0xb95b2
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 0xb9b97
jmp 0xb955d
movb $0x1, %bpl
movb %bpl, 0x20(%r15)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xe8a1c
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xf09c5
movq %rax, 0xe8(%r15)
movq %r14, %rdi
leaq 0x38(%rsp), %r13
movq %r13, %rsi
leaq 0x10(%rsp), %rbx
movq %rbx, %rdx
leaq 0x58(%rsp), %rcx
callq 0xfa1dc
movq 0x18(%r14), %rax
movq %rax, 0x38(%rsp)
movq (%r15), %rcx
addq $0x4, %rcx
movq %rcx, 0x40(%rsp)
movq 0x18(%rax), %rax
subq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0xe8(%r15), %rax
movq %rax, 0x10(%rsp)
movb %bpl, 0x18(%rsp)
movq $0x5e, 0x20(%rsp)
movq %r14, %rdi
leaq 0x7f018(%rip), %rsi     # 0x138492
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %r14, %rdi
movq %r13, %rsi
leaq 0x58(%rsp), %r13
movq %rbx, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0xfb640
movq 0x10(%rsp), %rdi
callq 0xf08ba
cmpl $0x0, 0x58(%rsp)
je 0xb94fa
movq %r14, %rdi
movq %r13, %rsi
callq 0xfa1a4
movq %r14, %rdi
leaq 0x5ad54(%rip), %rsi     # 0x114221
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9295
movq 0x28(%rsp), %rbx
movb $0x1, (%rbx)
jmp 0xb9551
movq %r14, %rdi
leaq 0x7eebc(%rip), %rsi     # 0x1383a7
xorl %eax, %eax
callq 0xe9295
movb $0x1, (%rbx)
jmp 0xb95b2
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq 0xe8(%r15), %rax
movq %rax, 0x18(%r15)
movq $0x0, 0x10(%r15)
movq %r14, %rdi
movq 0x28(%rsp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0xb9831
cmpb $0x0, (%rbx)
jne 0xb9551
movq 0xe0(%r15), %rax
addq 0xd0(%r15), %rax
cmpq $0x2faf081, %rax        # imm = 0x2FAF081
jl 0xb95f6
movw $0x101, (%rbx)          # imm = 0x101
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
cmpb $0x0, (%rbx)
jne 0xb95b2
movq %rbx, 0x58(%rsp)
movq %r15, 0x60(%rsp)
movq 0x38(%r15), %rax
movq %r13, 0x8(%rax)
movq 0x68(%rax), %rdi
movq 0x40(%r15), %rax
movq 0x18(%rax), %rsi
callq 0xf6509
movq 0x38(%r15), %rdi
movb $0x1, 0x79(%rdi)
movq 0x40(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0xfc530
movq 0x38(%r15), %rdi
leaq 0x6bc(%rip), %rax       # 0xb9c65
movq %rax, 0x60(%rdi)
callq 0xfc5b7
movl 0x8(%rsp), %esi
movq %r14, %rdi
callq 0xe8a25
cmpb $0x0, (%rbx)
jne 0xb974c
movq 0x8(%r15), %rbp
testq %rbp, %rbp
jle 0xb9747
addq %r12, %rbp
movq 0x18(%r14), %rdi
movq %rbp, %rsi
callq 0xeed0d
movq %rbp, %r12
cmpl $0x50456e64, %eax       # imm = 0x50456E64
jne 0xb92eb
jmp 0xb92b9
movq %r14, %rdi
leaq 0x38(%rsp), %rbp
movq %rbp, %rsi
leaq 0x10(%rsp), %r13
movq %r13, %rdx
leaq 0x58(%rsp), %rcx
callq 0xfa1dc
movq 0xe8(%r15), %rdi
callq 0xf145f
movq 0x18(%r14), %rax
movq %rax, 0x38(%rsp)
movq (%r15), %rcx
addq $0x4, %rcx
movq %rcx, 0x40(%rsp)
movq 0x18(%rax), %rax
subq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0xe8(%r15), %rax
movq %rax, 0x10(%rsp)
movb $0x1, 0x18(%rsp)
movq 0xd0(%r15), %rax
movq 0xe0(%r15), %rcx
leaq 0x60(%rax,%rcx), %rax
movq %rax, 0x20(%rsp)
movq %r14, %rdi
leaq 0x7ee36(%rip), %rsi     # 0x1384a9
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
leaq 0x58(%rsp), %r13
movq %r13, %rcx
xorl %r8d, %r8d
callq 0xfb640
movq 0x10(%rsp), %rdi
callq 0xf08ba
cmpl $0x0, 0x58(%rsp)
je 0xb96d5
movq %r14, %rdi
movq %r13, %rsi
callq 0xfa1a4
movq %r14, %rdi
leaq 0x5ab5b(%rip), %rsi     # 0x114221
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9295
jmp 0xb94dc
cmpb $0x0, 0x5c(%rsp)
je 0xb954c
movq 0x60(%rsp), %rdx
movq 0xe8(%r15), %rax
movq 0x18(%rax), %rcx
movq %r14, %rdi
leaq 0x5959e(%rip), %rsi     # 0x112c98
xorl %eax, %eax
callq 0xe8617
movq 0x60(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x8(%r15)
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xb9b97
jmp 0xb9551
leaq 0x7ec1e(%rip), %rsi     # 0x138353
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9295
jmp 0xb92cd
movw $0x101, (%rbx)          # imm = 0x101
movq %r14, %rdi
movq %r15, %rsi
callq 0xb97f4
testq %rbx, %rbx
je 0xb9785
cmpb $0x0, 0x1(%rbx)
je 0xb9773
leaq 0x7ec0b(%rip), %rsi     # 0x138374
movq %r14, %rdi
xorl %eax, %eax
callq 0xe9295
movq 0x8(%rbx), %rdi
callq 0xeb858
movq 0x10(%rbx), %rdi
callq 0xeb858
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq