// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl $0x18, %esi
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl $0x20, %esi
callq 0x15eac0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movl $0x20, %esi
callq 0x15eac0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
callq 0x165470
movl %eax, -0x2c(%rbp)
cmpl $0x50456e64, -0x2c(%rbp) # imm = 0x50456E64
jne 0x111844
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0xb23bd(%rip), %rsi     # 0x1c3bf5
movb $0x0, %al
callq 0x15b0d0
jmp 0x111906
movl -0x2c(%rbp), %eax
shrl $0x8, %eax
cmpl $0x504d61, %eax         # imm = 0x504D61
je 0x11186c
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0xb23a7(%rip), %rsi     # 0x1c3c07
movb $0x0, %al
callq 0x15bfb0
jmp 0x111906
cmpq $0x0, -0x20(%rbp)
je 0x111888
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x111a00
movq $0x0, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movl $0xf0, %esi
callq 0x15b780
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x17aa20
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x111a60
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
je 0x1118d5
jmp 0x111906
movq -0x20(%rbp), %rax
cmpq $0x1, 0x8(%rax)
jge 0x1118f1
movq -0x18(%rbp), %rax
movb $0x1, (%rax)
movq -0x18(%rbp), %rax
movb $0x1, 0x1(%rax)
jmp 0x111906
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x11180c
cmpq $0x0, -0x20(%rbp)
je 0x11191a
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x111a00
cmpq $0x0, -0x18(%rbp)
je 0x111957
movq -0x18(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0x11193d
movq -0x8(%rbp), %rdi
leaq 0xb22f2(%rip), %rsi     # 0x1c3c28
movb $0x0, %al
callq 0x15bfb0
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x15f2e0
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x15f2e0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)