// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x58
popq %rsi
callq 0xdecaf
movq %rax, %r14
leaq 0x9a82b(%rip), %rsi     # 0x120829
movq %rbx, %rdi
xorl %edx, %edx
callq 0xdfae5
testl %eax, %eax
je 0x86011
movb $0x1, 0x8(%r14)
leaq 0x9a821(%rip), %rsi     # 0x120839
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0xdfae5
movl %eax, 0xc(%r14)
leaq 0x9a81f(%rip), %rsi     # 0x12084d
movq %rbx, %rdi
callq 0xdfa87
testq %rax, %rax
je 0x8604e
movb $0x1, 0x9(%r14)
movq %rax, %rdi
callq 0xdfb36
cltq
movq %rax, 0x10(%r14)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xe08d2
movl %eax, (%r14)
testl %eax, %eax
pushq $0x2
popq %rcx
cmovel %ecx, %eax
movl %eax, 0x4(%r14)
movq $0x800, 0x18(%r14)      # imm = 0x800
movq 0x18(%rbx), %rdi
leaq 0x9a6f8(%rip), %rdx     # 0x120774
pushq $0x4
popq %rcx
movl $0x200, %esi            # imm = 0x200
callq 0xe4d48
testl %eax, %eax
jne 0x8609e
leaq 0x9a7c9(%rip), %rsi     # 0x12085d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf37f
movq %rbx, %rdi
callq 0xe0955
movq %rax, 0x40(%r14)
pushq $0x10
popq %r15
movq %r14, 0x18(%rsp)
movq %rbx, %rdi
leaq 0x24(%rsp), %rsi
callq 0xdebae
movq 0x18(%r14), %rbp
imulq %r15, %rbp
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0x884d4
cmpq %rax, %r15
jne 0x860f8
movq 0x18(%rbx), %rdi
leaq 0x9(%rbp), %rsi
leaq 0x9a923(%rip), %rdx     # 0x120a0b
pushq $0x5
popq %rcx
callq 0xe4d48
testl %eax, %eax
je 0x86286
movq %rbp, %rax
movq %rax, 0x30(%rsp)
movq 0x18(%rbx), %rdi
leaq 0x30(%rsp), %r13
movq %r13, %rsi
callq 0xe3f2a
movl %eax, %r12d
movq 0x18(%rbx), %rdi
movq 0x30(%rsp), %rsi
pushq $0x5
popq %rcx
movq %rcx, %rdx
xorl %r8d, %r8d
pushq $0x1
popq %r9
callq 0xe495c
movq %rax, %r14
addq $0x5, 0x30(%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3f2a
movb %al, 0xf(%rsp)
movq %r14, 0x28(%rsp)
movq 0x8(%r14), %r13
movq %r13, %rdi
leaq 0x9b3ec(%rip), %rsi     # 0x121547
callq 0x181a0
movzbl %r12b, %r14d
testl %eax, %eax
movq %r14, 0x40(%rsp)
je 0x86242
movq %r13, %rdi
leaq 0x9a88a(%rip), %rsi     # 0x120a05
callq 0x181a0
testl %eax, %eax
je 0x86265
movq %r13, %rdi
leaq 0x9a7bc(%rip), %rsi     # 0x12094e
pushq $0x4
popq %rdx
callq 0x18050
movb $0x1, %cl
movl %ecx, 0x10(%rsp)
testl %eax, %eax
je 0x8628f
movq %r13, %rdi
leaq 0x9a7a1(%rip), %rsi     # 0x120953
pushq $0x4
popq %rdx
callq 0x18050
testl %eax, %eax
je 0x862a9
movq %r13, %rdi
leaq 0x9a78c(%rip), %rsi     # 0x120958
pushq $0x4
popq %rdx
callq 0x18050
movb $0x1, %cl
movl %ecx, 0x10(%rsp)
testl %eax, %eax
je 0x862d9
movq %r13, %rdi
leaq 0x9a771(%rip), %rsi     # 0x12095d
pushq $0x4
popq %rdx
callq 0x18050
testl %eax, %eax
je 0x8629f
movq %r13, %rdi
leaq 0x9a75c(%rip), %rsi     # 0x120962
pushq $0x4
popq %rdx
callq 0x18050
testl %eax, %eax
je 0x8629f
movq %r13, %rdi
leaq 0x9a7eb(%rip), %rsi     # 0x120a0b
callq 0x181a0
testl %eax, %eax
jne 0x86543
cmpb $0x1, %r12b
je 0x86536
cmpl $0xff, %r14d
je 0x86274
jmp 0x8629f
cmpb $0x3, %r12b
ja 0x8626b
movb $0x1, %al
movl %eax, 0x10(%rsp)
leaq 0x9a4eb(%rip), %rcx     # 0x120740
movslq (%rcx,%r14,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %r13d, %r13d
pushq $0x5
jmp 0x862e1
cmpb $0x1, %r12b
je 0x862b3
cmpl $0xff, %r14d
jne 0x86299
xorl %r12d, %r12d
xorl %r13d, %r13d
movl $0x0, 0x10(%rsp)
pushq $0x7
jmp 0x862e1
leaq 0x8(%rbp), %rax
jmp 0x860fb
xorl %r12d, %r12d
xorl %r13d, %r13d
pushq $0xa
jmp 0x862e1
movb $0x1, %al
movl %eax, 0x10(%rsp)
xorl %r12d, %r12d
xorl %r13d, %r13d
pushq $0x1
jmp 0x862e1
xorl %r12d, %r12d
xorl %r13d, %r13d
pushq $0x8
jmp 0x862e1
movb $0x1, %al
movl %eax, 0x10(%rsp)
jmp 0x862d2
xorl %r12d, %r12d
xorl %r13d, %r13d
pushq $0x4
jmp 0x862e1
xorl %r12d, %r12d
xorl %r13d, %r13d
pushq $0x6
jmp 0x862e1
xorl %r12d, %r12d
xorl %r13d, %r13d
pushq $0x2
jmp 0x862e1
xorl %r12d, %r12d
movb $0x1, %r13b
pushq $0x9
popq %rax
movl %eax, %r14d
movq %rbx, %rdi
leaq 0x9a6a4(%rip), %rsi     # 0x120993
movq %rbp, %rdx
movl %r15d, %ecx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq %rbx, %rdi
leaq 0x9e6cc(%rip), %rsi     # 0x1249dd
movq 0x40(%rsp), %rdx
xorl %eax, %eax
callq 0xde896
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0x9a683(%rip), %rsi     # 0x1209b8
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movzbl 0xf(%rsp), %edx
movq %rbx, %rdi
leaq 0xa3736(%rip), %rsi     # 0x129a84
xorl %eax, %eax
callq 0xde896
movl %r14d, %eax
leaq 0x9a449(%rip), %rcx     # 0x1207a8
movslq -0x4(%rcx,%rax,4), %rdx
addq %rcx, %rdx
movq %rbx, %rdi
leaq 0x9a659(%rip), %rsi     # 0x1209ca
xorl %eax, %eax
callq 0xde896
movl 0x10(%rsp), %eax
orb %r13b, %al
je 0x86387
xorb $0x1, %r13b
jmp 0x863b1
movq 0x18(%rbx), %rdi
leaq 0x1(%r15), %rsi
movq 0x18(%rsp), %rax
imulq 0x18(%rax), %rsi
incq %rsi
leaq 0x9a5b0(%rip), %rdx     # 0x120953
pushq $0x4
popq %rcx
callq 0xe4d48
testl %eax, %eax
sete %r13b
addl $-0x2, %r14d
cmpl $0x8, %r14d
ja 0x864f9
leaq 0x9a38a(%rip), %rcx     # 0x120750
movslq (%rcx,%r14,4), %rax
addq %rcx, %rax
movzbl %r12b, %r9d
jmpq *%rax
andl $0x0, (%rsp)
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %rbp, %rcx
pushq $0x1
popq %r8
jmp 0x864f2
andl $0x0, (%rsp)
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %rbp, %rcx
xorl %r8d, %r8d
jmp 0x864f2
leaq 0x7(%rbp), %r12
movq %rbx, %rdi
callq 0xeac74
movq %rax, 0x10(%rsp)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
pushq $0x20
popq %r14
movq %r14, %rdx
movq %r14, %rcx
pushq $0x1
popq %r8
movl %r8d, %r9d
callq 0xe495c
movq %rax, %r12
addq $0x27, %rbp
movq %rbp, 0x38(%rsp)
movq 0x18(%rax), %rdi
callq 0xeb7e4
movq %rbx, %rdi
leaq 0x9a6c0(%rip), %rsi     # 0x120b15
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
xorl %esi, %esi
leaq 0x9a6bf(%rip), %rdx     # 0x120b2a
leaq 0x38(%rsp), %rcx
movq %r14, %r8
movq 0x10(%rsp), %r14
movq %r14, %r9
callq 0x884dd
movq 0x8(%r12), %rdi
leaq 0x9a6a6(%rip), %rsi     # 0x120b32
callq 0x181a0
testl %eax, %eax
jne 0x864b6
movq 0x18(%rbx), %rdi
leaq 0x38(%rsp), %rsi
callq 0xe40bf
movq %rbx, %rdi
leaq 0x9a69d(%rip), %rsi     # 0x120b4a
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
callq 0xeaf3c
movq %rbx, %rdi
movq %r12, %rsi
callq 0xe4b94
jmp 0x8650a
movq 0x18(%rsp), %rax
movb $0x1, 0xb(%rax)
jmp 0x8650a
movl $0x1, (%rsp)
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r15, %rdx
movq %rbp, %rcx
pushq $0x1
popq %r8
xorl %r9d, %r9d
callq 0x87d07
jmp 0x8650a
movq %rbx, %rdi
leaq 0x9a4dc(%rip), %rsi     # 0x1209df
xorl %eax, %eax
callq 0xde896
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0xe4b94
incq %r15
testb %r13b, %r13b
movq 0x18(%rsp), %r14
jne 0x860b3
jmp 0x86575
xorl %r12d, %r12d
xorl %r13d, %r13d
pushq $0x3
jmp 0x862e1
leaq 0x9a41d(%rip), %rsi     # 0x120967
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xdf05a
movl 0x24(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
callq 0xe4b94
movq 0x18(%rsp), %r14
cmpb $0x0, 0xb(%r14)
je 0x8658d
leaq 0x9a324(%rip), %rsi     # 0x1208a7
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf05a
movq 0x48(%r14), %rax
testq %rax, %rax
je 0x865fb
movl (%rax), %edx
leaq 0x9a36d(%rip), %rsi     # 0x12090c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x48(%r14), %rax
movq 0x18(%rax), %rdx
cmpq $0x800, %rdx            # imm = 0x800
jne 0x8660e
movq %rbx, %rdi
callq 0xe0955
movq %rax, 0x38(%r14)
pushq $0x2a
popq %rsi
movq %rbx, %rdi
callq 0xeb95d
movq %rax, 0x30(%r14)
movq 0x48(%r14), %rax
movq 0x8(%rax), %rdx
testq %rdx, %rdx
je 0x8661f
imulq 0x18(%r14), %rdx
movq 0x10(%rax), %rcx
movq %rbx, %rdi
movq %r14, %rsi
xorl %r8d, %r8d
callq 0x86af4
jmp 0x8661f
leaq 0x9a2e8(%rip), %rsi     # 0x1208ea
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0x8661f
leaq 0x9a31e(%rip), %rsi     # 0x120933
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq 0x48(%r14), %rsi
movq %rbx, %rdi
callq 0xded32
movq 0x30(%r14), %rdi
callq 0xeb97e
movq 0x38(%r14), %rsi
movq %rbx, %rdi
callq 0xe095f
movq 0x40(%r14), %rsi
movq %rbx, %rdi
callq 0xe095f
movq 0x50(%r14), %rdi
callq 0xe0e8d
movq %rbx, %rdi
movq %r14, %rsi
callq 0xded32
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq