// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/fat.c
// Function: do_subdir
static void do_subdir(deark *c, lctx *d, struct member_data *md, int nesting_level)
{
	int saved_indent_level;
	i64 cur_cluster_num;
	i64 cur_cluster_pos;
	struct dirctx *dctx = NULL;

	de_dbg_indent_save(c, &saved_indent_level);

	if(nesting_level >= MAX_NESTING_LEVEL) {
		de_err(c, "Directories nested too deeply");
		goto done;
	}

	dctx = de_malloc(c, sizeof(struct dirctx));

	cur_cluster_num = md->first_cluster;
	if(!is_good_clusternum(d, cur_cluster_num)) {
		de_err(c, "Bad subdirectory entry");
		goto done;
	}
	cur_cluster_pos = clusternum_to_offset(c, d, cur_cluster_num);
	de_dbg(c, "subdir starting at %"I64_FMT, cur_cluster_pos);
	de_dbg_indent(c, 1);

	while(1) {
		if(!is_good_clusternum(d, cur_cluster_num)) {
			break;
		}
		cur_cluster_pos = clusternum_to_offset(c, d, cur_cluster_num);
		de_dbg(c, "[subdir cluster %"I64_FMT" at %"I64_FMT"]", cur_cluster_num, cur_cluster_pos);

		if(d->cluster_used_flags[cur_cluster_num]) {
			goto done;
		}
		d->cluster_used_flags[cur_cluster_num] = 1;

		if(!do_dir_entries(c, d, dctx, cur_cluster_pos, d->bytes_per_cluster, nesting_level, 0)) {
			break;
		};

		cur_cluster_num = d->fat_nextcluster[cur_cluster_num];
	}

done:
	destroy_dirctx(c, dctx);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x15b580
cmpl $0x10, -0x1c(%rbp)
jl 0x850a9
movq -0x8(%rbp), %rdi
leaq 0x11ae8b(%rip), %rsi    # 0x19ff28
movb $0x0, %al
callq 0x15bfb0
jmp 0x851e7
movq -0x8(%rbp), %rdi
movl $0x220, %esi            # imm = 0x220
callq 0x15b780
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x853c0
cmpl $0x0, %eax
jne 0x850f0
movq -0x8(%rbp), %rdi
leaq 0x12934b(%rip), %rsi    # 0x1ae42f
movb $0x0, %al
callq 0x15bfb0
jmp 0x851e7
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x85400
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x129332(%rip), %rsi    # 0x1ae446
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x853c0
cmpl $0x0, %eax
jne 0x85140
jmp 0x851e5
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x85400
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
leaq 0x1292f5(%rip), %rsi    # 0x1ae45d
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq -0x28(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x85186
jmp 0x851e7
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq -0x28(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %r8
movl -0x1c(%rbp), %r9d
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0x83f20
cmpl $0x0, %eax
jne 0x851ca
jmp 0x851e5
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rax
movq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq %rax, -0x28(%rbp)
jmp 0x85129
jmp 0x851e7
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x84050
movq -0x8(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x15b5a0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)