// File: /workspace/github_c_makefile_star2_O3/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 $0x28, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movl $0x28, %esi
callq 0xe8b2b
movq %rax, %r14
movq %rbx, %rdi
callq 0xf6410
movq %rax, 0x8(%r14)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb220
movl %eax, 0x4(%r14)
movl $0xd, (%r14)
leaq 0x66175(%rip), %rsi     # 0x123306
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0xbd1b3
movq %rax, %rdi
callq 0xecb12
testl %eax, %eax
movl $0xd, %ecx
cmovnel %eax, %ecx
movl %ecx, (%r14)
movq %rbx, %rdi
callq 0xeb2a9
movq %rax, 0x18(%r14)
testl %ebp, %ebp
je 0xbd23d
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xbd949
movq 0x8(%r14), %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq 0x8(%r14), %rcx
movl $0x171, %esi            # imm = 0x171
movl $0x2, %edx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xefbd7
movq 0x8(%r14), %rdi
callq 0xf70f6
leaq 0x7c044(%rip), %rsi     # 0x13924d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movl $0x17e, %esi            # imm = 0x17E
callq 0xeead3
movzbl %al, %edx
leaq 0x7c02a(%rip), %rsi     # 0x139258
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
jmp 0xbd91a
movq 0x18(%rbx), %rax
cmpq $0x186, 0x18(%rax)      # imm = 0x186
jle 0xbd90d
movl $0x171, %r12d           # imm = 0x171
movq $0xffff, 0x10(%r14)     # imm = 0xFFFF
leaq 0x16(%r12), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0xbd91a
movq 0x18(%r14), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xbdb5c
testl %eax, %eax
je 0xbd91a
movq %rbx, %rdi
leaq 0x1c(%rsp), %rsi
callq 0xe8a1c
movq %rbx, %rdi
leaq 0x5efb4(%rip), %rsi     # 0x11c252
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movl 0x4(%r14), %r9d
movl $0x10, %edx
movl $0x10, %ecx
movq %r12, %rsi
movl $0x1, %r8d
callq 0xef87c
movq %rax, %r15
movq 0x18(%rax), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0x65490(%rip), %rsi     # 0x12277b
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x10, %r12
movq %r12, 0x20(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x20(%rsp), %r13
movq %r13, %rsi
callq 0xeebeb
movq %rax, 0x10(%r14)
movq %rbx, %rdi
leaq 0x7bf65(%rip), %rsi     # 0x139282
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rax, %r12
movq %rbx, %rdi
leaq 0x68cf5(%rip), %rsi     # 0x126035
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rax, %r13
movq %rbx, %rdi
leaq 0x75880(%rip), %rsi     # 0x132be3
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x10(%r14), %rbp
testq %r13, %r13
je 0xbd38d
movq 0x18(%r14), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0xbdb5c
testl %eax, %eax
je 0xbd8da
movq %rbp, 0x10(%rsp)
movq %rbx, %rdi
leaq 0x7befc(%rip), %rsi     # 0x139298
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x8(%r15), %rbp
movq %rbp, %rdi
leaq 0x7bef1(%rip), %rsi     # 0x1392b5
callq 0x181a0
testl %eax, %eax
je 0xbd482
movq %rbp, %rdi
leaq 0x7beea(%rip), %rsi     # 0x1392c5
callq 0x181a0
testl %eax, %eax
je 0xbd495
movq %rbp, %rdi
leaq 0x7bee3(%rip), %rsi     # 0x1392d5
callq 0x181a0
testl %eax, %eax
je 0xbd50d
movq %rbp, %rdi
leaq 0x7bedc(%rip), %rsi     # 0x1392e5
callq 0x181a0
testl %eax, %eax
je 0xbd682
movq %rbp, %rdi
leaq 0x7bed5(%rip), %rsi     # 0x1392f5
callq 0x181a0
testl %eax, %eax
je 0xbd7fb
movq %rbp, %rdi
leaq 0x7bece(%rip), %rsi     # 0x139305
callq 0x181a0
testl %eax, %eax
je 0xbd8a7
movq %rbp, %rdi
leaq 0x7bed4(%rip), %rsi     # 0x139322
callq 0x181a0
movq 0x18(%rbx), %rsi
testl %eax, %eax
je 0xbd8ba
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %rbx, %rdi
movq %r12, %rdx
movq %r13, %rcx
xorl %r9d, %r9d
callq 0xe8bea
jmp 0xbd8d5
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0xbd949
jmp 0xbd8d5
movq %r12, 0x8(%rsp)
cmpq $0x6, %r13
jl 0xbd8d5
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %r12
movq %r12, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7be7e(%rip), %rsi     # 0x13933d
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7be6b(%rip), %rsi     # 0x13934a
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x6be2e(%rip), %rsi     # 0x12932d
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
jmp 0xbd8d5
movq %r12, 0x8(%rsp)
cmpq $0x68, %r13
jl 0xbd8d5
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7be20(%rip), %rsi     # 0x139357
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7be1a(%rip), %rsi     # 0x139371
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x4, 0x8(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7be0e(%rip), %rsi     # 0x13938b
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7bdfb(%rip), %rsi     # 0x139398
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7bd80(%rip), %rsi     # 0x13933d
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7bd6d(%rip), %rsi     # 0x13934a
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed83
movq %rbx, %rdi
leaq 0x7bda8(%rip), %rsi     # 0x1393a5
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7bd98(%rip), %rsi     # 0x1393b4
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
addq $0x28, %r12
movq %r12, 0x8(%rsp)
movq 0x8(%r14), %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq 0x8(%r14), %rcx
movl (%r14), %r9d
movl $0x40, %edx
movl $0x1, %r8d
callq 0xefbd7
movq 0x8(%r14), %rdi
callq 0xf64a0
movq 0x8(%r14), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0x744ec(%rip), %rsi     # 0x131b5f
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
jmp 0xbd8d5
cmpq $0x1ac, %r13            # imm = 0x1AC
movq 0x10(%rsp), %rbp
jl 0xbd8da
leaq 0x58(%r12), %r13
movq 0x8(%r14), %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
movl $0x50, %edx
movq %r13, %rsi
movl $0x1, %r8d
callq 0xefbd7
movq 0x8(%r14), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0x7bcef(%rip), %rsi     # 0x1393c3
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
leaq 0xa8(%r12), %rax
movq %rax, 0x8(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0xeebeb
movq %rbx, %rdi
leaq 0x7bcd0(%rip), %rsi     # 0x1393d3
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
leaq 0xea(%r12), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
movl $0x20, %edx
movl $0x1, %r8d
callq 0xefbd7
movq 0x8(%r14), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0x7bc88(%rip), %rsi     # 0x1393df
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x20, 0x8(%rsp)
movq 0x8(%r14), %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
movl $0x20, %edx
movl $0x1, %r8d
callq 0xefbd7
movq 0x8(%r14), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0x7bc4d(%rip), %rsi     # 0x1393f1
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x156, %r12            # imm = 0x156
movq %r12, 0x8(%rsp)
movq 0x8(%r14), %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq 0x8(%r14), %rcx
movl (%r14), %r9d
movl $0x50, %edx
movl $0x1, %r8d
callq 0xefbd7
movq 0x8(%r14), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0x7bc0f(%rip), %rsi     # 0x139405
jmp 0xbd89b
cmpq $0x8c, %r13
movq 0x10(%rsp), %rbp
jl 0xbd8da
movq 0x20(%rsp), %r12
leaq 0xc(%r12), %r13
movq 0x8(%r14), %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
movl $0x40, %edx
movq %r13, %rsi
movl $0x1, %r8d
callq 0xefbd7
movq 0x8(%r14), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0x7bbc2(%rip), %rsi     # 0x139414
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x4c, %r12
movq 0x8(%r14), %rdi
callq 0xf6423
movq 0x18(%rbx), %rdi
movq 0x8(%r14), %rcx
movl 0x4(%r14), %r9d
movl $0x40, %edx
movq %r12, %rsi
movl $0x1, %r8d
callq 0xefbd7
movq 0x8(%r14), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0x7bb8e(%rip), %rsi     # 0x139429
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
jmp 0xbd8da
movq 0x18(%rbx), %rdi
movq %r12, %rsi
movq %r13, %rdx
leaq 0x7ba5d(%rip), %rcx     # 0x139315
jmp 0xbd8ca
movq %rsi, %rdi
movq %r12, %rsi
movq %r13, %rdx
leaq 0x7ba68(%rip), %rcx     # 0x139332
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xefd48
movq 0x10(%rsp), %rbp
movq %rbx, %rdi
movq %r15, %rsi
callq 0xefaca
movl 0x1c(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
cmpq $0xffff, %rbp           # imm = 0xFFFF
je 0xbd91a
movq 0x10(%r14), %r12
cmpq $0xffff, %r12           # imm = 0xFFFF
jne 0xbd255
jmp 0xbd91a
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xbd949
movq 0x8(%r14), %rdi
callq 0xf6753
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0xeb2b3
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq