// File: /workspace/github_c_makefile_star2_O2/dlbeer[P]ufat/main.c
// Function: cmd_fstat
static int cmd_fstat(struct ufat *uf, const struct options *opt)
{
	FILE *out;
	struct ufat_dirent ent;
	char can_name[UFAT_LFN_MAX_UTF8];
	int err;

	if (!opt->argc) {
		fprintf(stderr, "You must specify a file path\n");
		return -1;
	}

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

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

	err = ufat_get_filename(uf, &ent, can_name, sizeof(can_name));
	if (err < 0)
		fprintf(stderr, "ufat_get_filename: %s\n",
			ufat_strerror(err));
	else
		fprintf(out, "Filename:               %s\n", can_name);

	fprintf(out, "Entry block/offset:     %llu/%d\n",
		ent.dirent_block, ent.dirent_pos);

	if (ent.lfn_block != UFAT_BLOCK_NONE)
		fprintf(out, "LFN start block/offset: %llu/%d\n",
			ent.lfn_block, ent.lfn_pos);

	fprintf(out, "Short name:             %s", ent.short_name);
	if (ent.short_ext[0])
		fprintf(out, ".%s\n", ent.short_ext);
	else
		fprintf(out, "\n");
	fprintf(out, "Attributes:             0x%02x (", ent.attributes);
	print_attributes(out, ent.attributes);
	fprintf(out, ")\n");
	fprintf(out, "Creation date/time:     ");
	print_date(out, ent.create_date);
	fprintf(out, " ");
	print_time(out, ent.create_time);
	fprintf(out, "\n");
	fprintf(out, "Modification date/time: ");
	print_date(out, ent.modify_date);
	fprintf(out, " ");
	print_time(out, ent.modify_time);
	fprintf(out, "\n");
	fprintf(out, "Last access date:       ");
	print_date(out, ent.access_date);
	fprintf(out, "\n");
	fprintf(out, "First cluster:          %u\n", ent.first_cluster);
	fprintf(out, "Size:                   %u\n", ent.file_size);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x358, %rsp            # imm = 0x358
cmpl $0x0, 0x40(%rsi)
je 0x4f61
movq %rsi, %rbx
movq %rdi, %r15
movq 0x38(%rsi), %rax
movq (%rax), %rsi
leaq 0x8(%rsp), %rdx
callq 0x5ab1
pushq $-0x1
popq %rbp
testl %eax, %eax
js 0x4f4d
movq 0x20(%rbx), %rdi
callq 0x4a82
testq %rax, %rax
je 0x4f4d
movq %rax, %r14
leaq 0x8(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movq %r15, %rdi
movl $0x300, %ecx            # imm = 0x300
callq 0x25f3
testl %eax, %eax
js 0x4f82
leaq 0x1c43(%rip), %rsi      # 0x69d3
leaq 0x50(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
movq 0x8(%rsp), %rdx
movl 0x10(%rsp), %ecx
leaq 0x1c40(%rip), %rsi      # 0x69ef
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
movq 0x18(%rsp), %rdx
cmpq $-0x1, %rdx
je 0x4dd9
movl 0x20(%rsp), %ecx
leaq 0x1c41(%rip), %rsi      # 0x6a10
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
leaq 0x24(%rsp), %r15
leaq 0x1c4c(%rip), %rsi      # 0x6a31
movq %r14, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1140
cmpb $0x0, 0x9(%r15)
je 0x4e11
leaq 0x2d(%rsp), %rdx
leaq 0x1c47(%rip), %rsi      # 0x6a4c
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
jmp 0x4e1c
pushq $0xa
popq %rdi
movq %r14, %rsi
callq 0x1120
movl 0x34(%rsp), %edx
leaq 0x1c2a(%rip), %rsi      # 0x6a51
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
movl 0x34(%rsp), %esi
movq %r14, %rdi
callq 0x5bb6
leaq 0x21f3(%rip), %rdi      # 0x7037
pushq $0x2
popq %rsi
pushq $0x1
popq %r15
movq %r15, %rdx
movq %r14, %rcx
callq 0x11e0
leaq 0x1c15(%rip), %rdi      # 0x6a72
pushq $0x18
popq %r12
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x11e0
movzwl 0x38(%rsp), %esi
movq %r14, %rdi
callq 0x5b6b
pushq $0x20
popq %r13
movl %r13d, %edi
movq %r14, %rsi
callq 0x1120
movzwl 0x3a(%rsp), %esi
movq %r14, %rdi
callq 0x5b93
pushq $0xa
popq %rbp
movl %ebp, %edi
movq %r14, %rsi
callq 0x1120
leaq 0x1bdf(%rip), %rdi      # 0x6a8b
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x11e0
movzwl 0x3c(%rsp), %esi
movq %r14, %rdi
callq 0x5b6b
movl %r13d, %edi
movq %r14, %rsi
callq 0x1120
movzwl 0x3e(%rsp), %esi
movq %r14, %rdi
callq 0x5b93
movl %ebp, %edi
movq %r14, %rsi
callq 0x1120
leaq 0x1bb4(%rip), %rdi      # 0x6aa4
movq %r12, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x11e0
movzwl 0x40(%rsp), %esi
movq %r14, %rdi
callq 0x5b6b
movl %ebp, %edi
movq %r14, %rsi
callq 0x1120
movl 0x44(%rsp), %edx
leaq 0x1b9d(%rip), %rsi      # 0x6abd
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
movl 0x48(%rsp), %edx
leaq 0x1ba4(%rip), %rsi      # 0x6ad9
movq %r14, %rdi
xorl %eax, %eax
callq 0x1140
movq 0x20(%rbx), %rdi
movq %r14, %rsi
callq 0x4ae8
movl %eax, %ebp
movl %ebp, %eax
addq $0x358, %rsp            # imm = 0x358
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5090(%rip), %rax      # 0x9ff8
movq (%rax), %rcx
leaq 0x1a2c(%rip), %rdi      # 0x699e
pushq $0x1d
popq %rsi
pushq $0x1
popq %rdx
callq 0x11e0
pushq $-0x1
popq %rbp
jmp 0x4f4d
movq 0x506f(%rip), %rcx      # 0x9ff8
movq (%rcx), %r15
movl %eax, %edi
callq 0x1a87
leaq 0x1a22(%rip), %rsi      # 0x69bc
movq %r15, %rdi
movq %rax, %rdx
jmp 0x4d98