// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/pif.c
// Function: do_pif_main
static void do_pif_main(deark *c, de_module_params *mparams, int is_dvp)
{
	const char *tmps;
	struct pif_ctx *d = NULL;
	int is_oldfmt = 0;

	d = de_malloc(c, sizeof(struct pif_ctx));
	d->tmpstr = ucstring_create(c);

	d->input_encoding_ansi = de_get_input_encoding(c, NULL, DE_ENCODING_WINDOWS1252);

	d->input_encoding_oem = DE_ENCODING_CP437; // default
	tmps = de_get_ext_option(c, "oemenc");
	if(tmps) {
		d->input_encoding_oem = de_encoding_name_to_code(tmps);
		if(d->input_encoding_oem == DE_ENCODING_UNKNOWN) {
			d->input_encoding_oem = DE_ENCODING_CP437;
		}
	}

	d->pos_seen = de_inthashtable_create(c);

	if(!is_dvp && (c->infile->len < PIF_BASIC_SECTION_SIZE+22)) {
		is_oldfmt = 1;
	}

	if(is_oldfmt) {
		do_pif_section_basic(c, d, 0, PIF_BASIC_SECTION_SIZE);
	}
	else if(is_dvp) {
		do_pif_section_basic(c, d, 0, PIF_BASIC_SECTION_SIZE);
		do_dvp_extensions(c, d);
	}
	else {
		do_pif_sections(c, d);
	}

	if(d) {
		ucstring_destroy(d->tmpstr);
		de_inthashtable_destroy(c, d->pos_seen);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movq %rdi, %rbx
pushq $0x28
popq %rsi
callq 0xdecaf
movq %rax, %r14
movq %rbx, %rdi
callq 0xeac74
movq %rax, 0x8(%r14)
pushq $0x9
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, 0x4(%r14)
movl $0xd, (%r14)
leaq 0x6059f(%rip), %rsi     # 0x116146
movq %rbx, %rdi
callq 0xdfa87
testq %rax, %rax
je 0xb5bc7
movq %rax, %rdi
callq 0xe202b
testl %eax, %eax
pushq $0xd
popq %rcx
cmovnel %eax, %ecx
movl %ecx, (%r14)
movq %rbx, %rdi
callq 0xe0955
movq %rax, 0x18(%r14)
testl %ebp, %ebp
je 0xb5c4d
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xb6342
movq 0x8(%r14), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
movq 0x8(%r14), %rcx
pushq $0x2
popq %rdx
pushq $0x1
popq %r9
movl $0x171, %esi            # imm = 0x171
xorl %r8d, %r8d
callq 0xe4c9a
movq 0x8(%r14), %rdi
callq 0xeb877
leaq 0x76334(%rip), %rsi     # 0x12bf4d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movl $0x17e, %esi            # imm = 0x17E
callq 0xe3eb4
movzbl %al, %edx
leaq 0x7631a(%rip), %rsi     # 0x12bf58
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
jmp 0xb6313
movq 0x18(%rbx), %rax
cmpq $0x186, 0x18(%rax)      # imm = 0x186
jle 0xb6306
movq $0x171, 0x10(%r14)      # imm = 0x171
movl $0x171, %r13d           # imm = 0x171
pushq $0x1
popq %r12
cmpq $0xffff, %r13           # imm = 0xFFFF
je 0xb6313
movq $0xffff, 0x10(%r14)     # imm = 0xFFFF
leaq 0x16(%r13), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0xb6313
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xb654a
testl %eax, %eax
je 0xb6313
movq %rbx, %rdi
leaq 0x1c(%rsp), %rsi
callq 0xdebae
movq %rbx, %rdi
leaq 0x5949d(%rip), %rsi     # 0x10f162
movq %r13, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movl %r12d, %esi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %r9d
movq %r13, %rsi
pushq $0x10
popq %rcx
movq %rcx, %rdx
movl %r12d, %r8d
callq 0xe495c
movq %rax, 0x20(%rsp)
movq 0x18(%rax), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x5f8b0(%rip), %rsi     # 0x1155bb
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x10, %r13
movq %r13, 0x28(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x28(%rsp), %r15
movq %r15, %rsi
callq 0xe3fc4
movq %rax, 0x10(%r14)
movq %rbx, %rdi
leaq 0x76245(%rip), %rsi     # 0x12bf82
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, %r13
movq %rbx, %rdi
leaq 0x630d5(%rip), %rsi     # 0x118e35
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, %rbp
movq %rbx, %rdi
leaq 0x6fb60(%rip), %rsi     # 0x1258e3
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x10(%r14), %rax
movq %rax, 0x30(%rsp)
testq %rbp, %rbp
je 0xb5db1
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xb654a
testl %eax, %eax
je 0xb62ad
movq %rbx, %rdi
leaq 0x761dd(%rip), %rsi     # 0x12bf98
movq %r13, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movl %r12d, %r15d
movl %r12d, %esi
callq 0xdeba7
movq 0x20(%rsp), %rax
movq 0x8(%rax), %r12
movq %r12, %rdi
leaq 0x761cc(%rip), %rsi     # 0x12bfb5
callq 0x181a0
testl %eax, %eax
je 0xb5ea4
movq %r12, %rdi
leaq 0x761c5(%rip), %rsi     # 0x12bfc5
callq 0x181a0
testl %eax, %eax
je 0xb5eba
movq %r12, %rdi
leaq 0x761be(%rip), %rsi     # 0x12bfd5
callq 0x181a0
testl %eax, %eax
je 0xb5f35
movq %r12, %rdi
leaq 0x761b7(%rip), %rsi     # 0x12bfe5
callq 0x181a0
testl %eax, %eax
je 0xb609e
movq %r12, %rdi
leaq 0x761b0(%rip), %rsi     # 0x12bff5
callq 0x181a0
testl %eax, %eax
je 0xb6208
movq %r12, %rdi
leaq 0x761a9(%rip), %rsi     # 0x12c005
callq 0x181a0
testl %eax, %eax
je 0xb62da
movq %r12, %rdi
leaq 0x761af(%rip), %rsi     # 0x12c022
callq 0x181a0
testl %eax, %eax
je 0xb62ec
movq 0x18(%rbx), %rsi
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %rbx, %rdi
movq %r13, %rdx
movq %rbp, %rcx
xorl %r9d, %r9d
callq 0xded3a
jmp 0xb5eb2
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xb6342
movl %r15d, %r12d
jmp 0xb62ad
movq %r13, 0x10(%rsp)
cmpq $0x6, %rbp
movl %r15d, %r12d
jl 0xb62ad
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x76156(%rip), %rsi     # 0x12c03d
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x76143(%rip), %rsi     # 0x12c04a
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x661c6(%rip), %rsi     # 0x11c0ed
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
jmp 0xb62ad
movq %r13, 0x10(%rsp)
cmpq $0x68, %rbp
movl %r15d, %r12d
jl 0xb62ad
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r15
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x760f5(%rip), %rsi     # 0x12c057
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x760ef(%rip), %rsi     # 0x12c071
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x4, 0x10(%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x760e3(%rip), %rsi     # 0x12c08b
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x760d0(%rip), %rsi     # 0x12c098
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x76055(%rip), %rsi     # 0x12c03d
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x76042(%rip), %rsi     # 0x12c04a
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe40bf
movq %rbx, %rdi
leaq 0x7607d(%rip), %rsi     # 0x12c0a5
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x7606d(%rip), %rsi     # 0x12c0b4
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
addq $0x28, %r13
movq %r13, 0x10(%rsp)
movq 0x8(%r14), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%r14), %rcx
movl (%r14), %r9d
pushq $0x40
popq %rdx
movl %r12d, %r8d
callq 0xe4c9a
movq 0x8(%r14), %rdi
callq 0xead03
movq 0x8(%r14), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x6e7da(%rip), %rsi     # 0x124873
jmp 0xb62a3
cmpq $0x1ac, %rbp            # imm = 0x1AC
movl %r15d, %r12d
jl 0xb62ad
leaq 0x58(%r13), %r12
movq 0x8(%r14), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
movq %r12, %rsi
movl %r15d, %r12d
pushq $0x50
popq %r15
movq %r15, %rdx
movl %r12d, %r8d
callq 0xe4c9a
movq 0x8(%r14), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x75fd4(%rip), %rsi     # 0x12c0c3
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
leaq 0xa8(%r13), %rax
movq %rax, 0x10(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0x75fb6(%rip), %rsi     # 0x12c0d3
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
leaq 0xea(%r13), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%r14), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
pushq $0x20
popq %rbp
movq %rbp, %rdx
movl %r12d, %r8d
callq 0xe4c9a
movq 0x8(%r14), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x75f71(%rip), %rsi     # 0x12c0df
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x20, 0x10(%rsp)
movq 0x8(%r14), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
movq %rbp, %rdx
movl %r12d, %r8d
callq 0xe4c9a
movq 0x8(%r14), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x75f3b(%rip), %rsi     # 0x12c0f1
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x156, %r13            # imm = 0x156
movq %r13, 0x10(%rsp)
movq 0x8(%r14), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
movq 0x8(%r14), %rcx
movl (%r14), %r9d
movq %r15, %rdx
movl %r12d, %r8d
callq 0xe4c9a
movq 0x8(%r14), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x75f02(%rip), %rsi     # 0x12c105
jmp 0xb62a3
cmpq $0x8c, %rbp
movl %r15d, %r12d
jl 0xb62ad
movq 0x28(%rsp), %r12
leaq 0xc(%r12), %r13
movq 0x8(%r14), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
movq %r13, %rsi
pushq $0x40
popq %r13
movq %r13, %rdx
movl %r15d, %r8d
callq 0xe4c9a
movq 0x8(%r14), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x75eb8(%rip), %rsi     # 0x12c114
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x4c, %r12
movq 0x8(%r14), %rdi
callq 0xeac85
movq 0x18(%rbx), %rdi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
movq %r12, %rsi
movl %r15d, %r12d
movq %r13, %rdx
movl %r15d, %r8d
callq 0xe4c9a
movq 0x8(%r14), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x75e86(%rip), %rsi     # 0x12c129
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0xe4b94
movl 0x1c(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
cmpq $0xffff, 0x30(%rsp)     # imm = 0xFFFF
je 0xb6313
movq 0x10(%r14), %r13
jmp 0xb5c71
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
leaq 0x75d2b(%rip), %rcx     # 0x12c015
jmp 0xb62fc
movq %rbx, %rdi
movq %r13, %rsi
movq %rbp, %rdx
leaq 0x75d36(%rip), %rcx     # 0x12c032
callq 0xb6582
jmp 0xb5eb2
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xb6342
movq 0x8(%r14), %rdi
callq 0xeaf3c
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0xe095f
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq