LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_write_raw_dirent
int ufat_write_raw_dirent(struct ufat_directory *dir,
			  const uint8_t *data, unsigned int len)
{
	int idx;

	if (dir->cur_block == UFAT_BLOCK_NONE)
		return -UFAT_ERR_IO;

	idx = ufat_cache_open(dir->uf, dir->cur_block, 0);
	if (idx < 0)
		return idx;

	ufat_cache_write(dir->uf, idx);
	memcpy(ufat_cache_data(dir->uf, idx) +
	       dir->cur_pos * UFAT_DIRENT_SIZE,
	       data, len);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq 0x10(%rdi), %rsi
cmpq $-0x1, %rsi
je 0x383d
movl %edx, %ebp
movq %rdi, %r15
movq (%rdi), %rdi
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x3844
movq (%r15), %rdx
incl 0x20(%rdx)
movl %eax, %ecx
shlq $0x4, %rcx
orb $0x1, 0x80(%rdx,%rcx)
movq (%rdx), %rcx
movb (%rcx), %cl
shll %cl, %eax
addq %rdx, %rax
movl 0x8(%r15), %ecx
shll $0x5, %ecx
leaq (%rcx,%rax), %rdi
addq $0x180, %rdi            # imm = 0x180
movl %ebp, %edx
movq %r14, %rsi
callq 0x1160
jmp 0x3846
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x3846
movl %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_advance_raw_dirent
int ufat_advance_raw_dirent(struct ufat_directory *dir, int can_alloc)
{
	/* Advance the dirent pointer and check for a block overrun */
	dir->cur_pos++;
	if (dir->cur_pos * UFAT_DIRENT_SIZE >=
	    (1u << dir->uf->dev->log2_block_size)) {
		dir->cur_pos = 0;

		if (dir->cur_block < dir->uf->bpb.cluster_start) {
			/* FAT12/16 root directory */
			dir->cur_block++;
			if (dir->cur_block >= dir->uf->bpb.cluster_start)
				dir->cur_block = UFAT_BLOCK_NONE;

			return 0;
		}

		return advance_block_in_chain(dir, can_alloc);
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl 0x8(%rdi), %eax
incl %eax
movl %eax, 0x8(%rdi)
shll $0x5, %eax
movq (%rdi), %r14
movq (%r14), %rcx
movb (%rcx), %cl
shrl %cl, %eax
xorl %ebp, %ebp
testl %eax, %eax
je 0x3955
movq %rdi, %rbx
movl $0x0, 0x8(%rdi)
movq 0x10(%rdi), %rax
movq 0x48(%r14), %rdx
movq %rax, %r15
subq %rdx, %r15
jae 0x38b2
incq %rax
cmpq %rdx, %rax
movq $-0x1, %rcx
cmovbq %rax, %rcx
movq %rcx, 0x10(%rbx)
jmp 0x3955
movl %esi, %r12d
movb 0x2c(%r14), %cl
shrq %cl, %r15
incq %rax
movq %rax, %rsi
subq %rdx, %rsi
shrq %cl, %rsi
leal 0x2(%rsi), %ecx
movl %ecx, 0xc(%rsp)
cmpl %esi, %r15d
je 0x3904
addl $0x2, %r15d
leaq 0xc(%rsp), %rdx
movq %r14, %rdi
movl %r15d, %esi
callq 0x1fb2
testl %eax, %eax
js 0x3953
movl 0xc(%rsp), %eax
addl $-0x2, %eax
cmpl $0xfffffed, %eax        # imm = 0xFFFFFED
ja 0x390c
movb 0x2c(%r14), %cl
shll %cl, %eax
addq 0x48(%r14), %rax
movq %rax, 0x10(%rbx)
xorl %ebp, %ebp
jmp 0x3955
testl %r12d, %r12d
je 0x3964
movq (%rbx), %rdi
leaq 0xc(%rsp), %rdx
movl $0x1, %esi
callq 0x23ae
testl %eax, %eax
js 0x3953
movq (%rbx), %rdi
movl 0xc(%rsp), %esi
callq 0x3ace
movq (%rbx), %rdi
movl 0xc(%rsp), %edx
testl %eax, %eax
js 0x396e
movl %r15d, %esi
callq 0x21ad
testl %eax, %eax
js 0x3974
movl 0xc(%rsp), %eax
addl $-0x2, %eax
jmp 0x38fa
movl %eax, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq $-0x1, 0x10(%rbx)
jmp 0x3908
movl %eax, %ebp
movl %edx, %esi
jmp 0x397d
movl %eax, %ebp
movq (%rbx), %rdi
movl 0xc(%rsp), %esi
callq 0x2342
jmp 0x3955
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_read_raw_dirent
int ufat_read_raw_dirent(struct ufat_directory *dir, uint8_t *data)
{
	int idx;

	if (dir->cur_block == UFAT_BLOCK_NONE)
		return 1;

	idx = ufat_cache_open(dir->uf, dir->cur_block, 0);
	if (idx < 0)
		return idx;

	memcpy(data, ufat_cache_data(dir->uf, idx) +
	       dir->cur_pos * UFAT_DIRENT_SIZE,
	       UFAT_DIRENT_SIZE);

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq 0x10(%rdi), %rsi
cmpq $-0x1, %rsi
je 0x39d8
movq %rdi, %r15
movq (%rdi), %rdi
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x39df
movq (%r15), %rdx
movq (%rdx), %rcx
movb (%rcx), %cl
shll %cl, %eax
addq %rdx, %rax
movl 0x8(%r15), %ecx
shll $0x5, %ecx
movups 0x180(%rcx,%rax), %xmm0
movups 0x190(%rcx,%rax), %xmm1
movups %xmm1, 0x10(%r14)
movups %xmm0, (%r14)
jmp 0x39e1
movl $0x1, %ebx
jmp 0x39e1
movl %eax, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_allocate_raw_dirent
int ufat_allocate_raw_dirent(struct ufat_directory *dir, unsigned int count)
{
	ufat_block_t empty_start = UFAT_BLOCK_NONE;
	unsigned int empty_pos = 0;
	unsigned int empty_count = 0;

	ufat_dir_rewind(dir);

	for (;;) {
		uint8_t data[UFAT_DIRENT_SIZE];
		int err;

		err = ufat_read_raw_dirent(dir, data);
		if (err < 0)
			return err;

		/* Check to see if this raw dirent is empty. Keep track
		 * of contiguous chains of empty dirents.
		 */
		if (!data[0] || data[0] == 0xe5) {
			if (!empty_count) {
				empty_start = dir->cur_block;
				empty_pos = dir->cur_pos;
			}

			empty_count++;
		} else {
			empty_count = 0;
		}

		/* Is this chain long enough? */
		if (empty_count >= count)
			break;

		err = ufat_advance_raw_dirent(dir, 1);
		if (err < 0)
			return err;

		if (dir->cur_block == UFAT_BLOCK_NONE)
			return -UFAT_ERR_DIRECTORY_FULL;
	}

	/* Reposition at the start of the empty chain */
	dir->cur_block = empty_start;
	dir->cur_pos = empty_pos;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movq %rdi, %rbx
callq 0x262b
movl $0x0, 0x4(%rsp)
movq $-0x1, 0x8(%rsp)
leaq 0x10(%rsp), %r15
xorl %r12d, %r12d
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3984
testl %eax, %eax
js 0x3a53
movzbl 0x10(%rsp), %eax
cmpl $0xe5, %eax
je 0x3a39
testl %eax, %eax
jne 0x3a5b
testl %r12d, %r12d
jne 0x3a4e
movq 0x10(%rbx), %rax
movq %rax, 0x8(%rsp)
movl 0x8(%rbx), %eax
movl %eax, 0x4(%rsp)
incl %r12d
jmp 0x3a5e
movl $0x1, %r13d
jmp 0x3a97
xorl %r12d, %r12d
movl $0x2, %r13d
cmpl %ebp, %r12d
jae 0x3a9a
movl $0x1, %r13d
movq %rbx, %rdi
movl $0x1, %esi
callq 0x3853
testl %eax, %eax
js 0x3a97
xorl %r13d, %r13d
cmpq $-0x1, 0x10(%rbx)
sete %r13b
movl $0xfffffff2, %eax       # imm = 0xFFFFFFF2
cmovel %eax, %r14d
jmp 0x3a9a
movl %eax, %r14d
testl %r13d, %r13d
je 0x3a1a
cmpl $0x2, %r13d
jne 0x3abc
movq 0x8(%rsp), %rax
movq %rax, 0x10(%rbx)
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rbx)
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_init_dirent_cluster
int ufat_init_dirent_cluster(struct ufat *uf, ufat_cluster_t c)
{
	const struct ufat_bpb *bpb = &uf->bpb;
	const ufat_block_t start = cluster_to_block(bpb, c);
	const unsigned int count =
		1 << bpb->log2_blocks_per_cluster;
	const unsigned int block_size = 1 << uf->dev->log2_block_size;
	int i;

	for (i = count - 1; i >= 0; i--) {
		int idx = ufat_cache_open(uf, start + i, 1);

		if (idx < 0)
			return idx;

		ufat_cache_write(uf, idx);
		memset(ufat_cache_data(uf, idx), 0, block_size);
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebx
movq %rdi, %r14
addl $-0x2, %ebx
movb 0x2c(%rdi), %cl
shll %cl, %ebx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
shll %cl, %r13d
notl %r13d
movq (%rdi), %rax
movb (%rax), %cl
movl $0x1, %r15d
shlq %cl, %r15
leaq 0x80(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x180(%rdi), %rbp
addq 0x48(%rdi), %rbx
leaq (%rbx,%r13), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x1ad5
movl %eax, %r12d
testl %eax, %eax
js 0x3b5f
incl 0x20(%r14)
movl %r12d, %eax
shlq $0x4, %rax
movq 0x10(%rsp), %rcx
orb $0x1, (%rcx,%rax)
movq (%r14), %rax
movb (%rax), %cl
movl %r12d, %edi
shll %cl, %edi
addq %rbp, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1110
jmp 0x3b64
movl %r12d, 0xc(%rsp)
testl %r12d, %r12d
js 0x3b79
leaq -0x1(%r13), %rax
testq %r13, %r13
movq %rax, %r13
jg 0x3b1a
xorl %eax, %eax
jmp 0x3b7d
movl 0xc(%rsp), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_parse_dirent
void ufat_parse_dirent(ufat_fat_type_t type,
		       const uint8_t *data, struct ufat_dirent *inf)
{
	sn_copy(data, inf->short_name, 8);
	sn_copy(data + 0x08, inf->short_ext, 3);

	inf->attributes = data[0x0b];
	inf->create_time = r16(data + 0x0e);
	inf->create_date = r16(data + 0x10);
	inf->access_date = r16(data + 0x12);
	inf->modify_time = r16(data + 0x16);
	inf->modify_date = r16(data + 0x18);
	inf->file_size = r32(data + 0x1c);
	inf->first_cluster = r16(data + 0x1a);

	if (type == UFAT_TYPE_FAT32) {
		uint32_t high = r16(data + 0x14);

		inf->first_cluster |= high << 16;
	}
}

// Assembly:
xorl %eax, %eax
movb (%rsi,%rax), %cl
cmpb $0x21, %cl
jb 0x3ba8
movb %cl, 0x1c(%rdx,%rax)
incq %rax
cmpq $0x8, %rax
jne 0x3b8e
movl $0x8, %eax
movl %eax, %eax
movb $0x0, 0x1c(%rdx,%rax)
xorl %eax, %eax
movb 0x8(%rsi,%rax), %cl
cmpb $0x21, %cl
jb 0x3bcc
movb %cl, 0x25(%rdx,%rax)
incq %rax
cmpq $0x3, %rax
jne 0x3bb1
movl $0x3, %eax
movl %eax, %eax
movb $0x0, 0x25(%rdx,%rax)
movzbl 0xb(%rsi), %eax
movl %eax, 0x2c(%rdx)
movzwl 0xe(%rsi), %eax
movw %ax, 0x32(%rdx)
movzwl 0x10(%rsi), %eax
movw %ax, 0x30(%rdx)
movzwl 0x12(%rsi), %eax
movw %ax, 0x38(%rdx)
movzwl 0x16(%rsi), %eax
movw %ax, 0x36(%rdx)
movzwl 0x18(%rsi), %eax
movw %ax, 0x34(%rdx)
movl 0x1c(%rsi), %eax
movl %eax, 0x40(%rdx)
movzwl 0x1a(%rsi), %eax
movl %eax, 0x3c(%rdx)
cmpl $0x20, %edi
jne 0x3c29
movzbl 0x14(%rsi), %ecx
movzbl 0x15(%rsi), %esi
shll $0x18, %esi
shll $0x10, %ecx
orl %esi, %ecx
orl %eax, %ecx
movl %ecx, 0x3c(%rdx)
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_pack_dirent
void ufat_pack_dirent(const struct ufat_dirent *ent, uint8_t *data)
{
	memset(data, 0x20, 11);
	memcpy(data, ent->short_name, strlen(ent->short_name));
	memcpy(data + 0x08, ent->short_ext, strlen(ent->short_ext));

	data[0x0b] = ent->attributes;
	data[0x0c] = 0;
	data[0x0d] = 0;
	w16(data + 0x0e, ent->create_time);
	w16(data + 0x10, ent->create_date);
	w16(data + 0x12, ent->access_date);
	w16(data + 0x14, ent->first_cluster >> 16);
	w16(data + 0x16, ent->modify_time);
	w16(data + 0x18, ent->modify_date);
	w16(data + 0x1a, ent->first_cluster & 0xffff);
	w32(data + 0x1c, ent->file_size);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movabsq $0x2020202020202020, %rax # imm = 0x2020202020202020
movq %rax, (%rsi)
movl $0x20202020, 0x7(%rsi)  # imm = 0x20202020
leaq 0x1c(%rdi), %r15
movq %r15, %rdi
callq 0x10d0
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x1160
leaq 0x8(%rbx), %r15
leaq 0x25(%r14), %r12
movq %r12, %rdi
callq 0x10d0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x1160
movb 0x2c(%r14), %al
movb %al, 0xb(%rbx)
movw $0x0, 0xc(%rbx)
movzwl 0x32(%r14), %eax
movw %ax, 0xe(%rbx)
movzwl 0x30(%r14), %eax
movw %ax, 0x10(%rbx)
movzwl 0x38(%r14), %eax
movw %ax, 0x12(%rbx)
movzwl 0x3e(%r14), %eax
movw %ax, 0x14(%rbx)
movzwl 0x36(%r14), %eax
movw %ax, 0x16(%rbx)
movzwl 0x34(%r14), %eax
movw %ax, 0x18(%rbx)
movzwl 0x3c(%r14), %eax
movw %ax, 0x1a(%rbx)
movl 0x40(%r14), %eax
movl %eax, 0x1c(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_lfn_is_legal
int ufat_lfn_is_legal(const char *name)
{
	if (!*name)
		return 0;

	if (name[0] == '.') {
		if (!name[1])
			return 0;
		if (name[1] == '.' && !name[2])
			return 0;
	}

	while (*name) {
		if (*name == '\\' || *name == '/' || *name < ' ')
			return 0;

		name++;
	}

	return 1;
}

// Assembly:
movzbl (%rdi), %eax
testl %eax, %eax
je 0x3d1d
cmpl $0x2e, %eax
jne 0x3d02
movzbl 0x1(%rdi), %eax
testl %eax, %eax
je 0x3d1d
cmpl $0x2e, %eax
jne 0x3d02
cmpb $0x0, 0x2(%rdi)
je 0x3d24
xorl %eax, %eax
movzbl (%rdi), %ecx
testl %ecx, %ecx
je 0x3d1e
cmpl $0x2f, %ecx
je 0x3d1d
cmpl $0x5c, %ecx
je 0x3d1d
incq %rdi
cmpb $0x20, %cl
jge 0x3d04
retq
movl $0x1, %eax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_short_first
void ufat_short_first(const char *long_name,
		      char *short_name, char *ext_text)
{
	int len = strlen(long_name);
	int ext = len;
	int i, j;

	while (ext >= 0 && long_name[ext] != '.')
		ext--;

	if (ext > 0)
		ext++;
	else
		ext = len;

	j = 0;
	for (i = ext; j < 3 && long_name[i]; i++) {
		char c = long_name[i];

		if (is_legal_dos_char(c))
			ext_text[j++] = toupper(c);
	}
	ext_text[j] = 0;

	j = 0;
	for (i = 0; j < 8 && i < ext; i++) {
		char c = long_name[i];

		if (is_legal_dos_char(c))
			short_name[j++] = toupper(c);
	}
	short_name[j] = 0;

	if (!j) {
		for (i = 0; i < 8; i++)
			short_name[i] = '~';
		short_name[8] = 0;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
callq 0x10d0
movl %eax, %edx
testl %eax, %eax
js 0x3d5f
movl %eax, %edx
movl %edx, %ecx
cmpb $0x2e, (%r14,%rcx)
je 0x3d5f
leal -0x1(%rdx), %ecx
testl %edx, %edx
movl %ecx, %edx
jg 0x3d48
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leal 0x1(%rdx), %ecx
testl %edx, %edx
cmovgl %ecx, %eax
movq %rax, (%rsp)
movslq %eax, %r12
addq %r14, %r12
xorl %ebp, %ebp
movsbq (%r12), %r13
testq %r13, %r13
je 0x3da6
movl %r13d, %edi
callq 0x3e2c
testl %eax, %eax
je 0x3d9e
callq 0x1030
movq (%rax), %rax
movb (%rax,%r13,4), %al
movslq %ebp, %rcx
incl %ebp
movb %al, (%r15,%rcx)
incq %r12
cmpl $0x3, %ebp
jl 0x3d73
movslq %ebp, %rax
movb $0x0, (%r15,%rax)
movq (%rsp), %rax
testl %eax, %eax
jle 0x3dfe
movl %eax, %r12d
xorl %r15d, %r15d
movl $0x1, %r13d
movsbl -0x1(%r14,%r13), %ebp
movl %ebp, %edi
callq 0x3e2c
testl %eax, %eax
je 0x3dea
movslq %ebp, %rbp
callq 0x1030
movq (%rax), %rax
movb (%rax,%rbp,4), %al
movslq %r15d, %rcx
incl %r15d
movb %al, (%rbx,%rcx)
cmpl $0x7, %r15d
jg 0x3e01
leaq 0x1(%r13), %rax
cmpq %r12, %r13
movq %rax, %r13
jb 0x3dc2
jmp 0x3e01
xorl %r15d, %r15d
movslq %r15d, %rax
movb $0x0, (%rbx,%rax)
testl %eax, %eax
jne 0x3e1d
movabsq $0x7e7e7e7e7e7e7e7e, %rax # imm = 0x7E7E7E7E7E7E7E7E
movq %rax, (%rbx)
movb $0x0, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: is_legal_dos_char
static int is_legal_dos_char(char c)
{
	return isalnum(c) ||
		(c >= '!' && c <= ')') ||
		(c == '-') ||
		(c == '@') ||
		(c >= '^' && c <= '`') ||
		(c == '{' || c == '}' || c == '~');
}

// Assembly:
pushq %rbx
movl %edi, %ebx
callq 0x1200
movq %rax, %rcx
leal -0x21(%rbx), %edx
movl $0x1, %eax
cmpb $0x9, %dl
jb 0x3e7a
movq (%rcx), %rcx
movslq %ebx, %rdx
movzwl (%rcx,%rdx,2), %ecx
andl $0x8, %ecx
jne 0x3e7a
movsbl %bl, %ecx
cmpl $0x2d, %ecx
je 0x3e7a
cmpl $0x40, %ecx
je 0x3e7a
leal -0x5e(%rbx), %edx
cmpb $0x3, %dl
jb 0x3e7a
cmpl $0x7b, %ecx
je 0x3e7a
cmpl $0x7d, %ecx
je 0x3e7a
xorl %eax, %eax
cmpb $0x7e, %bl
sete %al
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_short_next
void ufat_short_next(char *short_name)
{
	int len = strlen(short_name);
	int tilde = strlen(short_name);
	unsigned int suffix_num;
	int i;

	while (tilde >= 0 && short_name[tilde] != '~')
		tilde--;
	if (tilde < 0)
		tilde = len;
	else
		tilde++;

	suffix_num = atoi(short_name + tilde) + 1;
	short_name[8] = 0;

	i = 7;
	while (suffix_num && i >= 0) {
		short_name[i] = (suffix_num % 10) + '0';
		suffix_num /= 10;
		i--;
	}

	if (i >= 0)
		short_name[i--] = '~';

	while (i >= tilde)
		short_name[i--] = '~';
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x10d0
movl %eax, %ecx
testl %eax, %eax
js 0x3ea5
movl %eax, %ecx
movl %ecx, %edx
cmpb $0x7e, (%rbx,%rdx)
je 0x3ea5
leal -0x1(%rcx), %edx
testl %ecx, %ecx
movl %edx, %ecx
jg 0x3e8f
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leal 0x1(%rcx), %ebp
testl %ecx, %ecx
cmovsl %eax, %ebp
movslq %ebp, %rdi
addq %rbx, %rdi
callq 0x11c0
movb $0x0, 0x8(%rbx)
incl %eax
jne 0x3eca
movb $0x1, %sil
movl $0x7, %ecx
jmp 0x3f06
movl $0x7, %ecx
movl $0xcccccccd, %edx       # imm = 0xCCCCCCCD
movl %eax, %edi
movl %eax, %eax
imulq %rdx, %rax
shrq $0x23, %rax
leal (%rax,%rax), %esi
leal (%rsi,%rsi,4), %esi
movl %edi, %r8d
subl %esi, %r8d
orb $0x30, %r8b
movb %r8b, (%rbx,%rcx)
addq $-0x1, %rcx
setb %sil
cmpl $0xa, %edi
jb 0x3f06
testb %sil, %sil
jne 0x3ed4
testb %sil, %sil
je 0x3f13
movl %ecx, %eax
decl %ecx
movb $0x7e, (%rbx,%rax)
movl %ecx, %edx
subl %ebp, %edx
jge 0x3f20
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movslq %ecx, %rax
subq %rdx, %rax
addq %rax, %rbx
incq %rdx
movq %rbx, %rdi
movl $0x7e, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1110
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_short_exists
int ufat_short_exists(struct ufat_directory *dir, const char *short_name,
		      const char *short_ext)
{
	struct ufat_dirent ent;

	ufat_dir_rewind(dir);
	for (;;) {
		int err = ufat_dir_read(dir, &ent, NULL, 0);

		if (err < 0)
			return err;

		if (err)
			break;

		if (ufat_compare_name(short_name, ent.short_name, 0) >= 0 &&
		    ufat_compare_name(short_ext, ent.short_ext, 0) >= 0)
			return 1;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
callq 0x262b
leaq 0x1c(%rsp), %r12
movq %rsp, %rbp
movl %eax, %r13d
movq %r15, %rdi
movq %rbp, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x263b
testl %eax, %eax
js 0x3fb7
movl $0x2, %edx
jne 0x3fb2
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x3fd6
testl %eax, %eax
js 0x3fb0
movq %rbx, %rdi
leaq 0x25(%rsp), %rsi
xorl %edx, %edx
callq 0x3fd6
movl %eax, %ecx
movl $0x1, %eax
movl $0x1, %edx
testl %ecx, %ecx
jns 0x3fbc
xorl %edx, %edx
movl %r13d, %eax
jmp 0x3fbc
movl $0x1, %edx
testl %edx, %edx
je 0x3f63
cmpl $0x2, %edx
jne 0x3fc7
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_compare_name
int ufat_compare_name(const char *search_name, const char *dir_name,
		      int component_only)
{
	int m = 0;

	while (search_name[m]) {
		int dc = dir_name[m];
		int sc = search_name[m];

		if (component_only && (sc == '/' || sc == '\\'))
			break;

		if (!dc)
			return -1;

		if (sc >= 'a' && sc <= 'z')
			sc -= 32;

		if (dc >= 'a' && dc <= 'z')
			dc -= 32;

		if (sc != dc)
			return -1;

		m++;
	}

	if (dir_name[m])
		return -1;

	return m;
}

// Assembly:
xorl %eax, %eax
movslq %eax, %rcx
movsbl (%rdi,%rcx), %r9d
testl %r9d, %r9d
je 0x4048
movsbl (%rsi,%rcx), %r8d
testl %edx, %edx
je 0x4003
movl $0x3, %ecx
cmpb $0x2f, %r9b
je 0x403f
movzbl %r9b, %r10d
cmpl $0x5c, %r10d
je 0x403f
testb %r8b, %r8b
je 0x403a
leal -0x61(%r9), %ecx
leal -0x20(%r9), %r10d
cmpb $0x1a, %cl
cmovael %r9d, %r10d
leal -0x61(%r8), %ecx
leal -0x20(%r8), %r9d
cmpb $0x1a, %cl
cmovael %r8d, %r9d
xorl %ecx, %ecx
xorl %r8d, %r8d
cmpl %r9d, %r10d
setne %cl
sete %r8b
addl %r8d, %eax
jmp 0x403f
movl $0x1, %ecx
testl %ecx, %ecx
je 0x3fd8
cmpl $0x3, %ecx
jne 0x4054
cltq
xorl %ecx, %ecx
cmpb (%rsi,%rax), %cl
sbbl %ecx, %ecx
orl %ecx, %eax
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_lfn_parse
void ufat_lfn_parse(struct ufat_lfn_parser *s, const uint8_t *data,
		    ufat_block_t blk, unsigned int pos)
{
	const int fr_seq = data[0];
	uint16_t frag_data[13];
	int fr_pos;
	int fr_len;
	int i;

	fr_pos = ((fr_seq & 0x3f) - 1) * 13;
	fr_len = 13;
	if (fr_pos + fr_len > UFAT_LFN_MAX_CHARS)
		fr_len = UFAT_LFN_MAX_CHARS - fr_pos;

	/* Check against expected sequence number and checksum */
	if (fr_seq & 0x40) {
		s->start_block = blk;
		s->start_pos = pos;
		s->seq = fr_seq & 0x3f;
		s->len = fr_pos + fr_len;
		s->short_checksum = data[0x0d];
	} else if (fr_seq != s->seq ||
		   s->short_checksum != data[0x0d]) {
		ufat_lfn_reset(s);
		return;
	}
	s->seq--;

	/* Unpack and copy fragment */
	for (i = 0; i < 5; i++)
		frag_data[i] = r16(data + 0x01 + i * 2);
	for (i = 0; i < 6; i++)
		frag_data[i + 5] = r16(data + 0x0e + i * 2);
	frag_data[11] = r16(data + 0x1c);
	frag_data[12] = r16(data + 0x1e);

	for (i = 0; i < fr_len; i++)
		s->buf[fr_pos + i] = frag_data[i];
}

// Assembly:
movq %rdx, %rax
movzbl (%rsi), %r9d
movl %r9d, %r8d
andl $0x3f, %r8d
leal (%r8,%r8,2), %edx
leal (%r8,%rdx,4), %r10d
movl $0x10c, %r11d           # imm = 0x10C
subl %r10d, %r11d
cmpl $0x14, %r8d
movl $0xd, %edx
cmovael %r11d, %edx
testb $0x40, %r9b
jne 0x40a2
cmpl %r9d, 0x14(%rdi)
jne 0x409a
movb 0xc(%rdi), %al
cmpb 0xd(%rsi), %al
je 0x40bc
movl $0xffffffff, 0x14(%rdi) # imm = 0xFFFFFFFF
retq
movq %rax, (%rdi)
movl %ecx, 0x8(%rdi)
movl %r8d, 0x14(%rdi)
leal (%r10,%rdx), %eax
addl $-0xd, %eax
movl %eax, 0x10(%rdi)
movb 0xd(%rsi), %al
movb %al, 0xc(%rdi)
subq $0x28, %rsp
decl 0x14(%rdi)
xorl %eax, %eax
movzwl 0x1(%rsi,%rax,2), %ecx
movw %cx, (%rsp,%rax,2)
incq %rax
cmpq $0x5, %rax
jne 0x40c5
movl $0x7, %eax
movzwl (%rsi,%rax,2), %ecx
movw %cx, -0x4(%rsp,%rax,2)
incq %rax
cmpq $0xd, %rax
jne 0x40dc
movzwl 0x1c(%rsi), %eax
movw %ax, 0x16(%rsp)
movzwl 0x1e(%rsi), %eax
movw %ax, 0x18(%rsp)
testl %edx, %edx
jle 0x4120
leaq (%r8,%r8,4), %rax
leaq (%rax,%rax,4), %rax
addq %r8, %rax
addq %rax, %rdi
addq $-0x2, %rdi
addl %edx, %edx
movq %rsp, %rsi
callq 0x1160
addq $0x28, %rsp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_ucs2_to_utf8
int ufat_ucs2_to_utf8(const uint16_t *src, int src_len,
		      char *dst, int dst_len)
{
	int i;
	int j = 0;

	for (i = 0; i < src_len && src[i]; i++) {
		uint16_t c = src[i];

		if (c >= 0x800) {
			if (j + 3 >= dst_len)
				return -UFAT_ERR_BAD_ENCODING;

			dst[j++] = 0xe0 | (c >> 12);
			dst[j++] = 0x80 | ((c >> 6) & 0x3f);
			dst[j++] = 0x80 | (c & 0x3f);
		} else if (c >= 0x80) {
			if (j + 2 >= dst_len)
				return -UFAT_ERR_BAD_ENCODING;

			dst[j++] = 0xc0 | c >> 6;
			dst[j++] = 0x80 | (c & 0x3f);
		} else {
			if (j + 1 >= dst_len)
				return -UFAT_ERR_BAD_ENCODING;

			dst[j++] = c;
		}
	}

	if (j >= dst_len)
		return -UFAT_ERR_NAME_TOO_LONG;

	dst[j] = 0;
	return 0;
}

// Assembly:
pushq %rbx
testl %esi, %esi
jle 0x41eb
movl %esi, %eax
xorl %esi, %esi
xorl %r8d, %r8d
movzwl (%rdi,%rsi,2), %r9d
testw %r9w, %r9w
je 0x41ee
movzwl %r9w, %r11d
cmpl $0x800, %r11d           # imm = 0x800
jb 0x418a
leal 0x3(%r8), %r10d
cmpl %ecx, %r10d
jge 0x41d5
movl %r11d, %ebx
shrl $0xc, %ebx
orb $-0x20, %bl
movslq %r8d, %r8
movb %bl, (%rdx,%r8)
shrl $0x6, %r11d
andb $0x3f, %r11b
orb $-0x80, %r11b
movb %r11b, 0x1(%rdx,%r8)
andb $0x3f, %r9b
orb $-0x80, %r9b
movb %r9b, 0x2(%rdx,%r8)
jmp 0x41cd
cmpl $0x80, %r11d
jb 0x41bd
leal 0x2(%r8), %r10d
cmpl %ecx, %r10d
jge 0x41d5
movl %r9d, %r11d
shrl $0x6, %r11d
orb $-0x40, %r11b
movslq %r8d, %r8
movb %r11b, (%rdx,%r8)
andb $0x3f, %r9b
orb $-0x80, %r9b
movb %r9b, 0x1(%rdx,%r8)
jmp 0x41cd
leal 0x1(%r8), %r10d
cmpl %ecx, %r10d
jge 0x41d5
movslq %r8d, %r8
movb %r9b, (%rdx,%r8)
movb $0x1, %r9b
movl %r10d, %r8d
jmp 0x41d8
xorl %r9d, %r9d
testb %r9b, %r9b
je 0x4203
incq %rsi
cmpq %rsi, %rax
jne 0x4135
jmp 0x41ee
xorl %r8d, %r8d
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
cmpl %ecx, %r8d
jge 0x4208
movslq %r8d, %rax
movb $0x0, (%rdx,%rax)
xorl %eax, %eax
jmp 0x4208
movl $0xfffffff3, %eax       # imm = 0xFFFFFFF3
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_short_checksum
uint8_t ufat_short_checksum(const char *short_name, const char *short_ext)
{
	uint8_t sum = 0;
	int i;

	for (i = 0; short_name[i]; i++)
		sum = cksum_next(sum, short_name[i]);
	for (; i < 8; i++)
		sum = cksum_next(sum, ' ');

	for (i = 0; short_ext[i]; i++)
		sum = cksum_next(sum, short_ext[i]);
	for (; i < 3; i++)
		sum = cksum_next(sum, ' ');

	return sum;
}

// Assembly:
movb (%rdi), %dl
testb %dl, %dl
je 0x4225
xorl %ecx, %ecx
xorl %eax, %eax
rorb %al
addb %dl, %al
movb 0x1(%rdi,%rcx), %dl
incq %rcx
testb %dl, %dl
jne 0x4214
jmp 0x4229
xorl %eax, %eax
xorl %ecx, %ecx
cmpl $0x7, %ecx
ja 0x4239
addl $-0x8, %ecx
rorb %al
addb $0x20, %al
incl %ecx
jne 0x4231
movb (%rsi), %dl
xorl %ecx, %ecx
testb %dl, %dl
je 0x424e
rorb %al
addb %dl, %al
movb 0x1(%rsi,%rcx), %dl
incq %rcx
jmp 0x423d
cmpl $0x2, %ecx
ja 0x425e
addl $-0x3, %ecx
rorb %al
addb $0x20, %al
incl %ecx
jne 0x4256
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_utf8_to_ucs2
int ufat_utf8_to_ucs2(const char *src, uint16_t *dst)
{
	int len = 0;
	int i;

	while (*src && len < UFAT_LFN_MAX_CHARS) {
		unsigned int c = *src;

		if ((c & 0xf0) == 0xf0)
			return -UFAT_ERR_ILLEGAL_NAME;

		if ((c & 0xe0) == 0xe0) {
			unsigned int b = src[1];
			unsigned int a = src[2];

			if ((a & 0xc0) != 0xc0 ||
			    (b & 0xc0) != 0xc0)
				return -UFAT_ERR_BAD_ENCODING;

			dst[len++] = ((c & 0xf) << 12) |
				((b & 0x3f) << 6) |
				(a & 0x3f);
			src += 3;
		} else if ((c & 0xc0) == 0xc0) {
			unsigned int b = src[1];

			if ((b & 0xc0) != 0xc0)
				return -UFAT_ERR_BAD_ENCODING;

			dst[len++] = ((c & 0x1f) << 6) | (b & 0x3f);
			src += 2;
		} else if (c & 0x80) {
			return -UFAT_ERR_BAD_ENCODING;
		} else {
			dst[len++] = c;
			src++;
		}
	}

	if (*src)
		return -UFAT_ERR_NAME_TOO_LONG;

	/* Pad out to full length */
	for (i = len; i < UFAT_LFN_MAX_CHARS; i++)
		dst[i] = 0;

	return len;
}

// Assembly:
pushq %rbx
xorl %ebx, %ebx
movl $0xc0, %ecx
movsbl (%rdi), %edx
testl %edx, %edx
je 0x4363
cmpl $0xfe, %ebx
jg 0x4363
movl %edx, %r8d
notl %r8d
testb $-0x10, %r8b
jne 0x4296
movl $0xfffffff5, %eax       # imm = 0xFFFFFFF5
xorl %edx, %edx
jmp 0x434f
testb $-0x20, %r8b
jne 0x42e4
movsbl 0x1(%rdi), %r10d
movl %r10d, %r8d
notl %r8d
movzbl 0x2(%rdi), %r9d
movl %r9d, %r11d
notl %r11d
orl %r8d, %r11d
testb $-0x40, %r11b
sete %r8b
jne 0x4318
shll $0xc, %edx
andl $0x3f, %r10d
shll $0x6, %r10d
orl %edx, %r10d
andl $0x3f, %r9d
orl %r10d, %r9d
movslq %ebx, %rdx
incl %ebx
movw %r9w, (%rsi,%rdx,2)
addq $0x3, %rdi
jmp 0x431d
testb $-0x40, %r8b
jne 0x4328
movzbl 0x1(%rdi), %r9d
movl %r9d, %r8d
andl $-0x40, %r8d
cmpl %ecx, %r8d
jne 0x433b
andl $0x1f, %edx
shll $0x6, %edx
andl $0x3f, %r9d
orl %edx, %r9d
movslq %ebx, %rdx
incl %ebx
movw %r9w, (%rsi,%rdx,2)
addq $0x2, %rdi
jmp 0x4340
movl $0xfffffff3, %eax       # imm = 0xFFFFFFF3
testb %r8b, %r8b
je 0x428f
jmp 0x434d
testb %dl, %dl
js 0x4359
movslq %ebx, %r8
incl %ebx
movw %dx, (%rsi,%r8,2)
incq %rdi
jmp 0x434d
movl $0xfffffff3, %eax       # imm = 0xFFFFFFF3
cmpl $0xc0, %r8d
jne 0x428f
movb $0x1, %dl
testb %dl, %dl
jne 0x4267
jmp 0x4393
movl $0xfffffff3, %eax       # imm = 0xFFFFFFF3
jmp 0x428f
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
testb %dl, %dl
jne 0x4393
cmpl $0xfe, %ebx
jg 0x4391
movslq %ebx, %rax
leaq (%rsi,%rax,2), %rdi
movl $0xfe, %eax
subl %ebx, %eax
leaq 0x2(,%rax,2), %rdx
xorl %esi, %esi
callq 0x1110
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_lfn_pack_fragment
void ufat_lfn_pack_fragment(const uint16_t *ucs, int seq, int is_first,
			    uint8_t *data, uint8_t checksum)
{
	int i;

	data[0] = seq;
	if (is_first)
		data[0] |= 0x40;

	for (i = 0; i < 5; i++)
		w16(data + 0x01 + i * 2, ucs[i]);

	data[0x0b] = UFAT_ATTR_LFN_FRAGMENT;
	data[0x0c] = 0;
	data[0x0d] = checksum;

	for (i = 0; i < 6; i++)
		w16(data + 0x0e + i * 2, ucs[i + 5]);

	data[0x1a] = 0;
	data[0x1b] = 0;

	w16(data + 0x1c, ucs[11]);
	w16(data + 0x1e, ucs[12]);
}

// Assembly:
movl %esi, %eax
orb $0x40, %al
testl %edx, %edx
movzbl %al, %eax
cmovel %esi, %eax
movb %al, (%rcx)
xorl %eax, %eax
movzwl (%rdi,%rax,2), %edx
movw %dx, 0x1(%rcx,%rax,2)
incq %rax
cmpq $0x5, %rax
jne 0x43a5
movw $0xf, 0xb(%rcx)
movb %r8b, 0xd(%rcx)
xorl %eax, %eax
movzwl 0xa(%rdi,%rax,2), %edx
movw %dx, 0xe(%rcx,%rax,2)
incq %rax
cmpq $0x6, %rax
jne 0x43c3
movw $0x0, 0x1a(%rcx)
movzwl 0x16(%rdi), %eax
movw %ax, 0x1c(%rcx)
movzwl 0x18(%rdi), %eax
movw %ax, 0x1e(%rcx)
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_format_short
int ufat_format_short(const char *name, const char *ext,
		      char *out, int max_len)
{
	int i = 0;

	while (*name) {
		if (i >= max_len)
			return -UFAT_ERR_NAME_TOO_LONG;

		out[i++] = *(name++);
	}

	if (*ext) {
		if (i >= max_len)
			return -UFAT_ERR_NAME_TOO_LONG;
		out[i++] = '.';

		while (*ext) {
			if (i >= max_len)
				return -UFAT_ERR_NAME_TOO_LONG;
			out[i++] = *(ext++);
		}
	}

	if (i >= max_len)
		return -UFAT_ERR_NAME_TOO_LONG;

	out[i] = 0;
	return 0;
}

// Assembly:
movb (%rdi), %al
testb %al, %al
je 0x441d
xorl %r10d, %r10d
testl %ecx, %ecx
movl $0x0, %r9d
cmovgl %ecx, %r9d
cmpq %r10, %r9
je 0x4476
leaq 0x1(%r10), %r8
movb %al, (%rdx,%r10)
movb 0x1(%rdi,%r10), %al
movq %r8, %r10
testb %al, %al
jne 0x4402
jmp 0x4420
xorl %r8d, %r8d
cmpb $0x0, (%rsi)
je 0x4462
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
cmpl %ecx, %r8d
jge 0x4475
movl %r8d, %edi
movb $0x2e, (%rdx,%rdi)
movb (%rsi), %r9b
incl %r8d
testb %r9b, %r9b
je 0x4462
addq %rdx, %rdi
movl $0x1, %r10d
cmpl %ecx, %r8d
jge 0x4475
movb %r9b, (%rdi,%r10)
movb (%rsi,%r10), %r9b
incl %r8d
incq %r10
testb %r9b, %r9b
jne 0x444a
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
cmpl %ecx, %r8d
jge 0x4475
movslq %r8d, %rax
movb $0x0, (%rdx,%rax)
xorl %eax, %eax
retq
movl $0xfffffffa, %eax       # imm = 0xFFFFFFFA
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_ent.c
// Function: ufat_update_attributes
int ufat_update_attributes(struct ufat *uf, struct ufat_dirent *ent)
{
	int idx = ufat_cache_open(uf, ent->dirent_block, 0);
	uint8_t *data;
	struct ufat_dirent old;

	if (idx < 0)
		return idx;

	data = ufat_cache_data(uf, idx) + ent->dirent_pos * UFAT_DIRENT_SIZE;
	ufat_parse_dirent(uf->bpb.type, data, &old);

	if (!(old.attributes & UFAT_ATTR_DIRECTORY))
		old.attributes = (old.attributes & ~UFAT_ATTR_USER) |
			(ent->attributes & UFAT_ATTR_USER);

	old.create_date = ent->create_date;
	old.create_time = ent->create_time;
	old.modify_date = ent->modify_date;
	old.modify_time = ent->modify_time;
	old.access_date = ent->access_date;

	ufat_cache_write(uf, idx);
	ufat_pack_dirent(&old, data);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rsi
xorl %edx, %edx
callq 0x1ad5
movl %eax, %ebp
testl %eax, %eax
js 0x4539
movq (%rbx), %rax
movb (%rax), %cl
movl %ebp, %eax
shll %cl, %eax
addq %rbx, %rax
movl 0x8(%r14), %ecx
shll $0x5, %ecx
leaq (%rcx,%rax), %r15
addq $0x180, %r15            # imm = 0x180
movl 0x28(%rbx), %edi
leaq 0x8(%rsp), %r12
movq %r15, %rsi
movq %r12, %rdx
callq 0x3b8c
movl 0x2c(%r12), %eax
testb $0x10, %al
jne 0x44ec
andl $-0x38, %eax
movl 0x2c(%r14), %ecx
andl $0x27, %ecx
orl %eax, %ecx
movl %ecx, 0x34(%rsp)
movzwl 0x30(%r14), %eax
leaq 0x8(%rsp), %rdi
movw %ax, 0x30(%rdi)
movzwl 0x32(%r14), %eax
movw %ax, 0x32(%rdi)
movzwl 0x34(%r14), %eax
movw %ax, 0x34(%rdi)
movzwl 0x36(%r14), %eax
movw %ax, 0x36(%rdi)
movzwl 0x38(%r14), %eax
movw %ax, 0x38(%rdi)
incl 0x20(%rbx)
movl %ebp, %eax
shlq $0x4, %rax
orb $0x1, 0x80(%rbx,%rax)
movq %r15, %rsi
callq 0x3c2a
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_mkfs.c
// Function: init_fat12
static int init_fat12(struct ufat_device *dev, const struct fs_layout *fl)
{
	const unsigned int block_size = 1 << dev->log2_block_size;
	unsigned int minor_byte = 0;
	unsigned int cluster_pair = 0;
	ufat_block_t i;
	ufat_block_t block;

	for (i = 0, block = 0; i < fl->fat_blocks * 2; i++, block++) {
		uint8_t buf[block_size];
		unsigned int j;

		if (block == fl->fat_blocks) {
			block = 0;
			minor_byte = 0;
			cluster_pair = 0;
		}

		memset(buf, 0, block_size);

		for (j = 0; j < block_size; j++) {
			uint32_t pair_data = 0;

			if ((cluster_pair << 1) >= fl->clusters)
				pair_data = 0xff7ff7;
			else if ((cluster_pair << 1) + 1 >= fl->clusters)
				pair_data = 0xff7000;

			buf[j] = pair_data >> (minor_byte << 3);

			if (++minor_byte >= 3) {
				minor_byte = 0;
				cluster_pair++;
			}
		}

		if (block == 0) {
			buf[0] = MEDIA_DISK;
			buf[1] = 0x8f;
			buf[2] = 0xff;
		}

		if (dev->write(dev, fl->reserved_blocks + i, 1, buf) < 0)
			return -UFAT_ERR_IO;
	}

	return 0;
}

// Assembly:
movq 0x18(%rsi), %rax
shlq %rax
testq %rax, %rax
je 0x493b
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r8
movq %rdi, -0x48(%rbp)
movb (%rdi), %cl
movl $0x1, %eax
shlq %cl, %rax
movl %eax, %r13d
movq %rax, -0x40(%rbp)
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, -0x38(%rbp)
xorl %r14d, %r14d
xorl %ecx, %ecx
xorl %r15d, %r15d
xorl %ebx, %ebx
movq %r15, -0x60(%rbp)
movq %rsp, -0x58(%rbp)
movq %rsp, %r12
subq -0x38(%rbp), %r12
movq %r12, %rsp
movq 0x18(%r8), %rax
movq %rcx, -0x30(%rbp)
movq %rax, -0x50(%rbp)
cmpq %rax, %rcx
movl $0x0, %eax
cmovel %eax, %ebx
cmovel %eax, %r14d
movq %r12, %rdi
xorl %esi, %esi
movq -0x40(%rbp), %rdx
movq %r8, %r15
callq 0x1110
movq %r15, %r9
movl 0x28(%r15), %eax
xorl %edx, %edx
movl %r14d, %ecx
movl %ebx, %esi
movl $0xff7ff7, %r10d        # imm = 0xFF7FF7
leal 0x1(%rcx), %r14d
cmpl $0x3, %r14d
sbbl $-0x1, %ebx
xorl %edi, %edi
cmpl $0x3, %r14d
leal 0x1(%rsi,%rsi), %r8d
cmovael %edi, %r14d
cmpl %eax, %r8d
jb 0x48af
movl $0xff7000, %edi         # imm = 0xFF7000
addl %esi, %esi
cmpl %eax, %esi
cmovael %r10d, %edi
shll $0x3, %ecx
shrl %cl, %edi
movb %dil, (%r12,%rdx)
incq %rdx
movl %r14d, %ecx
movl %ebx, %esi
cmpq %rdx, %r13
jne 0x488b
movq -0x30(%rbp), %rax
cmpq -0x50(%rbp), %rax
movl $0x0, %ecx
cmovneq %rax, %rcx
movq %rcx, -0x30(%rbp)
testq %rcx, %rcx
jne 0x48f4
movw $0x8ff8, (%r12)         # imm = 0x8FF8
movb $-0x1, 0x2(%r12)
movq 0x8(%r9), %rsi
movq -0x60(%rbp), %r15
addq %r15, %rsi
movl $0x1, %edx
movq -0x48(%rbp), %rdi
movq %r12, %rcx
movq %r9, %r12
callq *0x10(%rdi)
testl %eax, %eax
movq -0x58(%rbp), %rsp
js 0x493e
incq %r15
movq -0x30(%rbp), %rcx
incq %rcx
movq 0x18(%r12), %rax
addq %rax, %rax
cmpq %rax, %r15
movq %r12, %r8
jb 0x4839
xorl %eax, %eax
jmp 0x4943
xorl %eax, %eax
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_mkfs.c
// Function: init_fat16
static int init_fat16(struct ufat_device *dev, const struct fs_layout *fl)
{
	const unsigned int block_size = 1 << dev->log2_block_size;
	ufat_block_t i;
	ufat_block_t block;
	ufat_cluster_t c;

	for (i = 0, block = 0, c = 0; i < fl->fat_blocks * 2; i++, block++) {
		uint8_t buf[block_size];
		unsigned int j;

		if (block == fl->fat_blocks) {
			block = 0;
			c = 0;
		}

		memset(buf, 0, block_size);

		for (j = 0; j < block_size; j += 2) {
			if (c >= fl->clusters)
				w16(buf + j, 0xfff7);

			c++;
		}

		if (block == 0) {
			w16(buf, 0xff00 | MEDIA_DISK);
			w16(buf + 2, 0xfff8);
		}

		if (dev->write(dev, fl->reserved_blocks + i, 1, buf) < 0)
			return -UFAT_ERR_IO;
	}

	return 0;
}

// Assembly:
movq 0x18(%rsi), %rax
shlq %rax
testq %rax, %rax
je 0x4a58
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, -0x48(%rbp)
movb (%rdi), %cl
movl $0x1, %eax
shlq %cl, %rax
movl %eax, %r13d
movq %rax, -0x40(%rbp)
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, -0x38(%rbp)
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ecx, %ecx
movq %rsi, -0x30(%rbp)
movq %r15, -0x60(%rbp)
movq %rsp, -0x58(%rbp)
movq %rsp, %r12
subq -0x38(%rbp), %r12
movq %r12, %rsp
movq 0x18(%rsi), %rbx
movq %rcx, -0x50(%rbp)
cmpq %rbx, %rcx
movl $0x0, %eax
cmovel %eax, %r14d
movq %r12, %rdi
movq %rsi, %r15
xorl %esi, %esi
movq -0x40(%rbp), %rdx
callq 0x1110
movq %r15, %rdx
movl 0x28(%r15), %eax
xorl %ecx, %ecx
cmpl %eax, %r14d
jb 0x49ec
movw $0xfff7, (%r12,%rcx)    # imm = 0xFFF7
incl %r14d
addq $0x2, %rcx
cmpq %r13, %rcx
jb 0x49e0
movq -0x50(%rbp), %rax
cmpq %rbx, %rax
movl $0x0, %ebx
cmovneq %rax, %rbx
testq %rbx, %rbx
jne 0x4a15
movl $0xfff8fff8, (%r12)     # imm = 0xFFF8FFF8
movq 0x8(%rdx), %rsi
movq -0x60(%rbp), %r15
addq %r15, %rsi
movl $0x1, %edx
movq -0x48(%rbp), %rdi
movq %r12, %rcx
callq *0x10(%rdi)
testl %eax, %eax
movq -0x58(%rbp), %rsp
js 0x4a5b
incq %r15
incq %rbx
movq -0x30(%rbp), %rsi
movq 0x18(%rsi), %rax
addq %rax, %rax
movq %rbx, %rcx
cmpq %rax, %r15
jb 0x49a0
xorl %eax, %eax
jmp 0x4a60
xorl %eax, %eax
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_mkfs.c
// Function: init_fat32
static int init_fat32(struct ufat_device *dev, const struct fs_layout *fl)
{
	const unsigned int block_size = 1 << dev->log2_block_size;
	ufat_block_t i;
	ufat_block_t block;
	ufat_cluster_t c;

	for (i = 0, block = 0, c = 0; i < fl->fat_blocks * 2; i++, block++) {
		uint8_t buf[block_size];
		unsigned int j;

		if (block == fl->fat_blocks) {
			block = 0;
			c = 0;
		}

		memset(buf, 0, block_size);

		for (j = 0; j < block_size; j += 4) {
			if (c >= fl->clusters)
				w32(buf + j, 0xfffffff7);

			c++;
		}

		if (block == 0) {
			w32(buf + 0, 0xffffff00 | MEDIA_DISK);
			w32(buf + 4, 0xfffffff8);
			w32(buf + 8, 0xfffffff8);
		}

		if (dev->write(dev, fl->reserved_blocks + i, 1, buf) < 0)
			return -UFAT_ERR_IO;
	}

	return 0;
}

// Assembly:
movq 0x18(%rsi), %rax
shlq %rax
testq %rax, %rax
je 0x4b85
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, -0x48(%rbp)
movb (%rdi), %cl
movl $0x1, %eax
shlq %cl, %rax
movl %eax, %r13d
movq %rax, -0x40(%rbp)
addq $0xf, %rax
andq $-0x10, %rax
movq %rax, -0x38(%rbp)
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ecx, %ecx
movq %rsi, -0x30(%rbp)
movq %r15, -0x60(%rbp)
movq %rsp, -0x58(%rbp)
movq %rsp, %r12
subq -0x38(%rbp), %r12
movq %r12, %rsp
movq 0x18(%rsi), %rbx
movq %rcx, -0x50(%rbp)
cmpq %rbx, %rcx
movl $0x0, %eax
cmovel %eax, %r14d
movq %r12, %rdi
movq %rsi, %r15
xorl %esi, %esi
movq -0x40(%rbp), %rdx
callq 0x1110
movq %r15, %rdx
movl 0x28(%r15), %eax
xorl %ecx, %ecx
cmpl %eax, %r14d
jb 0x4b0a
movl $0xfffffff7, (%r12,%rcx) # imm = 0xFFFFFFF7
incl %r14d
addq $0x4, %rcx
cmpq %r13, %rcx
jb 0x4afd
movq -0x50(%rbp), %rax
cmpq %rbx, %rax
movl $0x0, %ebx
cmovneq %rax, %rbx
testq %rbx, %rbx
jne 0x4b42
movabsq $-0x700000008, %rax     # imm = 0xFFFFFFF8FFFFFFF8
movq %rax, (%r12)
movl $0xfffffff8, 0x8(%r12)  # imm = 0xFFFFFFF8
movq 0x8(%rdx), %rsi
movq -0x60(%rbp), %r15
addq %r15, %rsi
movl $0x1, %edx
movq -0x48(%rbp), %rdi
movq %r12, %rcx
callq *0x10(%rdi)
testl %eax, %eax
movq -0x58(%rbp), %rsp
js 0x4b88
incq %r15
incq %rbx
movq -0x30(%rbp), %rsi
movq 0x18(%rsi), %rax
addq %rax, %rax
movq %rbx, %rcx
cmpq %rax, %r15
jb 0x4abd
xorl %eax, %eax
jmp 0x4b8d
xorl %eax, %eax
retq
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_mkfs.c
// Function: write_fsinfo
static int write_fsinfo(struct ufat_device *dev, const struct fs_layout *fl)
{
	const unsigned int log2_bps =
		fl->log2_sector_size - dev->log2_block_size;
	const unsigned int block_size = 1 << dev->log2_block_size;
	uint8_t buf[block_size];

	memset(buf, 0, sizeof(buf));
	w32(buf + 0x000, 0x41615252); /* FSI_LeadSig */
	w32(buf + 0x1e4, 0x61417272); /* FSI_StrucSig */
	w32(buf + 0x1e8, fl->clusters - 3); /* FSI_Free_Count */
	w32(buf + 0x1ec, 2); /* FSI_Nxt_Free */
	w32(buf + 0x1fc, 0xaa550000); /* FSI_TrailSig */

	/* Write FSInfo and its backup */
	const ufat_block_t fsinfo_block = FSINFO_SECTOR >> log2_bps;
	const ufat_block_t fsinfo_backup_block =
		(FSINFO_SECTOR + BACKUP_SECTOR) >> log2_bps;
	if (dev->write(dev, fsinfo_block, 1, buf) < 0 ||
	    dev->write(dev, fsinfo_backup_block, 1, buf) < 0)
		return -UFAT_ERR_IO;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %r14
movl (%rdi), %ecx
movl $0x1, %edx
shlq %cl, %rdx
movl (%rsi), %r15d
subl %ecx, %r15d
leaq 0xf(%rdx), %r13
andq $-0x10, %r13
movq %rsp, %rbx
movq %rbx, -0x30(%rbp)
subq %r13, %rbx
movq %rbx, %rsp
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1110
movl $0x41615252, (%rbx)     # imm = 0x41615252
movl $0x61417272, 0x1e4(%rbx) # imm = 0x61417272
movl 0x28(%r12), %eax
addl $-0x3, %eax
movb %al, 0x1e8(%rbx)
movq %r13, %rcx
negq %rcx
movq -0x30(%rbp), %rdx
movb %ah, 0x1e9(%rdx,%rcx)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1ea(%rbx)
shrl $0x18, %eax
movb %al, 0x1eb(%rbx)
movl $0x2, 0x1ec(%rbx)
movl $0xaa550000, 0x1fc(%rbx) # imm = 0xAA550000
movl $0x1, %esi
movl %r15d, %ecx
shrl %cl, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq *0x10(%r14)
testl %eax, %eax
js 0x4c71
movl $0x7, %esi
movl %r15d, %ecx
shrl %cl, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rbx, %rcx
callq *0x10(%r14)
sarl $0x1f, %eax
jmp 0x4c76
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_mkfs.c
// Function: erase_blocks
static int erase_blocks(struct ufat_device *dev, ufat_block_t start,
			ufat_block_t count)
{
	const unsigned int block_size = 1 << dev->log2_block_size;
	uint8_t buf[block_size];

	memset(buf, 0, sizeof(buf));
	for (ufat_block_t i = 0; i < count; i++)
		if (dev->write(dev, start + i, 1, buf) < 0)
			return -UFAT_ERR_IO;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb (%rdi), %cl
movl $0x1, %eax
shlq %cl, %rax
movq %rdx, %r14
movq %rsi, %r15
leaq 0xf(%rax), %rcx
andq $-0x10, %rcx
movq %rsp, %r12
subq %rcx, %r12
movq %r12, %rsp
movq %r12, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x1110
movq %r14, -0x30(%rbp)
testq %r14, %r14
setne %r13b
je 0x4f16
movq %r15, %rsi
movl $0x1, %r15d
movl $0x1, %edx
movq %rbx, %rdi
movq %rsi, %r14
movq %r12, %rcx
callq *0x10(%rbx)
testl %eax, %eax
js 0x4f16
movq %r15, %r13
cmpq %r15, -0x30(%rbp)
je 0x4f0e
leaq (%r14,%r13), %rsi
movl $0x1, %edx
movq %rbx, %rdi
movq %r12, %rcx
callq *0x10(%rbx)
leaq 0x1(%r13), %r15
testl %eax, %eax
jns 0x4eeb
cmpq -0x30(%rbp), %r13
setb %r13b
movzbl %r13b, %eax
negl %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/main.c
// Function: open_output
static FILE *open_output(const char *fname)
{
	FILE *out;

	if (!fname)
		return stdout;

	out = fopen(fname, "wb");
	if (!out) {
		fprintf(stderr, "Failed to open %s for writing: %s\n",
			fname, strerror(errno));
		return NULL;
	}

	return out;
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0x540c
movq %rdi, %rbx
leaq 0x2a11(%rip), %rsi      # 0x7e07
callq 0x11a0
testq %rax, %rax
jne 0x5416
movq %rbx, %rdi
callq 0x13cc
xorl %eax, %eax
jmp 0x5416
movq 0x5bad(%rip), %rax      # 0xafc0
movq (%rax), %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 $0x388, %rsp            # imm = 0x388
movq %rsi, %rbx
movq %rdi, %r14
cmpl $0x0, 0x40(%rsi)
je 0x54c9
movq 0x38(%rbx), %rax
movq (%rax), %rsi
leaq 0x80(%rsp), %rdx
movq %r14, %rdi
callq 0x62cd
testl %eax, %eax
js 0x564d
leaq 0x18(%rsp), %rsi
leaq 0x80(%rsp), %rdx
movq %r14, %rdi
callq 0x25d0
testl %eax, %eax
jns 0x54d6
movl %eax, %edi
callq 0x1442
jmp 0x564d
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x25a4
movq 0x20(%rbx), %rdi
callq 0x53e6
movq %rax, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x5652
movq %rbx, 0x10(%rsp)
leaq 0x18(%rsp), %r15
leaq 0x38(%rsp), %r12
leaq 0x80(%rsp), %r13
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
movl $0x300, %ecx            # imm = 0x300
callq 0x263b
testl %eax, %eax
js 0x5609
movl $0x2, %ebx
jne 0x55ff
movzwl 0x6c(%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 0x2420(%rip), %rsi      # 0x7976
xorl %eax, %eax
callq 0x1140
movl $0x20, %edi
movq %r14, %rsi
callq 0x1120
movzwl 0x6e(%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
leaq 0x23f5(%rip), %rsi      # 0x7985
xorl %eax, %eax
callq 0x1140
movl $0x20, %edi
movq %r14, %rsi
callq 0x1120
movl 0x64(%rsp), %esi
andl $-0x11, %esi
movq %r14, %rdi
callq 0x636b
testb $0x10, 0x64(%rsp)
jne 0x55d1
movl 0x78(%rsp), %edx
movq %r14, %rdi
leaq 0x23a9(%rip), %rsi      # 0x7971
xorl %eax, %eax
callq 0x1140
jmp 0x55e9
movq %r14, %rdi
leaq 0x238b(%rip), %rsi      # 0x7966
leaq 0x2389(%rip), %rdx      # 0x796b
xorl %eax, %eax
callq 0x1140
xorl %ebx, %ebx
movq %r14, %rdi
leaq 0x23f5(%rip), %rsi      # 0x79ea
movq %r13, %rdx
xorl %eax, %eax
callq 0x1140
testl %ebx, %ebx
je 0x5507
jmp 0x561d
movl %eax, %ebp
movl %eax, %edi
callq 0x1468
movl $0x1, %ebx
movl %ebp, 0xc(%rsp)
jmp 0x55ff
cmpl $0x1, %ebx
jne 0x5629
cmpl $0x0, 0xc(%rsp)
js 0x563c
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movq %r14, %rsi
callq 0x5418
jmp 0x5652
movq 0x10(%rsp), %rax
movq 0x20(%rax), %rdi
movq %r14, %rsi
callq 0x5418
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x388, %rsp            # imm = 0x388
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq