// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/iso9660.c
// Function: do_dir_rec_system_use_area
static void do_dir_rec_system_use_area(deark *c, lctx *d, struct dir_record *dr,
	i64 pos1, i64 len)
{
	i64 pos = pos1;
	int non_SUSP_handled = 0;
	i64 non_SUSP_len = len; // default
	i64 SUSP_len = 0; // default

	de_dbg(c, "[%"I64_FMT" bytes of system use data at %"I64_FMT"]", len, pos1);

	if(dr->is_root_dot) {
		if(is_SUSP_indicator(c, pos, len)) {
			d->vol->uses_SUSP = 1;
			non_SUSP_len = 0;
			SUSP_len = len;
		}
	}
	else if(d->vol->uses_SUSP) {
		non_SUSP_len = d->vol->SUSP_default_bytes_to_skip;
		SUSP_len = len - d->vol->SUSP_default_bytes_to_skip;
	}

	if(non_SUSP_len>0) {
		u8 buf[10];

		// TODO: Detect & handle more non-SUSP formats here.
		// - Apple AA/ProDOS
		// - Apple BA

		de_zeromem(buf, sizeof(buf));
		de_read(buf, pos, de_min_int(sizeof(buf), non_SUSP_len));

		if(d->vol->is_cdxa && non_SUSP_len>=14 && buf[6]=='X' && buf[7]=='A') {
			do_CDXA_dirdata(c, d, dr, pos);
			non_SUSP_handled = 1;
		}
		else if(non_SUSP_len>=14 && buf[0]=='A' && buf[1]=='A' && buf[2]==0x0e &&
			buf[3]==0x02)
		{
			// TODO: Support XA + AA
			do_Apple_AA_HFS(c, d, dr, pos, non_SUSP_len);
			non_SUSP_handled = 1;
		}
		else if(non_SUSP_len>=10 && !de_memcmp(buf, "ARCHIMEDES", 10)) {
			do_ARCHIMEDES(c, d, dr, pos, non_SUSP_len);
			non_SUSP_handled = 1;
		}
	}

	if(non_SUSP_len>0 && !non_SUSP_handled) {
		de_dbg(c, "[unidentified system use data]");
		if(c->debug_level>=2) {
			de_dbg_indent(c, 1);
			de_dbg_hexdump(c, c->infile, pos, non_SUSP_len, 256, NULL, 0x1);
			de_dbg_indent(c, -1);
		}
	}

	if(d->vol->uses_SUSP && SUSP_len>0) {
		do_dir_rec_SUSP(c, d, dr, pos+non_SUSP_len, SUSP_len);
	}
	// TODO?: There can potentially also be non-SUSP data *after* the SUSP data,
	// but I don't know if we need to worry about that.
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0xeaf69(%rip), %rsi     # 0x1b9e7a
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x4(%rax)
je 0xcef56
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xcf550
cmpl $0x0, %eax
je 0xcef54
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movb $0x1, 0x2a(%rax)
movq $0x0, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0xcef8a
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpb $0x0, 0x2a(%rax)
je 0xcef88
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x30(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
subq 0x30(%rcx), %rax
movq %rax, -0x48(%rbp)
jmp 0xcef8a
cmpq $0x0, -0x40(%rbp)
jle 0xcf0c2
leaq -0x52(%rbp), %rdi
xorl %esi, %esi
movl $0xa, %edx
callq 0x19140
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
leaq -0x52(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x40(%rbp), %rsi
movl $0xa, %edi
callq 0x15ccf0
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %rax, %rcx
callq 0x164d10
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movzbl 0x26(%rax), %eax
cmpl $0x0, %eax
je 0xcf02e
cmpq $0xe, -0x40(%rbp)
jl 0xcf02e
movzbl -0x4c(%rbp), %eax
cmpl $0x58, %eax
jne 0xcf02e
movzbl -0x4b(%rbp), %eax
cmpl $0x41, %eax
jne 0xcf02e
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0xcf5d0
movl $0x1, -0x34(%rbp)
jmp 0xcf0c0
cmpq $0xe, -0x40(%rbp)
jl 0xcf07b
movzbl -0x52(%rbp), %eax
cmpl $0x41, %eax
jne 0xcf07b
movzbl -0x51(%rbp), %eax
cmpl $0x41, %eax
jne 0xcf07b
movzbl -0x50(%rbp), %eax
cmpl $0xe, %eax
jne 0xcf07b
movzbl -0x4f(%rbp), %eax
cmpl $0x2, %eax
jne 0xcf07b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %r8
callq 0xcf650
movl $0x1, -0x34(%rbp)
jmp 0xcf0be
cmpq $0xa, -0x40(%rbp)
jl 0xcf0bc
leaq -0x52(%rbp), %rdi
leaq 0xeae13(%rip), %rsi     # 0x1b9ea0
movl $0xa, %edx
callq 0x19170
cmpl $0x0, %eax
jne 0xcf0bc
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %r8
callq 0xcf790
movl $0x1, -0x34(%rbp)
jmp 0xcf0be
jmp 0xcf0c0
jmp 0xcf0c2
cmpq $0x0, -0x40(%rbp)
jle 0xcf133
cmpl $0x0, -0x34(%rbp)
jne 0xcf133
movq -0x8(%rbp), %rdi
leaq 0xeadd1(%rip), %rsi     # 0x1b9eab
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
cmpl $0x2, (%rax)
jl 0xcf131
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x30(%rbp), %rdx
movq -0x40(%rbp), %rcx
movl $0x100, %r8d            # imm = 0x100
xorl %eax, %eax
movl %eax, %r9d
movl $0x1, (%rsp)
callq 0x15b840
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
jmp 0xcf133
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movzbl 0x2a(%rax), %eax
cmpl $0x0, %eax
je 0xcf168
cmpq $0x0, -0x48(%rbp)
jle 0xcf168
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x30(%rbp), %rcx
addq -0x40(%rbp), %rcx
movq -0x48(%rbp), %r8
callq 0xcf890
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)