// File: /workspace/github_c_makefile_star2_O3/dlbeer[P]ufat/main.c
// Function: cmd_dir
static int cmd_dir(struct ufat *uf, const struct options *opt)
{
	struct ufat_directory dir;
	FILE *out;

	if (opt->argc) {
		struct ufat_dirent ent;
		int err;

		if (require_file(uf, opt->argv[0], &ent) < 0)
			return -1;

		err = ufat_open_subdir(uf, &dir, &ent);
		if (err < 0) {
			fprintf(stderr, "ufat_open_subdir: %s\n",
				ufat_strerror(err));
			return -1;
		}
	} else {
		ufat_open_root(uf, &dir);
	}

	out = open_output(opt->out_file);
	if (!out)
		return -1;

	if (list_dir(out, &dir) < 0) {
		close_output(opt->out_file, out);
		return -1;
	}

	return close_output(opt->out_file, out);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x378, %rsp            # imm = 0x378
movq %rsi, %r15
movq %rdi, %rbx
cmpl $0x0, 0x40(%rsi)
je 0x53d2
movq 0x38(%r15), %rax
movq (%rax), %rsi
leaq 0x70(%rsp), %rdx
movq %rbx, %rdi
callq 0x61cb
testl %eax, %eax
js 0x555b
leaq 0x8(%rsp), %rsi
leaq 0x70(%rsp), %rdx
movq %rbx, %rdi
callq 0x250c
testl %eax, %eax
jns 0x53df
movl %eax, %edi
callq 0x1442
jmp 0x555b
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x24e0
movq 0x20(%r15), %rdi
callq 0x52f5
movq %rax, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x5572
movq %r15, (%rsp)
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rsi
leaq 0x70(%rsp), %rdx
movl $0x300, %ecx            # imm = 0x300
callq 0x2577
testl %eax, %eax
js 0x5526
leaq 0x2560(%rip), %r12      # 0x7985
leaq 0x25be(%rip), %rbp      # 0x79ea
leaq 0x70(%rsp), %rbx
leaq 0x8(%rsp), %r13
leaq 0x28(%rsp), %r15
testl %eax, %eax
jne 0x5562
movzwl 0x5c(%rsp), %r8d
movl %r8d, %edx
shrl $0x9, %edx
addl $0x7bc, %edx            # imm = 0x7BC
movl %r8d, %ecx
shrl $0x5, %ecx
andl $0xf, %ecx
andl $0x1f, %r8d
movq %r14, %rdi
leaq 0x250a(%rip), %rsi      # 0x7976
xorl %eax, %eax
callq 0x1140
movl $0x20, %edi
movq %r14, %rsi
callq 0x1120
movzwl 0x5e(%rsp), %r8d
movl %r8d, %edx
shrl $0xb, %edx
movl %r8d, %ecx
shrl $0x5, %ecx
andl $0x3f, %ecx
addl %r8d, %r8d
andl $0x3e, %r8d
movq %r14, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x1140
movl $0x20, %edi
movq %r14, %rsi
callq 0x1120
movl 0x54(%rsp), %esi
andl $-0x11, %esi
movq %r14, %rdi
callq 0x6269
testb $0x10, 0x54(%rsp)
jne 0x54e3
movl 0x68(%rsp), %edx
movq %r14, %rdi
leaq 0x2497(%rip), %rsi      # 0x7971
xorl %eax, %eax
callq 0x1140
jmp 0x54fb
movq %r14, %rdi
leaq 0x2479(%rip), %rsi      # 0x7966
leaq 0x2477(%rip), %rdx      # 0x796b
xorl %eax, %eax
callq 0x1140
movq %r14, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1140
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl $0x300, %ecx            # imm = 0x300
callq 0x2577
testl %eax, %eax
jns 0x543b
movq 0x5acb(%rip), %rcx      # 0xaff8
movq (%rcx), %rbx
movl %eax, %edi
callq 0x2102
leaq 0x240b(%rip), %rsi      # 0x7949
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1140
movq (%rsp), %rax
movq 0x20(%rax), %rdi
movq %r14, %rsi
callq 0x5327
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x5572
movq (%rsp), %rax
movq 0x20(%rax), %rdi
movq %r14, %rsi
callq 0x5327
addq $0x378, %rsp            # imm = 0x378
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq