// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/iso9660.c
// Function: de_run_iso9660
static void de_run_iso9660(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	i64 cursec;
	const char *s;

	d = de_malloc(c, sizeof(lctx));

	if(de_get_ext_option_bool(c, "iso9660:tolower", 0)) {
		d->names_to_lowercase = 1;
	}

	d->dirsize_hack_state = de_get_ext_option_bool(c, "iso9660:dirsizehack", -1);

	s = de_get_ext_option(c, "iso9660:voldesc");
	if(s) {
		d->vol_desc_sector_forced = 1;
		d->vol_desc_sector_to_use = de_atoi(s);
	}

	d->user_req_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_UNKNOWN);
	d->rr_encoding = (d->user_req_encoding==DE_ENCODING_UNKNOWN) ?
		DE_ENCODING_UTF8 : d->user_req_encoding;

	d->secsize = 2048;

	if(!dbuf_memcmp(c->infile, 512, "PM\x00\x00", 4)) {
		de_info(c, "Note: This file includes an Apple Partition Map. "
			"Use \"-m apm\" to read it.");
	}

	d->voldesc_crc_hash = de_inthashtable_create(c);
	cursec = 16;
	while(1) {
		if(!do_volume_descriptor(c, d, cursec)) break;
		cursec++;
	}

	if(d->is_udf) {
		de_warn(c, "This file might have UDF-specific content, which is "
			"not supported.");
	}

	if(!d->vol) {
		de_err(c, "No usable volume descriptor found");
		goto done;
	}

	de_dbg(c, "[using volume descriptor at sector %u]", (unsigned int)d->vol->secnum);

	if(d->vol->block_size != 2048) {
		// TODO: Figure out sector size vs. block size.
		de_err(c, "Unsupported block size: %u", (unsigned int)d->vol->block_size);
		goto done;
	}

	d->dirs_seen = de_inthashtable_create(c);
	d->curpath = de_strarray_create(c, MAX_NESTING_LEVEL+10);

	if(d->vol->root_dir_extent_blk) {
		do_directory(c, d, sector_dpos(d, d->vol->root_dir_extent_blk),
			d->vol->root_dir_data_len, 0);
	}

done:
	if(d) {
		de_free(c, d->vol);
		de_strarray_destroy(d->curpath);
		de_inthashtable_destroy(c, d->dirs_seen);
		de_inthashtable_destroy(c, d->voldesc_crc_hash);
		de_crcobj_destroy(d->crco);
		de_free(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
movl $0x58, %esi
callq 0xe969b
movq %rax, %r12
leaq 0xa1f69(%rip), %rsi     # 0x12d7a1
movq %rbx, %rdi
xorl %edx, %edx
callq 0xea727
testl %eax, %eax
je 0x8b84c
movb $0x1, 0x8(%r12)
leaq 0xa1f5e(%rip), %rsi     # 0x12d7b1
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xea727
movl %eax, 0xc(%r12)
leaq 0xa1f59(%rip), %rsi     # 0x12d7c5
movq %rbx, %rdi
callq 0xea6cb
testq %rax, %rax
je 0x8b88e
movb $0x1, 0x9(%r12)
movq %rax, %rdi
callq 0xea781
cltq
movq %rax, 0x10(%r12)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xeb7d1
testl %eax, %eax
movl $0x2, %ecx
cmovnel %eax, %ecx
movl %eax, (%r12)
movl %ecx, 0x4(%r12)
movq $0x800, 0x18(%r12)      # imm = 0x800
movq 0x18(%rbx), %rdi
leaq 0xa1e3b(%rip), %rdx     # 0x12d6fc
movl $0x200, %esi            # imm = 0x200
movl $0x4, %ecx
callq 0xf025e
testl %eax, %eax
jne 0x8b8e5
leaq 0xa1efa(%rip), %rsi     # 0x12d7d5
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9ef5
movq %rbx, %rdi
callq 0xeb85a
movq %rax, 0x40(%r12)
movl $0x10, %r15d
movq %r12, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x14(%rsp), %rsi
callq 0xe958c
movq 0x18(%r12), %r13
imulq %r15, %r13
movq 0x18(%rbx), %rdi
leaq 0x4(%r13), %rsi
callq 0xef32a
movb $0x1, %cl
cmpq %rax, %r15
jne 0x8b945
movq 0x18(%rbx), %rdi
leaq 0x9(%r13), %rsi
movl $0x5, %ecx
leaq 0xa2048(%rip), %rdx     # 0x12d983
callq 0xf025e
testl %eax, %eax
setne %cl
leaq 0x8(%r13), %rax
testb %cl, %cl
cmovneq %r13, %rax
movq %rax, 0x30(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x30(%rsp), %r14
movq %r14, %rsi
callq 0xef14d
movl %eax, %ebp
movq 0x18(%rbx), %rdi
movq 0x30(%rsp), %rsi
movl $0x5, %edx
movl $0x5, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xefe67
movq %rax, %r12
addq $0x5, 0x30(%rsp)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xef14d
movb %al, 0xf(%rsp)
movq %r12, 0x28(%rsp)
movq 0x8(%r12), %r14
movq %r14, %rdi
leaq 0xa2b0a(%rip), %rsi     # 0x12e4bf
callq 0x181a0
testl %eax, %eax
movb %bpl, 0xe(%rsp)
je 0x8ba9f
movq %r14, %rdi
leaq 0xa1fac(%rip), %rsi     # 0x12d97d
callq 0x181a0
testl %eax, %eax
je 0x8bac9
movl $0x4, %edx
movq %r14, %rdi
leaq 0xa1ed9(%rip), %rsi     # 0x12d8c6
callq 0x18050
movb $0x1, %r12b
testl %eax, %eax
je 0x8badf
movl $0x4, %edx
movq %r14, %rdi
leaq 0xa1ebf(%rip), %rsi     # 0x12d8cb
callq 0x18050
testl %eax, %eax
je 0x8bb05
movl $0x4, %edx
movq %r14, %rdi
leaq 0xa1ea8(%rip), %rsi     # 0x12d8d0
callq 0x18050
movb $0x1, %r12b
testl %eax, %eax
je 0x8bd99
movl $0x4, %edx
movq %r14, %rdi
leaq 0xa1e8e(%rip), %rsi     # 0x12d8d5
callq 0x18050
movl $0x1, %ebp
testl %eax, %eax
je 0x8bb2a
movl $0x4, %edx
movq %r14, %rdi
leaq 0xa1e72(%rip), %rsi     # 0x12d8da
callq 0x18050
xorl %ecx, %ecx
testl %eax, %eax
je 0x8bb2c
movq %r14, %rdi
leaq 0xa1f02(%rip), %rsi     # 0x12d983
callq 0x181a0
movb $0x1, %r12b
testl %eax, %eax
je 0x8bdaa
xorl %ecx, %ecx
movb $0x1, %al
xorl %r14d, %r14d
xorl %ebp, %ebp
jmp 0x8bb31
movzbl %bpl, %eax
movb $0x1, %r12b
cmpb $0x3, %bpl
ja 0x8bae6
leaq 0xa1c15(%rip), %rcx     # 0x12d6c8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x5, %ebp
xorl %eax, %eax
movb 0xe(%rsp), %cl
jmp 0x8bb15
movb $0x1, %r12b
cmpb $0x1, %bpl
je 0x8bb0c
movzbl %bpl, %eax
cmpl $0xff, %eax
je 0x8baed
jmp 0x8bafe
movl $0xa, %ebp
jmp 0x8bb2a
cmpl $0xff, %eax
jne 0x8bafe
movl $0x7, %ebp
xorl %ecx, %ecx
xorl %eax, %eax
xorl %r14d, %r14d
xorl %r12d, %r12d
jmp 0x8bb31
movl $0x1, %ebp
jmp 0x8bb2a
movl $0x8, %ebp
jmp 0x8bb2a
movl %ebp, %ecx
movl $0x2, %ebp
xorl %eax, %eax
jmp 0x8bb2e
movl $0x4, %ebp
jmp 0x8bb2a
movl $0x6, %ebp
jmp 0x8bb2a
movl $0x2, %ebp
xorl %ecx, %ecx
xorl %eax, %eax
xorl %r14d, %r14d
testb %al, %al
jne 0x8bdcf
movl %ecx, 0x10(%rsp)
movq %rbx, %rdi
leaq 0xa1dc4(%rip), %rsi     # 0x12d90b
movq %r13, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movzbl 0xe(%rsp), %edx
movq %rbx, %rdi
leaq 0xa5dd5(%rip), %rsi     # 0x131945
xorl %eax, %eax
callq 0xe9226
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xf7557
movq %rbx, %rdi
leaq 0xa1da1(%rip), %rsi     # 0x12d930
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movzbl 0xf(%rsp), %edx
movq %rbx, %rdi
leaq 0xaae12(%rip), %rsi     # 0x1369ba
xorl %eax, %eax
callq 0xe9226
movl %ebp, %eax
leaq 0xa1b78(%rip), %rcx     # 0x12d730
movslq -0x4(%rcx,%rax,4), %rdx
addq %rcx, %rdx
movq %rbx, %rdi
leaq 0xa1d78(%rip), %rsi     # 0x12d942
xorl %eax, %eax
callq 0xe9226
orb %r14b, %r12b
je 0x8bbe1
xorb $0x1, %r14b
movq 0x20(%rsp), %r12
jmp 0x8bc0e
movq 0x18(%rbx), %rdi
leaq 0x1(%r15), %rsi
movq 0x20(%rsp), %r12
imulq 0x18(%r12), %rsi
incq %rsi
movl $0x4, %ecx
leaq 0xa1cc8(%rip), %rdx     # 0x12d8cb
callq 0xf025e
testl %eax, %eax
sete %r14b
addl $-0x2, %ebp
cmpl $0x8, %ebp
ja 0x8bd61
leaq 0xa1ab7(%rip), %rcx     # 0x12d6d8
movslq (%rcx,%rbp,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, (%rsp)
movzbl 0x10(%rsp), %r9d
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %rcx
movl $0x1, %r8d
jmp 0x8bd5a
movl $0x0, (%rsp)
movzbl 0x10(%rsp), %r9d
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
jmp 0x8bd5a
addq $0x7, %r13
movq %r13, 0x18(%rsp)
movq %rbx, %rdi
callq 0xf6870
movq %rax, %rbp
movq 0x18(%rbx), %rdi
movq 0x18(%rsp), %rsi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0xefe67
movq %rax, %r13
addq $0x20, 0x18(%rsp)
movq 0x18(%rax), %rdi
callq 0xf74bd
movq %rbx, %rdi
leaq 0xa1dca(%rip), %rsi     # 0x12da8d
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movl $0x20, %r8d
movq %rbx, %rdi
xorl %esi, %esi
leaq 0xa1dc3(%rip), %rdx     # 0x12daa2
leaq 0x18(%rsp), %rcx
movq %rbp, %r9
callq 0x8dfe7
movq 0x8(%r13), %rdi
leaq 0xa1db3(%rip), %rsi     # 0x12daaa
callq 0x181a0
testl %eax, %eax
jne 0x8bd21
movq 0x18(%rbx), %rdi
leaq 0x18(%rsp), %rsi
callq 0xef3a0
movq %rbx, %rdi
leaq 0xa1daa(%rip), %rsi     # 0x12dac2
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbp, %rdi
callq 0xf6bb0
movq %rbx, %rdi
movq %r13, %rsi
callq 0xf00aa
jmp 0x8bd72
movb $0x1, 0xb(%r12)
jmp 0x8bd72
movl $0x1, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %r13, %rcx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x8d78a
jmp 0x8bd72
movq %rbx, %rdi
leaq 0xa1bec(%rip), %rsi     # 0x12d957
xorl %eax, %eax
callq 0xe9226
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0xf00aa
incq %r15
testb %r14b, %r14b
jne 0x8b8fd
jmp 0x8be01
movl $0x9, %ebp
xorl %ecx, %ecx
xorl %eax, %eax
movb $0x1, %r14b
jmp 0x8bb31
movb 0xe(%rsp), %al
cmpb $0x1, %al
je 0x8bdc5
movzbl %al, %eax
cmpl $0xff, %eax
je 0x8baed
jmp 0x8bb2a
movl $0x3, %ebp
jmp 0x8bb2a
leaq 0xa1b09(%rip), %rsi     # 0x12d8df
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9b27
movl 0x14(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0xf00aa
movq 0x20(%rsp), %r12
cmpb $0x0, 0xb(%r12)
je 0x8be1a
leaq 0xa1a0f(%rip), %rsi     # 0x12d81f
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9b27
movq 0x48(%r12), %rax
testq %rax, %rax
je 0x8be90
movl (%rax), %edx
leaq 0xa1a57(%rip), %rsi     # 0x12d884
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x48(%r12), %rax
movq 0x18(%rax), %rdx
cmpq $0x800, %rdx            # imm = 0x800
jne 0x8bea3
movq %rbx, %rdi
callq 0xeb85a
movq %rax, 0x38(%r12)
movl $0x2a, %esi
movq %rbx, %rdi
callq 0xf7666
movq %rax, 0x30(%r12)
movq 0x48(%r12), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
je 0x8beb4
imulq 0x18(%r12), %rdx
movq 0x10(%rax), %rcx
movq %rbx, %rdi
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x8c418
jmp 0x8beb4
leaq 0xa19cb(%rip), %rsi     # 0x12d862
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0x8beb4
leaq 0xa1a01(%rip), %rsi     # 0x12d8ab
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq 0x48(%r12), %rsi
movq %rbx, %rdi
callq 0xe9752
movq 0x30(%r12), %rdi
callq 0xf7689
movq 0x38(%r12), %rsi
movq %rbx, %rdi
callq 0xeb864
movq 0x40(%r12), %rsi
movq %rbx, %rdi
callq 0xeb864
movq 0x50(%r12), %rdi
callq 0xebe1d
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe9752
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq