// File: /workspace/github_c_makefile_star2_O3/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 $0x48, %rsp
movq %rdi, %rbx
movl $0x58, %esi
callq 0xe8b2b
movq %rax, %r14
leaq 0xa29ed(%rip), %rsi     # 0x12da99
movq %rbx, %rdi
xorl %edx, %edx
callq 0xe9bd0
testl %eax, %eax
je 0x8b0bf
movb $0x1, 0x8(%r14)
leaq 0xa29e3(%rip), %rsi     # 0x12daa9
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xe9bd0
movl %eax, 0xc(%r14)
leaq 0xa29df(%rip), %rsi     # 0x12dabd
movq %rbx, %rdi
callq 0xe9b74
testq %rax, %rax
je 0x8b0fe
movb $0x1, 0x9(%r14)
movq %rax, %rdi
callq 0xe9c2a
cltq
movq %rax, 0x10(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xeb220
testl %eax, %eax
movl $0x2, %ecx
cmovnel %eax, %ecx
movl %eax, (%r14)
movl %ecx, 0x4(%r14)
movq $0x800, 0x18(%r14)      # imm = 0x800
movq 0x18(%rbx), %rdi
leaq 0xa28b6(%rip), %rdx     # 0x12d9e4
movl $0x200, %esi            # imm = 0x200
movl $0x4, %ecx
callq 0xefc85
testl %eax, %eax
jne 0x8b152
leaq 0xa2985(%rip), %rsi     # 0x12dacd
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9393
movq %rbx, %rdi
callq 0xeb2a9
movq %rax, 0x40(%r14)
movl $0x10, %r15d
movq %r14, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x1c(%rsp), %rsi
callq 0xe8a1c
movq 0x18(%r14), %r12
imulq %r15, %r12
movq 0x18(%rbx), %rdi
leaq 0x4(%r12), %rsi
callq 0xeed0d
cmpq %rax, %r15
jne 0x8b1b3
movq 0x18(%rbx), %rdi
leaq 0x9(%r12), %rsi
movl $0x5, %ecx
leaq 0xa2ad5(%rip), %rdx     # 0x12dc7b
callq 0xefc85
testl %eax, %eax
je 0x8b360
movq %r12, %rax
movq %rax, 0x38(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x38(%rsp), %r14
movq %r14, %rsi
callq 0xeeb4b
movl %eax, %ebp
movq 0x18(%rbx), %rdi
movq 0x38(%rsp), %rsi
movl $0x5, %edx
movl $0x5, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xef87c
movq %rax, %r13
addq $0x5, 0x38(%rsp)
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeeb4b
movb %al, 0x1b(%rsp)
movq %r13, 0x30(%rsp)
movq 0x8(%r13), %r13
movq %r13, %rdi
leaq 0xa359c(%rip), %rsi     # 0x12e7b7
callq 0x181a0
movzbl %bpl, %edx
testl %eax, %eax
movq %rdx, 0x28(%rsp)
je 0x8b314
movq %r13, %rdi
leaq 0xa2a3a(%rip), %rsi     # 0x12dc75
callq 0x181a0
testl %eax, %eax
je 0x8b338
movl $0x4, %edx
movq %r13, %rdi
leaq 0xa2967(%rip), %rsi     # 0x12dbbe
callq 0x18050
movb $0x1, %r14b
testl %eax, %eax
je 0x8b36a
movl $0x4, %edx
movq %r13, %rdi
leaq 0xa294d(%rip), %rsi     # 0x12dbc3
callq 0x18050
testl %eax, %eax
je 0x8b380
movl $0x4, %edx
movq %r13, %rdi
leaq 0xa2936(%rip), %rsi     # 0x12dbc8
callq 0x18050
movb $0x1, %r14b
testl %eax, %eax
je 0x8b60c
movl %ebp, 0x14(%rsp)
movl $0x4, %edx
movq %r13, %rdi
leaq 0xa2918(%rip), %rsi     # 0x12dbcd
callq 0x18050
movl $0x1, %ebp
testl %eax, %eax
je 0x8b3a5
movl $0x4, %edx
movq %r13, %rdi
leaq 0xa28fc(%rip), %rsi     # 0x12dbd2
callq 0x18050
testl %eax, %eax
je 0x8b3a5
movq %r13, %rdi
leaq 0xa298e(%rip), %rsi     # 0x12dc7b
callq 0x181a0
testl %eax, %eax
jne 0x8b62b
cmpb $0x1, 0x14(%rsp)
je 0x8b621
cmpl $0xff, 0x28(%rsp)
je 0x8b34b
jmp 0x8b3a5
movb $0x1, %r14b
cmpb $0x3, %bpl
ja 0x8b371
leaq 0xa268c(%rip), %rcx     # 0x12d9b0
movslq (%rcx,%rdx,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %ebp, 0x14(%rsp)
movl $0x5, %ebp
jmp 0x8b3ad
movb $0x1, %r14b
cmpb $0x1, %bpl
je 0x8b387
cmpl $0xff, 0x28(%rsp)
jne 0x8b379
movl $0x7, %ebp
movl $0x0, 0x14(%rsp)
xorl %r13d, %r13d
xorl %r14d, %r14d
jmp 0x8b3b0
leaq 0x8(%r12), %rax
jmp 0x8b1b6
movl $0xa, %ebp
jmp 0x8b3a5
cmpl $0xff, %edx
je 0x8b34b
movl $0x1, %ebp
jmp 0x8b3a5
movl $0x8, %ebp
jmp 0x8b3a5
movl %ebp, 0x14(%rsp)
movl $0x2, %ebp
jmp 0x8b3ad
movl $0x4, %ebp
jmp 0x8b3a5
movl $0x6, %ebp
jmp 0x8b3a5
movl $0x2, %ebp
movl $0x0, 0x14(%rsp)
xorl %r13d, %r13d
movq %rbx, %rdi
leaq 0xa2849(%rip), %rsi     # 0x12dc03
movq %r12, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq %rbx, %rdi
leaq 0xa68eb(%rip), %rsi     # 0x131cc9
movq 0x28(%rsp), %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x30(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xf70f6
movq %rbx, %rdi
leaq 0xa2826(%rip), %rsi     # 0x12dc28
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movzbl 0x1b(%rsp), %edx
movq %rbx, %rdi
leaq 0xab969(%rip), %rsi     # 0x136d84
xorl %eax, %eax
callq 0xe8617
movl %ebp, %eax
leaq 0xa25ed(%rip), %rcx     # 0x12da18
movslq -0x4(%rcx,%rax,4), %rdx
addq %rcx, %rdx
movq %rbx, %rdi
leaq 0xa27fd(%rip), %rsi     # 0x12dc3a
xorl %eax, %eax
callq 0xe8617
orb %r13b, %r14b
je 0x8b454
xorb $0x1, %r13b
movq 0x20(%rsp), %r14
jmp 0x8b480
movq 0x18(%rbx), %rdi
leaq 0x1(%r15), %rsi
movq 0x20(%rsp), %r14
imulq 0x18(%r14), %rsi
incq %rsi
movl $0x4, %ecx
leaq 0xa274e(%rip), %rdx     # 0x12dbc3
callq 0xefc85
testl %eax, %eax
sete %r13b
addl $-0x2, %ebp
cmpl $0x8, %ebp
ja 0x8b5d4
leaq 0xa252d(%rip), %rcx     # 0x12d9c0
movslq (%rcx,%rbp,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, (%rsp)
movzbl 0x14(%rsp), %r9d
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl $0x1, %r8d
jmp 0x8b5cd
movl $0x0, (%rsp)
movzbl 0x14(%rsp), %r9d
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
jmp 0x8b5cd
leaq 0x7(%r12), %rbp
movq %rbx, %rdi
callq 0xf6410
movq %rax, %r14
movq 0x18(%rbx), %rdi
movl $0x20, %edx
movl $0x20, %ecx
movq %rbp, %rsi
movl $0x1, %r8d
movl $0x1, %r9d
callq 0xef87c
movq %rax, %rbp
addq $0x27, %r12
movq %r12, 0x40(%rsp)
movq 0x18(%rax), %rdi
callq 0xf705c
movq %rbx, %rdi
leaq 0xa2853(%rip), %rsi     # 0x12dd85
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movl $0x20, %r8d
movq %rbx, %rdi
xorl %esi, %esi
leaq 0xa284c(%rip), %rdx     # 0x12dd9a
leaq 0x40(%rsp), %rcx
movq %r14, %r9
callq 0x8d6f0
movq 0x8(%rbp), %rdi
leaq 0xa283c(%rip), %rsi     # 0x12dda2
callq 0x181a0
testl %eax, %eax
jne 0x8b590
movq 0x18(%rbx), %rdi
leaq 0x40(%rsp), %rsi
callq 0xeed83
movq %rbx, %rdi
leaq 0xa2833(%rip), %rsi     # 0x12ddba
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
callq 0xf6753
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xefaca
movq 0x20(%rsp), %r14
jmp 0x8b5e5
movb $0x1, 0xb(%r14)
jmp 0x8b5e5
movl $0x1, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x8ceb9
jmp 0x8b5e5
movq %rbx, %rdi
leaq 0xa2671(%rip), %rsi     # 0x12dc4f
xorl %eax, %eax
callq 0xe8617
movl 0x1c(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0xefaca
incq %r15
testb %r13b, %r13b
jne 0x8b169
jmp 0x8b65d
movl $0x9, %ebp
movl $0x0, 0x14(%rsp)
movb $0x1, %r13b
jmp 0x8b3b0
movl $0x3, %ebp
jmp 0x8b3a5
leaq 0xa25a5(%rip), %rsi     # 0x12dbd7
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8faa
movl 0x1c(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq %rbx, %rdi
movq 0x30(%rsp), %rsi
callq 0xefaca
movq 0x20(%rsp), %r14
cmpb $0x0, 0xb(%r14)
je 0x8b675
leaq 0xa24ac(%rip), %rsi     # 0x12db17
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8faa
movq 0x48(%r14), %rax
testq %rax, %rax
je 0x8b6e5
movl (%rax), %edx
leaq 0xa24f5(%rip), %rsi     # 0x12db7c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x48(%r14), %rax
movq 0x18(%rax), %rdx
cmpq $0x800, %rdx            # imm = 0x800
jne 0x8b6f8
movq %rbx, %rdi
callq 0xeb2a9
movq %rax, 0x38(%r14)
movl $0x2a, %esi
movq %rbx, %rdi
callq 0xf7205
movq %rax, 0x30(%r14)
movq 0x48(%r14), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
je 0x8b709
imulq 0x18(%r14), %rdx
movq 0x10(%rax), %rcx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r8d, %r8d
callq 0x8bc27
jmp 0x8b709
leaq 0xa246e(%rip), %rsi     # 0x12db5a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
jmp 0x8b709
leaq 0xa24a4(%rip), %rsi     # 0x12dba3
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq 0x48(%r14), %rsi
movq %rbx, %rdi
callq 0xe8be2
movq 0x30(%r14), %rdi
callq 0xf7228
movq 0x38(%r14), %rsi
movq %rbx, %rdi
callq 0xeb2b3
movq 0x40(%r14), %rsi
movq %rbx, %rdi
callq 0xeb2b3
movq 0x50(%r14), %rdi
callq 0xeb858
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe8be2
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq