// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/lha.c
// Function: do_run_lha_internal
static void do_run_lha_internal(deark *c, lctx *d, de_module_params *mparams)
{
	i64 pos;
	struct member_data *md = NULL;
	de_encoding guessed_encoding;

	if(!d->basefmt_name) {
		d->basefmt_name = "LHA";
	}
	d->lhark_req = de_get_ext_option_bool(c, "lha:lhark", -1);
	d->lhark_policy = d->lhark_req;

	// It's not really safe to guess CP437, because Japanese-encoded (CP932?)
	// filenames are common.
	if(d->basefmt==BASEFMT_SWG || d->basefmt==BASEFMT_PAKLEO) {
		guessed_encoding = DE_ENCODING_CP437;
	}
	else if(d->basefmt==BASEFMT_TPK) {
		guessed_encoding = DE_ENCODING_WINDOWS1252;
	}
	else {
		guessed_encoding = DE_ENCODING_ASCII;
	}
	d->input_encoding = de_get_input_encoding(c, NULL, guessed_encoding);

	d->hlev_of_first_member = 0xff;
	if(d->basefmt==BASEFMT_PAKLEO) {
		d->crco = de_crcobj_create(c, DE_CRCOBJ_CRC32_PL);
	}
	else {
		d->crco = de_crcobj_create(c, DE_CRCOBJ_CRC16_ARC);
	}
	d->crco_cksum = de_crcobj_create(c, DE_CRCOBJ_SUM_BYTES);

	pos = 0;
	if(d->basefmt==BASEFMT_PAKLEO) pos += 37;

	while(1) {
		if(pos >= c->infile->len) break;

		md = create_member_data(c);
		md->encoding = d->input_encoding;
		md->member_pos = pos;
		if(!do_read_member(c, d, md)) goto done;
		if(md->total_size<1) goto done;

		d->member_count++;
		pos += md->total_size;

		destroy_member_data(c, md);
		md = NULL;
	}

done:
	do_lha_footer(c, d);
	destroy_member_data(c, md);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xc2676
movq -0x10(%rbp), %rax
leaq 0xf516a(%rip), %rcx     # 0x1b77dc
movq %rcx, 0x10(%rax)
movq -0x8(%rbp), %rdi
leaq 0xf515f(%rip), %rsi     # 0x1b77e0
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x15cbc0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x10(%rbp), %rax
cmpl $0x1, 0xc(%rax)
je 0xc26b6
movq -0x10(%rbp), %rax
cmpl $0x3, 0xc(%rax)
jne 0xc26bf
movl $0xd, -0x2c(%rbp)
jmp 0xc26db
movq -0x10(%rbp), %rax
cmpl $0x2, 0xc(%rax)
jne 0xc26d2
movl $0x9, -0x2c(%rbp)
jmp 0xc26d9
movl $0x1, -0x2c(%rbp)
jmp 0xc26db
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %edx
xorl %eax, %eax
movl %eax, %esi
callq 0x15e4a0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movb $-0x1, 0x18(%rax)
movq -0x10(%rbp), %rax
cmpl $0x3, 0xc(%rax)
jne 0xc2720
movq -0x8(%rbp), %rdi
movl $0x12, %esi
callq 0x15eac0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
jmp 0xc2739
movq -0x8(%rbp), %rdi
movl $0x21, %esi
callq 0x15eac0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rdi
movl $0x30, %esi
callq 0x15eac0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x3, 0xc(%rax)
jne 0xc2770
movq -0x20(%rbp), %rax
addq $0x25, %rax
movq %rax, -0x20(%rbp)
jmp 0xc2772
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jl 0xc2789
jmp 0xc280b
movq -0x8(%rbp), %rdi
callq 0xc2880
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xc28b0
cmpl $0x0, %eax
jne 0xc27c7
jmp 0xc280d
movq -0x28(%rbp), %rax
cmpq $0x1, 0x10(%rax)
jge 0xc27d4
jmp 0xc280d
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x1c(%rax)
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xc3730
movq $0x0, -0x28(%rbp)
jmp 0xc2772
jmp 0xc280d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xc37a0
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xc3730
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)