// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x18
popq %rsi
callq 0xdecaf
movq %rax, %rbx
pushq $0x20
popq %rbp
movq %r14, %rdi
movl %ebp, %esi
callq 0xe0ae9
movq %rax, 0x8(%rbx)
movq %r14, %rdi
movl %ebp, %esi
callq 0xe0ae9
movq %rax, 0x10(%rbx)
pushq $0x1
popq %r12
leaq 0x58(%rsp), %rbp
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rbx, 0x28(%rsp)
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xe404f
cmpl $0x50456e64, %eax       # imm = 0x50456E64
je 0xb246d
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
cmpl $0x504d6100, %eax       # imm = 0x504D6100
jne 0xb2483
testq %r15, %r15
je 0xb2065
movq %r14, %rdi
movq %r15, %rsi
callq 0xb253c
movl $0xf0, %esi
movq %r14, %rdi
callq 0xdecaf
movq %rax, %r15
movq %r14, %rdi
callq 0xf07cc
movq %rax, 0x38(%r15)
movq %r13, (%r15)
leaq 0x3(%r13), %rax
movq %rax, 0x50(%rsp)
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0xdebae
movq (%r15), %rdx
movq %r14, %rdi
leaq 0x66f01(%rip), %rsi     # 0x118fa8
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movl %r12d, %esi
callq 0xdeba7
movq 0x18(%r14), %rdi
leaq 0x50(%rsp), %rsi
callq 0xe3f2a
movb %al, 0x21(%r15)
movzbl %al, %edx
movq %r14, %rdi
leaq 0x78fb9(%rip), %rsi     # 0x12b091
xorl %eax, %eax
callq 0xde896
movzbl 0x21(%r15), %eax
cmpl $0x34, %eax
je 0xb2148
cmpl $0x67, %eax
jne 0xb223d
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 0xb2579
cmpb $0x0, (%rbx)
jne 0xb2445
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 0xb28d4
jmp 0xb23f0
movb $0x1, %r12b
movb %r12b, 0x20(%r15)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0xdebae
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe59cd
movq %rax, 0xe8(%r15)
movq %r14, %rdi
leaq 0x30(%rsp), %rbp
movq %rbp, %rsi
leaq 0x10(%rsp), %rbx
movq %rbx, %rdx
leaq 0x58(%rsp), %rcx
callq 0xee7ee
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, 0x10(%rsp)
movb %r12b, 0x18(%rsp)
pushq $0x1
popq %r12
movq $0x5e, 0x20(%rsp)
movq %r14, %rdi
leaq 0x78fbd(%rip), %rsi     # 0x12b192
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movl %r12d, %esi
callq 0xdeba7
movq %r14, %rdi
movq %rbp, %rsi
leaq 0x58(%rsp), %rbp
movq %rbx, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0xef9dc
movq 0x10(%rsp), %rdi
callq 0xe58e8
cmpl $0x0, 0x58(%rsp)
je 0xb2256
movq %r14, %rdi
movq %rbp, %rsi
callq 0xee7bc
movq %r14, %rdi
leaq 0x54f9b(%rip), %rsi     # 0x1071c1
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf2a5
movq 0x28(%rsp), %rbx
movb $0x1, (%rbx)
jmp 0xb23e4
movq %r14, %rdi
leaq 0x78e60(%rip), %rsi     # 0x12b0a7
xorl %eax, %eax
callq 0xdf2a5
movb $0x1, (%rbx)
jmp 0xb2445
movq %r14, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq 0xe8(%r15), %rax
movq %rax, 0x18(%r15)
andq $0x0, 0x10(%r15)
movq %r14, %rdi
movq 0x28(%rsp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0xb2579
cmpb $0x0, (%rbx)
jne 0xb23e4
movq 0xe0(%r15), %rax
addq 0xd0(%r15), %rax
cmpq $0x2faf081, %rax        # imm = 0x2FAF081
jl 0xb22ad
movw $0x101, (%rbx)          # imm = 0x101
jmp 0xb23e4
movq %r14, %rdi
movl %r12d, %ebp
leaq 0x30(%rsp), %rsi
leaq 0x10(%rsp), %r12
movq %r12, %rdx
leaq 0x58(%rsp), %rcx
callq 0xee7ee
movq 0xe8(%r15), %rdi
callq 0xe62cf
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, 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 0x78e7f(%rip), %rsi     # 0x12b1a9
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movl %ebp, %esi
leaq 0x58(%rsp), %rbp
callq 0xdeba7
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
callq 0xef9dc
movq 0x10(%rsp), %rdi
callq 0xe58e8
cmpl $0x0, 0x58(%rsp)
je 0xb238b
movq %r14, %rdi
movq %rbp, %rsi
callq 0xee7bc
movq %r14, %rdi
leaq 0x54e45(%rip), %rsi     # 0x1071c1
movq %rax, %rdx
xorl %eax, %eax
callq 0xdf2a5
movb $0x1, (%rbx)
jmp 0xb23e0
cmpb $0x0, 0x5c(%rsp)
je 0xb23db
movq 0x60(%rsp), %rdx
movq 0xe8(%r15), %rax
movq 0x18(%rax), %rcx
movq %r14, %rdi
leaq 0x538cc(%rip), %rsi     # 0x105c78
xorl %eax, %eax
callq 0xde896
movq 0x60(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x8(%r15)
movq %r14, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xb28d4
jmp 0xb23e0
movw $0x101, (%rbx)          # imm = 0x101
pushq $0x1
popq %r12
movl 0xc(%rsp), %esi
movq %r14, %rdi
callq 0xdebb7
cmpb $0x0, (%rbx)
jne 0xb2445
movq %rbx, 0x58(%rsp)
movq %r15, 0x60(%rsp)
movq 0x38(%r15), %rax
movq %rbp, 0x8(%rax)
movq 0x68(%rax), %rdi
movq 0x40(%r15), %rax
movq 0x18(%rax), %rsi
callq 0xead71
movq 0x38(%r15), %rdi
movb $0x1, 0x79(%rdi)
movq 0x40(%r15), %rax
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
callq 0xf0864
movq 0x38(%r15), %rdi
leaq 0x566(%rip), %rax       # 0xb29a2
movq %rax, 0x60(%rdi)
callq 0xf08e8
movl 0x8(%rsp), %esi
movq %r14, %rdi
callq 0xdebb7
cmpb $0x0, (%rbx)
jne 0xb249c
movq 0x8(%r15), %rax
addq %rax, %r13
testq %rax, %rax
jg 0xb202e
movw $0x101, (%rbx)          # imm = 0x101
jmp 0xb249c
leaq 0x78bcd(%rip), %rsi     # 0x12b041
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
jmp 0xb2497
leaq 0x78bc9(%rip), %rsi     # 0x12b053
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xdf2a5
testq %r15, %r15
je 0xb24a7
movq %r14, %rdi
movq %r15, %rsi
callq 0xb253c
testq %rbx, %rbx
je 0xb24d5
cmpb $0x0, 0x1(%rbx)
je 0xb24c3
leaq 0x78bbb(%rip), %rsi     # 0x12b074
movq %r14, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq 0x8(%rbx), %rdi
callq 0xe0e8d
movq 0x10(%rbx), %rdi
callq 0xe0e8d
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq