LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat.c
// Function: ufat_read_fat
int ufat_read_fat(struct ufat *uf, ufat_cluster_t index,
		  ufat_cluster_t *out)
{
	if (index >= uf->bpb.num_clusters)
		return -UFAT_ERR_INVALID_CLUSTER;

	switch (uf->bpb.type) {
	case UFAT_TYPE_FAT12: return read_fat12(uf, index, out);
	case UFAT_TYPE_FAT16: return read_fat16(uf, index, out);
	case UFAT_TYPE_FAT32: return read_fat32(uf, index, out);
	}

	return 0;
}

// Assembly:
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
cmpl %esi, 0x50(%rdi)
jbe 0x2182
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movl 0x28(%rdi), %ecx
cmpl $0x20, %ecx
je 0x20a5
cmpl $0x10, %ecx
je 0x2044
xorl %eax, %eax
cmpl $0xc, %ecx
jne 0x2178
movl %ebp, %r15d
shrl %r15d
leal (%r15,%r15,2), %esi
incl %esi
leaq 0x7(%rsp), %rdx
movq %r14, %rdi
callq 0x24b6
testl %eax, %eax
js 0x2178
leal (%r15,%r15,2), %esi
testb $0x1, %bpl
jne 0x212c
leaq 0x6(%rsp), %rdx
movq %r14, %rdi
callq 0x24b6
testl %eax, %eax
js 0x2178
movzbl 0x6(%rsp), %ecx
movzbl 0x7(%rsp), %eax
andl $0xf, %eax
shll $0x8, %eax
jmp 0x2150
movq (%r14), %rax
movl (%rax), %r15d
decl %r15d
movl %ebp, %esi
movl %r15d, %ecx
shrl %cl, %esi
addq 0x30(%r14), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x2178
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r15d, %ecx
shll %cl, %edx
notl %edx
movq (%r14), %rcx
movb (%rcx), %cl
shll %cl, %eax
andl %ebp, %edx
addq %r14, %rax
movzwl 0x180(%rax,%rdx,2), %eax
cmpw $-0x8, %ax
jae 0x2114
cmpw $-0x9, %ax
je 0x2124
movl %eax, (%rbx)
jmp 0x2176
movq (%r14), %rax
movl (%rax), %r15d
addl $-0x2, %r15d
movl %ebp, %esi
movl %r15d, %ecx
shrl %cl, %esi
addq 0x30(%r14), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x2178
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r15d, %ecx
shll %cl, %edx
notl %edx
movq (%r14), %rcx
movb (%rcx), %cl
shll %cl, %eax
andl %ebp, %edx
addq %r14, %rax
shll $0x2, %edx
movzbl 0x182(%rdx,%rax), %esi
movzbl 0x183(%rdx,%rax), %ecx
shll $0x10, %esi
movzwl 0x180(%rdx,%rax), %eax
orl %esi, %eax
andl $0xf, %ecx
shll $0x18, %ecx
orl %eax, %ecx
cmpl $0xffffff8, %ecx        # imm = 0xFFFFFF8
jb 0x211c
movl $0xffffff8, (%rbx)      # imm = 0xFFFFFF8
jmp 0x2176
cmpl $0xffffff7, %ecx        # imm = 0xFFFFFF7
jne 0x2174
movl $0xffffff7, (%rbx)      # imm = 0xFFFFFF7
jmp 0x2176
addl $0x2, %esi
leaq 0x6(%rsp), %rdx
movq %r14, %rdi
callq 0x24b6
testl %eax, %eax
js 0x2178
movzbl 0x6(%rsp), %ecx
shll $0x4, %ecx
movzbl 0x7(%rsp), %eax
shrl $0x4, %eax
orl %ecx, %eax
cmpl $0xff7, %eax            # imm = 0xFF7
movl $0xffffff7, %ecx        # imm = 0xFFFFFF7
cmovnel %eax, %ecx
cmpl $0xff0, %eax            # imm = 0xFF0
movl $0xffffff8, %edx        # imm = 0xFFFFFF8
cmovel %edx, %ecx
cmpl $0xff8, %eax            # imm = 0xFF8
cmovael %edx, %ecx
movl %ecx, (%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat.c
// Function: ufat_write_fat
int ufat_write_fat(struct ufat *uf, ufat_cluster_t index,
		   ufat_cluster_t in)
{
	if (index >= uf->bpb.num_clusters)
		return -UFAT_ERR_INVALID_CLUSTER;

	switch (uf->bpb.type) {
	case UFAT_TYPE_FAT12: return write_fat12(uf, index, in);
	case UFAT_TYPE_FAT16: return write_fat16(uf, index, in);
	case UFAT_TYPE_FAT32: return write_fat32(uf, index, in);
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl $0xfffffffb, %r15d      # imm = 0xFFFFFFFB
cmpl %esi, 0x50(%rdi)
jbe 0x2336
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movl 0x28(%rdi), %eax
cmpl $0x20, %eax
je 0x2291
cmpl $0x10, %eax
je 0x2230
xorl %r15d, %r15d
cmpl $0xc, %eax
jne 0x2336
movl %ebp, %eax
shrl %eax
leal (%rax,%rax,2), %r12d
testb $0x1, %bpl
jne 0x22f3
movzbl %bl, %edx
movq %r14, %rdi
movl %r12d, %esi
movl $0xff, %ecx
callq 0x2516
testl %eax, %eax
js 0x2333
incl %r12d
shrl $0x8, %ebx
andl $0xf, %ebx
movq %r14, %rdi
movl %r12d, %esi
movl %ebx, %edx
movl $0xf, %ecx
jmp 0x2326
movq (%r14), %rax
movl (%rax), %r12d
decl %r12d
movl %ebp, %esi
movl %r12d, %ecx
shrl %cl, %esi
addq 0x30(%r14), %rsi
xorl %r15d, %r15d
movq %r14, %rdi
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x22ee
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r12d, %ecx
shll %cl, %edx
incl 0x20(%r14)
movl %eax, %ecx
shlq $0x4, %rcx
orb $0x1, 0x80(%r14,%rcx)
movq (%r14), %rcx
movb (%rcx), %cl
shll %cl, %eax
notl %edx
andl %ebp, %edx
addq %r14, %rax
movw %bx, 0x180(%rax,%rdx,2)
jmp 0x2336
movq (%r14), %rax
movl (%rax), %r12d
addl $-0x2, %r12d
movl %ebp, %esi
movl %r12d, %ecx
shrl %cl, %esi
addq 0x30(%r14), %rsi
xorl %r15d, %r15d
movq %r14, %rdi
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x22ee
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r12d, %ecx
shll %cl, %edx
incl 0x20(%r14)
movl %eax, %ecx
shlq $0x4, %rcx
orb $0x1, 0x80(%r14,%rcx)
notl %edx
movq (%r14), %rcx
movb (%rcx), %cl
shll %cl, %eax
andl %ebp, %edx
addq %r14, %rax
shll $0x2, %edx
movl %ebx, 0x180(%rdx,%rax)
jmp 0x2336
movl %eax, %r15d
jmp 0x2336
leal 0x1(%r12), %esi
movl %ebx, %eax
shlb $0x4, %al
movzbl %al, %edx
movq %r14, %rdi
movl $0xf0, %ecx
callq 0x2516
testl %eax, %eax
js 0x2333
addl $0x2, %r12d
shrl $0x4, %ebx
movzbl %bl, %edx
movq %r14, %rdi
movl %r12d, %esi
movl $0xff, %ecx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2516
movl %eax, %r15d
movl %r15d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat.c
// Function: ufat_free_chain
int ufat_free_chain(struct ufat *uf, ufat_cluster_t c)
{
	while (UFAT_CLUSTER_IS_PTR(c)) {
		ufat_cluster_t next;
		int i = ufat_read_fat(uf, c, &next);

		if (i < 0)
			return i;

		i = ufat_write_fat(uf, c, UFAT_CLUSTER_FREE);
		if (i < 0)
			return i;

		c = next;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %esi, %r15d
movq %rdi, %rbx
leaq 0xc(%rsp), %r14
leal -0x2(%r15), %eax
cmpl $0xfffffed, %eax        # imm = 0xFFFFFED
ja 0x239d
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x1fb2
xorl %r12d, %r12d
testl %eax, %eax
js 0x2394
movq %rbx, %rdi
movl %r15d, %esi
xorl %edx, %edx
callq 0x21ad
testl %eax, %eax
js 0x2394
movb $0x1, %r12b
movl 0xc(%rsp), %r15d
jmp 0x2396
movl %eax, %ebp
testb %r12b, %r12b
jne 0x2359
jmp 0x239f
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat.c
// Function: ufat_alloc_chain
int ufat_alloc_chain(struct ufat *uf, unsigned int count, ufat_cluster_t *out)
{
	ufat_cluster_t chain = UFAT_CLUSTER_EOC;

	while (count) {
		int err = alloc_cluster(uf, &chain, chain);

		if (err < 0) {
			ufat_free_chain(uf, chain);
			return err;
		}

		count--;
	}

	*out = chain;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, 0x10(%rsp)
movl %esi, %ebx
movq %rdi, %r14
movl $0xffffff8, (%rsp)      # imm = 0xFFFFFF8
testl %ebx, %ebx
je 0x2491
movl 0x50(%r14), %r12d
movl $0xfffffff1, %ebp       # imm = 0xFFFFFFF1
addl $-0x2, %r12d
je 0x2470
movl %ebx, 0x8(%rsp)
movl %r12d, %ebp
movl (%rsp), %r15d
movl 0x78(%r14), %eax
leal 0x2(%rax), %r13d
incl %eax
xorl %edx, %edx
divl %r12d
movl %edx, 0x78(%r14)
cmpl $0xff0, %r13d           # imm = 0xFF0
jne 0x241b
movl $0x4, %ecx
cmpl $0xc, 0x28(%r14)
je 0x244e
movq %r14, %rdi
movl %r13d, %esi
leaq 0xc(%rsp), %rdx
callq 0x1fb2
xorl %ecx, %ecx
orl 0xc(%rsp), %eax
jne 0x244e
movq %r14, %rdi
movl %r13d, %esi
movl (%rsp), %edx
callq 0x21ad
movl %eax, %ebx
testl %eax, %eax
cmovnsl %r13d, %r15d
movl $0x1, %ecx
testb $0x3, %cl
jne 0x2466
decl %ebp
jne 0x23f3
movl %r15d, (%rsp)
movl 0x8(%rsp), %ebx
movl $0xfffffff1, %ebp       # imm = 0xFFFFFFF1
jmp 0x2470
movl %r15d, (%rsp)
movl %ebx, %ebp
movl 0x8(%rsp), %ebx
testl %ebp, %ebp
js 0x2478
decl %ebx
jmp 0x2487
movq %r14, %rdi
movl (%rsp), %esi
callq 0x2342
movl %ebp, 0x4(%rsp)
testl %ebp, %ebp
jns 0x23cd
jmp 0x24a3
movq 0x10(%rsp), %rax
movl (%rsp), %ecx
movl %ecx, (%rax)
movl $0x0, 0x4(%rsp)
movl 0x4(%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.c
// Function: read_fat_byte
static int read_fat_byte(struct ufat *uf, unsigned int offset, uint8_t *out)
{
	ufat_block_t b = offset >> uf->dev->log2_block_size;
	unsigned int r = offset & ((1 << uf->dev->log2_block_size) - 1);
	int idx;

	idx = ufat_cache_open(uf, uf->bpb.fat_start + b, 0);
	if (idx < 0)
		return idx;

	*out = ufat_cache_data(uf, idx)[r];
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %rax
movl (%rax), %r12d
movl %r12d, %ecx
shrl %cl, %esi
movq %rdx, %r15
addq 0x30(%rdi), %rsi
xorl %r14d, %r14d
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x2507
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r12d, %ecx
shll %cl, %edx
notl %edx
movq (%rbx), %rcx
movb (%rcx), %cl
shll %cl, %eax
andl %ebp, %edx
addq %rbx, %rax
movb 0x180(%rdx,%rax), %al
movb %al, (%r15)
jmp 0x250a
movl %eax, %r14d
movl %r14d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat.c
// Function: write_fat_byte
static int write_fat_byte(struct ufat *uf, unsigned int offset,
			  uint8_t byte, uint8_t mask)
{
	ufat_block_t b = offset >> uf->dev->log2_block_size;
	unsigned int r = offset & ((1 << uf->dev->log2_block_size) - 1);
	int idx;
	uint8_t *data;

	idx = ufat_cache_open(uf, uf->bpb.fat_start + b, 0);
	if (idx < 0)
		return idx;

	data = ufat_cache_data(uf, idx);
	ufat_cache_write(uf, idx);

	data[r] = (data[r] & ~mask) | (byte & mask);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %esi, %r12d
movq %rdi, %r14
movq (%rdi), %rax
movl (%rax), %r13d
movl %r13d, %ecx
shrl %cl, %esi
movl %edx, %r15d
addq 0x30(%rdi), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x258e
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r13d, %ecx
shll %cl, %edx
notl %edx
andl %r12d, %edx
movq (%r14), %rcx
movb (%rcx), %cl
movl %eax, %esi
shll %cl, %eax
addq %r14, %rax
incl 0x20(%r14)
shlq $0x4, %rsi
orb $0x1, 0x80(%r14,%rsi)
movb 0x180(%rdx,%rax), %cl
xorb %cl, %r15b
andb %bl, %r15b
xorb %cl, %r15b
movb %r15b, 0x180(%rdx,%rax)
jmp 0x2590
movl %eax, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_dir.c
// Function: ufat_open_root
void ufat_open_root(struct ufat *uf, struct ufat_directory *dir)
{
	if (uf->bpb.root_cluster)
		dir->start = cluster_to_block(&uf->bpb, uf->bpb.root_cluster);
	else
		dir->start = uf->bpb.root_start;

	dir->uf = uf;
	dir->cur_block = dir->start;
	dir->cur_pos = 0;
}

// Assembly:
movl 0x68(%rdi), %eax
testl %eax, %eax
je 0x25b9
addl $-0x2, %eax
movb 0x2c(%rdi), %cl
shll %cl, %eax
addq 0x48(%rdi), %rax
jmp 0x25bd
movq 0x58(%rdi), %rax
movq %rax, 0x18(%rsi)
movq %rdi, (%rsi)
movq %rax, 0x10(%rsi)
movl $0x0, 0x8(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_dir.c
// Function: ufat_open_subdir
int ufat_open_subdir(struct ufat *uf, struct ufat_directory *dir,
		     const struct ufat_dirent *ent)
{
	if (!(ent->attributes & UFAT_ATTR_DIRECTORY))
		return -UFAT_ERR_NOT_DIRECTORY;

	if (ent->dirent_block == UFAT_BLOCK_NONE || !ent->first_cluster) {
		ufat_open_root(uf, dir);
		return 0;
	}

	dir->uf = uf;
	dir->start = cluster_to_block(&uf->bpb, ent->first_cluster);
	dir->cur_block = dir->start;
	dir->cur_pos = 0;

	return 0;
}

// Assembly:
movl $0xfffffff9, %eax       # imm = 0xFFFFFFF9
testb $0x10, 0x2c(%rdx)
je 0x262a
cmpq $-0x1, (%rdx)
je 0x25fd
movl 0x3c(%rdx), %eax
testl %eax, %eax
je 0x25fd
movq %rdi, (%rsi)
addl $-0x2, %eax
movb 0x2c(%rdi), %cl
shll %cl, %eax
addq 0x48(%rdi), %rax
movq %rax, 0x18(%rsi)
jmp 0x261d
movl 0x68(%rdi), %eax
testl %eax, %eax
je 0x2612
addl $-0x2, %eax
movb 0x2c(%rdi), %cl
shll %cl, %eax
addq 0x48(%rdi), %rax
jmp 0x2616
movq 0x58(%rdi), %rax
movq %rax, 0x18(%rsi)
movq %rdi, (%rsi)
movq %rax, 0x10(%rsi)
movl $0x0, 0x8(%rsi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_dir.c
// Function: ufat_dir_read
int ufat_dir_read(struct ufat_directory *dir, struct ufat_dirent *inf,
		  char *lfn_buf, int max_len)
{
	struct ufat_lfn_parser lfn;

	ufat_lfn_reset(&lfn);

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

		inf->dirent_block = dir->cur_block;
		inf->dirent_pos = dir->cur_pos;

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

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

		if (data[0x0b] == 0x0f && data[0] != 0xe5) {
			ufat_lfn_parse(&lfn, data,
				       inf->dirent_block, inf->dirent_pos);
		} else if (data[0] && data[0] != 0xe5) {
			ufat_parse_dirent(dir->uf->bpb.type, data, inf);

			if (ufat_short_checksum(inf->short_name,
						inf->short_ext) !=
			    lfn.short_checksum)
				ufat_lfn_reset(&lfn);

			if (inf->attributes & 0x08) {
				ufat_lfn_reset(&lfn);
				continue;
			}

			if (ufat_lfn_ok(&lfn)) {
				inf->lfn_block = lfn.start_block;
				inf->lfn_pos = lfn.start_pos;
			} else {
				inf->lfn_block = UFAT_BLOCK_NONE;
				inf->lfn_pos = 0;
			}

			if (lfn_buf)
				return format_name(&lfn, inf, lfn_buf, max_len);

			return 0;
		} else {
			ufat_lfn_reset(&lfn);
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %ecx, 0x4(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, %r15
movq %rdi, %r12
leaq 0x40(%rsp), %r13
movl $0xffffffff, 0x14(%r13) # imm = 0xFFFFFFFF
leaq 0x1c(%rsi), %rax
movq %rax, 0x18(%rsp)
leaq 0x25(%rsi), %rax
movq %rax, 0x10(%rsp)
leaq 0x20(%rsp), %r14
movq 0x10(%r12), %rax
movq %rax, (%r15)
movl 0x8(%r12), %eax
movl %eax, 0x8(%r15)
movq %r12, %rdi
movq %r14, %rsi
callq 0x3984
movl $0x1, %ebx
testl %eax, %eax
jne 0x26b2
movq %r12, %rdi
xorl %esi, %esi
callq 0x3853
testl %eax, %eax
je 0x26c2
movl %eax, %ebp
testl %ebx, %ebx
je 0x267f
cmpl $0x3, %ebx
je 0x267f
jmp 0x279f
movb 0x20(%rsp), %al
cmpb $0xf, 0x2b(%rsp)
sete %cl
cmpb $-0x1b, %al
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x26ee
movq (%r15), %rdx
movl 0x8(%r15), %ecx
movq %r13, %rdi
movq %r14, %rsi
callq 0x405a
jmp 0x2704
movzbl %al, %eax
testl %eax, %eax
je 0x26fc
cmpl $0xe5, %eax
jne 0x2708
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
xorl %ebx, %ebx
jmp 0x26b4
movq (%r12), %rax
movl 0x28(%rax), %edi
movq %r14, %rsi
movq %r15, %rdx
callq 0x3b8c
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x420a
cmpb 0x4c(%rsp), %al
je 0x2737
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
testb $0x8, 0x2c(%r15)
jne 0x2757
cmpl $0x0, 0x54(%rsp)
je 0x2769
movq $-0x1, 0x10(%r15)
movl $0x0, 0x18(%r15)
jmp 0x277a
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
movl $0x3, %ebx
jmp 0x26b4
movq 0x40(%rsp), %rax
movq %rax, 0x10(%r15)
movl 0x48(%rsp), %eax
movl %eax, 0x18(%r15)
movq 0x8(%rsp), %rdx
testq %rdx, %rdx
je 0x2798
movq %r13, %rdi
movq %r15, %rsi
movl 0x4(%rsp), %ecx
callq 0x27b3
jmp 0x26b2
xorl %ebp, %ebp
jmp 0x26b4
movl %ebp, %eax
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_dir.c
// Function: ufat_dir_delete
int ufat_dir_delete(struct ufat *uf, struct ufat_dirent *ent)
{
	int err;

	if (ent->dirent_block == UFAT_BLOCK_NONE || ent->short_name[0] == '.')
		return -UFAT_ERR_IMMUTABLE;

	if (ent->attributes & UFAT_ATTR_DIRECTORY) {
		err = verify_empty_dir(uf, ent);
		if (err < 0)
			return err;
	}

	err = delete_entry(uf, ent);
	if (err < 0)
		return err;

	return ufat_free_chain(uf, ent->first_cluster);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl $0xfffffff7, %ebp       # imm = 0xFFFFFFF7
cmpq $-0x1, (%rsi)
je 0x2887
movq %rsi, %r14
cmpb $0x2e, 0x1c(%rsi)
je 0x2887
movq %rdi, %rbx
testb $0x10, 0x2c(%r14)
je 0x286a
movq %rsp, %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0x25d0
testl %eax, %eax
js 0x2864
movq %rsp, %r15
leaq 0x20(%rsp), %r12
movl $0xfffffff6, %r13d      # imm = 0xFFFFFFF6
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x263b
testl %eax, %eax
js 0x2850
movl $0x2, %ecx
jne 0x2857
xorl %ecx, %ecx
cmpb $0x2e, 0x3c(%rsp)
setne %cl
cmovnel %r13d, %ebp
jmp 0x2857
movl $0x1, %ecx
movl %eax, %ebp
testl %ecx, %ecx
je 0x2826
cmpl $0x2, %ecx
jne 0x2866
xorl %ebp, %ebp
jmp 0x2866
movl %eax, %ebp
testl %ebp, %ebp
js 0x2887
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2898
testl %eax, %eax
js 0x2885
movl 0x3c(%r14), %esi
movq %rbx, %rdi
callq 0x2342
movl %eax, %ebp
movl %ebp, %eax
addq $0x68, %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_dir.c
// Function: delete_entry
static int delete_entry(struct ufat *uf, struct ufat_dirent *ent)
{
	static const uint8_t del_marker = 0xe5;
	struct ufat_directory dir;

	dir.uf = uf;

	if (ent->lfn_block == UFAT_BLOCK_NONE) {
		dir.cur_block = ent->dirent_block;
		dir.cur_pos = ent->dirent_pos;
	} else {
		dir.cur_block = ent->lfn_block;
		dir.cur_pos = ent->lfn_pos;
	}

	for (;;) {
		int err;

		err = ufat_write_raw_dirent(&dir, &del_marker, 1);
		if (err < 0)
			return err;

		if (dir.cur_block == ent->dirent_block &&
		    dir.cur_pos == ent->dirent_pos)
			break;

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

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rbx
movq %rdi, (%rsp)
movq 0x10(%rsi), %rax
movl $0x18, %ecx
cmpq $-0x1, %rax
jne 0x28c2
movq (%rbx), %rax
movl $0x8, %ecx
movq %rsp, %r14
movq %rax, 0x10(%r14)
movl (%rbx,%rcx), %eax
movl %eax, 0x8(%r14)
leaq 0x48aa(%rip), %r15      # 0x7181
movl $0x1, %r12d
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x37d8
testl %eax, %eax
js 0x2922
movq 0x10(%rsp), %rax
cmpq (%rbx), %rax
jne 0x290a
movl 0x8(%rsp), %eax
movl $0x2, %r12d
cmpl 0x8(%rbx), %eax
je 0x2924
movq %r14, %rdi
xorl %esi, %esi
callq 0x3853
movl %eax, %r12d
testl %eax, %eax
cmovsl %eax, %ebp
shrl $0x1f, %r12d
jmp 0x2924
movl %eax, %ebp
testl %r12d, %r12d
je 0x28d7
cmpl $0x2, %r12d
jne 0x2931
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_dir.c
// Function: ufat_dir_create
int ufat_dir_create(struct ufat_directory *dir, struct ufat_dirent *ent,
		    const char *name)
{
	struct ufat_dirent check;
	int err;

	if (!ufat_lfn_is_legal(name))
		return -UFAT_ERR_ILLEGAL_NAME;

	if (!ufat_dir_find(dir, name, &check))
		return -UFAT_ERR_FILE_EXISTS;

	err = create_empty_dir(dir, &ent->first_cluster, ent);
	if (err < 0)
		return err;

	ent->file_size = 0;
	ent->attributes = (ent->attributes & UFAT_ATTR_USER) |
		UFAT_ATTR_DIRECTORY;

	err = insert_dirent(dir, ent, name);
	if (err < 0) {
		ufat_free_chain(dir->uf, ent->first_cluster);
		return err;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq %rdx, %rdi
callq 0x3ce3
testl %eax, %eax
je 0x2a90
leaq 0x50(%rsp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2b08
testl %eax, %eax
je 0x2a98
movq (%r14), %rdi
leaq 0x4(%rsp), %rdx
movl $0x1, %esi
callq 0x23ae
testl %eax, %eax
js 0x2aa0
movq (%r14), %rdi
movl 0x4(%rsp), %esi
callq 0x3ace
movq (%r14), %rdi
movl 0x4(%rsp), %esi
testl %eax, %eax
js 0x2aa5
addl $-0x2, %esi
movb 0x2c(%rdi), %cl
shll %cl, %esi
addq 0x48(%rdi), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x1ad5
movl %eax, %r12d
movq (%r14), %rax
testl %r12d, %r12d
js 0x2aaa
incl 0x20(%rax)
movl %r12d, %ecx
shlq $0x4, %rcx
orb $0x1, 0x80(%rax,%rcx)
leaq 0x8(%rsp), %r13
movl $0x9, %ecx
movq %r13, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movw $0x2e, %cx
movw %cx, 0x1c(%r13)
movb $0x0, 0x25(%r13)
movl $0x10, 0x2c(%r13)
movl 0x4(%rsp), %ecx
movl %ecx, 0x3c(%r13)
movl $0x0, 0x40(%r13)
movq (%rax), %rcx
movb (%rcx), %cl
movl %r12d, %edx
shll %cl, %edx
leaq (%rax,%rdx), %rsi
addq $0x180, %rsi            # imm = 0x180
movq %r13, %rdi
callq 0x3c2a
movw $0x2e, %ax
movw %ax, 0x1d(%r13)
movq (%r14), %rax
movq 0x18(%r14), %rdx
subq 0x48(%rax), %rdx
jb 0x2a64
movb 0x2c(%rax), %cl
shrq %cl, %rdx
addl $0x2, %edx
movl %edx, %ebp
leaq 0x8(%rsp), %rdi
movl %ebp, 0x3c(%rdi)
movq (%rax), %rcx
movb (%rcx), %cl
shll %cl, %r12d
leaq (%rax,%r12), %rsi
addq $0x1a0, %rsi            # imm = 0x1A0
callq 0x3c2a
movl 0x4(%rsp), %eax
movl %eax, 0x3c(%rbx)
xorl %r12d, %r12d
jmp 0x2ab6
movl $0xfffffff5, %r12d      # imm = 0xFFFFFFF5
jmp 0x2af3
movl $0xfffffff4, %r12d      # imm = 0xFFFFFFF4
jmp 0x2af3
movl %eax, %r12d
jmp 0x2ab6
movl %eax, %r12d
jmp 0x2ab1
movl 0x4(%rsp), %esi
movq %rax, %rdi
callq 0x2342
testl %r12d, %r12d
js 0x2af3
movl $0x0, 0x40(%rbx)
movl 0x2c(%rbx), %eax
andl $0x27, %eax
orl $0x10, %eax
movl %eax, 0x2c(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2b86
xorl %r12d, %r12d
testl %eax, %eax
jns 0x2af3
movl %eax, %ebp
movq (%r14), %rdi
movl 0x3c(%rbx), %esi
callq 0x2342
movl %ebp, %r12d
movl %r12d, %eax
addq $0x98, %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_dir.c
// Function: ufat_dir_find
int ufat_dir_find(struct ufat_directory *dir,
		  const char *target, struct ufat_dirent *inf)
{
	ufat_dir_rewind(dir);

	for (;;) {
		char name[UFAT_LFN_MAX_UTF8];
		int err = ufat_dir_read(dir, inf, name, sizeof(name));

		if (err)
			return err;

		if (ufat_compare_name(target, name, 0) >= 0)
			break;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x300, %rsp            # imm = 0x300
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq 0x18(%rdi), %rax
movq %rax, 0x10(%rdi)
movl $0x0, 0x8(%rdi)
movq %rsp, %r12
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl $0x300, %ecx            # imm = 0x300
callq 0x263b
testl %eax, %eax
je 0x2b54
movl %eax, %ecx
movl $0x1, %eax
movl %ecx, %ebp
jmp 0x2b69
movq %r14, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x3fd6
notl %eax
shrl $0x1e, %eax
andl $-0x2, %eax
testl %eax, %eax
je 0x2b32
cmpl $0x1, %eax
je 0x2b74
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x300, %rsp            # imm = 0x300
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_dir.c
// Function: ufat_dir_mkfile
int ufat_dir_mkfile(struct ufat_directory *dir, struct ufat_dirent *ent,
		    const char *name)
{
	struct ufat_dirent check;
	int err;

	if (!ufat_lfn_is_legal(name))
		return -UFAT_ERR_ILLEGAL_NAME;

	if (!ufat_dir_find(dir, name, &check))
		return -UFAT_ERR_FILE_EXISTS;

	ent->file_size = 0;
	ent->first_cluster = 0;
	ent->attributes &= UFAT_ATTR_USER;

	err = insert_dirent(dir, ent, name);
	if (err < 0)
		return err;

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x50, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, %rdi
callq 0x3ce3
testl %eax, %eax
je 0x2d72
leaq 0x8(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2b08
testl %eax, %eax
je 0x2d79
movq $0x0, 0x3c(%r14)
andl $0x27, 0x2c(%r14)
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x2b86
movl %eax, %ecx
sarl $0x1f, %eax
andl %ecx, %eax
jmp 0x2d7e
movl $0xfffffff5, %eax       # imm = 0xFFFFFFF5
jmp 0x2d7e
movl $0xfffffff4, %eax       # imm = 0xFFFFFFF4
addq $0x50, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_dir.c
// Function: ufat_dir_find_path
int ufat_dir_find_path(struct ufat_directory *dir,
		       const char *path, struct ufat_dirent *ent,
		       const char **path_out)
{
	int at_root = 1;

	ufat_dir_rewind(dir);

	while (*path) {
		int len = 0;

		/* Ignore blank components */
		if (*path == '/' || *path == '\\') {
			path++;
			continue;
		}

		/* Descend if necessary */
		if (!at_root) {
			int err = ufat_open_subdir(dir->uf, dir, ent);

			if (err < 0)
				return err;
		}

		/* Search for this component */
		for (;;) {
			char name[UFAT_LFN_MAX_UTF8];
			int err = ufat_dir_read(dir, ent,
						name, sizeof(name));

			if (err < 0)
				return err;

			if (err) {
				if (path_out)
					*path_out = path;
				return 1;
			}

			len = ufat_compare_name(path, name, 1);
			if (len >= 0)
				break;
		}

		/* Skip over this component */
		path += len;
		if (*path)
			path++;
		at_root = 0;
	}

	if (at_root) {
		/* Pseudo-dirent for root directory */
		memset(ent, 0, sizeof(*ent));
		ent->dirent_block = UFAT_BLOCK_NONE;
		ent->attributes = UFAT_ATTR_DIRECTORY;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x318, %rsp            # imm = 0x318
movq %rcx, 0x8(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
movq 0x18(%rdi), %rax
movq %rax, 0x10(%rdi)
movl $0x0, 0x8(%rdi)
movl $0x1, %r14d
leaq 0x10(%rsp), %r13
movzbl (%r12), %eax
cmpl $0x2f, %eax
je 0x2e7e
cmpl $0x5c, %eax
je 0x2e7e
testl %eax, %eax
je 0x2ea2
testl %r14d, %r14d
jne 0x2dfe
movq (%r15), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x25d0
testl %eax, %eax
cmovsl %eax, %ebp
js 0x2e98
movl %r14d, 0x4(%rsp)
xorl %r14d, %r14d
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movl $0x300, %ecx            # imm = 0x300
callq 0x263b
testl %eax, %eax
js 0x2e38
je 0x2e41
movl $0x1, %ecx
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x2e31
movq %r12, (%rax)
movl $0x1, %ebp
jmp 0x2e5e
movl $0x1, %ecx
movl %eax, %ebp
jmp 0x2e5e
movq %r12, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x3fd6
movl %eax, %r14d
movl %eax, %ecx
notl %ecx
shrl $0x1d, %ecx
andl $-0x4, %ecx
testl %ecx, %ecx
je 0x2e06
cmpl $0x4, %ecx
jne 0x2e91
movslq %r14d, %rax
cmpb $0x1, (%r12,%rax)
leaq (%r12,%rax), %r12
sbbq $-0x1, %r12
xorl %r14d, %r14d
xorl %ecx, %ecx
jmp 0x2e86
incq %r12
movl $0x2, %ecx
testb $0x5, %cl
je 0x2dc1
jmp 0x2ed1
movl 0x4(%rsp), %r14d
jmp 0x2e86
xorl %r14d, %r14d
movl $0x1, %ecx
jmp 0x2e86
xorl %ebp, %ebp
testl %r14d, %r14d
je 0x2ed1
xorps %xmm0, %xmm0
movups %xmm0, (%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x10(%rbx)
movq $0x0, 0x40(%rbx)
movq $-0x1, (%rbx)
movl $0x10, 0x2c(%rbx)
movl %ebp, %eax
addq $0x318, %rsp            # imm = 0x318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_dir.c
// Function: ufat_get_filename
int ufat_get_filename(struct ufat *uf,
		      const struct ufat_dirent *ent,
		      char *name_buf, int max_len)
{
	struct ufat_lfn_parser lfn;

	ufat_lfn_reset(&lfn);

	if (ent->lfn_block != UFAT_BLOCK_NONE) {
		struct ufat_directory dir;

		dir.uf = uf;
		dir.cur_block = ent->lfn_block;
		dir.cur_pos = ent->lfn_pos;

		while (!(dir.cur_block == ent->dirent_block &&
			 dir.cur_pos == ent->dirent_pos) &&
		       dir.cur_block != UFAT_BLOCK_NONE) {
			uint8_t data[UFAT_DIRENT_SIZE];
			int err;

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

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

			ufat_lfn_parse(&lfn, data,
				       dir.cur_block, dir.cur_pos);
		}
	}

	return format_name(&lfn, ent, name_buf, max_len);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rsi, %r15
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
movq 0x10(%rsi), %rax
cmpq $-0x1, %rax
je 0x2fb0
movq %rdx, 0x8(%rsp)
movl %ecx, 0x4(%rsp)
leaq 0x10(%rsp), %r12
movq %rdi, (%r12)
movq %rax, 0x10(%r12)
movl 0x18(%r15), %eax
movl %eax, 0x8(%r12)
leaq 0x30(%rsp), %r13
leaq 0x50(%rsp), %rbx
movq 0x20(%rsp), %rcx
cmpq (%r15), %rcx
jne 0x2f57
movb $0x1, %al
cmpq $-0x1, %rcx
je 0x2fa3
movl 0x8(%r15), %ecx
cmpl %ecx, 0x18(%rsp)
jne 0x2f5d
jmp 0x2fa3
cmpq $-0x1, %rcx
je 0x2fa1
movq %r12, %rdi
movq %r13, %rsi
callq 0x3984
xorl %r14d, %r14d
testl %eax, %eax
js 0x2f96
movq %r12, %rdi
xorl %esi, %esi
callq 0x3853
testl %eax, %eax
js 0x2f96
movq 0x20(%rsp), %rdx
movl 0x18(%rsp), %ecx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x405a
movb $0x1, %r14b
jmp 0x2f98
movl %eax, %ebp
testb %r14b, %r14b
jne 0x2f39
xorl %eax, %eax
jmp 0x2fa3
movb $0x1, %al
testb %al, %al
movl 0x4(%rsp), %ecx
movq 0x8(%rsp), %rdx
je 0x2fbf
leaq 0x50(%rsp), %rdi
movq %r15, %rsi
callq 0x27b3
movl %eax, %ebp
movl %ebp, %eax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_dir.c
// Function: ufat_move
int ufat_move(struct ufat_dirent *ent, struct ufat_directory *dst,
	      const char *new_name)
{
	struct ufat_dirent new_ent;
	int err;

	if (!ufat_lfn_is_legal(new_name))
		return -UFAT_ERR_ILLEGAL_NAME;

	if (!ufat_dir_find(dst, new_name, &new_ent))
		return -UFAT_ERR_FILE_EXISTS;

	if (ent->short_name[0] == '.' || ent->dirent_block == UFAT_BLOCK_NONE)
		return -UFAT_ERR_IMMUTABLE;

	memcpy(&new_ent, ent, sizeof(new_ent));
	err = insert_dirent(dst, &new_ent, new_name);
	if (err < 0)
		return err;

	err = delete_entry(dst->uf, ent);
	if (err < 0) {
		delete_entry(dst->uf, &new_ent);
		return err;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq %rdx, %rdi
callq 0x3ce3
testl %eax, %eax
je 0x305b
movq %rsp, %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2b08
testl %eax, %eax
je 0x3062
movl $0xfffffff7, %eax       # imm = 0xFFFFFFF7
cmpb $0x2e, 0x1c(%r14)
je 0x3067
cmpq $-0x1, (%r14)
je 0x3067
movq %rsp, %rax
movl $0x9, %ecx
movq %rax, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2b86
testl %eax, %eax
js 0x3067
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x2898
movl %eax, %ebp
xorl %eax, %eax
testl %ebp, %ebp
jns 0x3067
movq (%rbx), %rdi
movq %rsp, %rsi
callq 0x2898
movl %ebp, %eax
jmp 0x3067
movl $0xfffffff5, %eax       # imm = 0xFFFFFFF5
jmp 0x3067
movl $0xfffffff4, %eax       # imm = 0xFFFFFFF4
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_file.c
// Function: ufat_open_file
int ufat_open_file(struct ufat *uf, struct ufat_file *f,
		   const struct ufat_dirent *ent)
{
	if (ent->attributes & UFAT_ATTR_DIRECTORY)
		return -UFAT_ERR_NOT_FILE;

	f->uf = uf;
	f->dirent_block = ent->dirent_block;
	f->dirent_pos = ent->dirent_pos;
	f->start = ent->first_cluster;
	f->file_size = ent->file_size;
	f->prev_cluster = 0;
	f->cur_cluster = f->start;
	f->cur_pos = 0;

	return 0;
}

// Assembly:
movl $0xfffffff8, %eax       # imm = 0xFFFFFFF8
testb $0x10, 0x2c(%rdx)
jne 0x30a6
movq %rdi, (%rsi)
movq (%rdx), %rax
movq %rax, 0x8(%rsi)
movl 0x8(%rdx), %eax
movl %eax, 0x10(%rsi)
movl 0x3c(%rdx), %ecx
movl %ecx, 0x14(%rsi)
movl 0x40(%rdx), %eax
movl %eax, 0x18(%rsi)
xorl %eax, %eax
movl %eax, 0x1c(%rsi)
movl %ecx, 0x20(%rsi)
movl %eax, 0x24(%rsi)
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_file.c
// Function: advance_ptr
static int advance_ptr(struct ufat_file *f, ufat_size_t nbytes)
{
	const unsigned int log2_cluster_size =
		f->uf->dev->log2_block_size +
		f->uf->bpb.log2_blocks_per_cluster;
	ufat_size_t end_pos;
	unsigned int nclusters;
	ufat_cluster_t c = f->cur_cluster;
	ufat_cluster_t prev = f->prev_cluster;

	end_pos = f->cur_pos + nbytes;

	nclusters = (end_pos >> log2_cluster_size) -
		(f->cur_pos >> log2_cluster_size);

	while (nclusters) {
		ufat_cluster_t next;
		int i;

		i = ufat_read_fat(f->uf, c, &next);
		if (i < 0)
			return i;

		prev = c;
		c = next;
		nclusters--;
	}

	f->prev_cluster = prev;
	f->cur_cluster = c;
	f->cur_pos += nbytes;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movq (%rdi), %rax
movq (%rax), %rdx
movl 0x2c(%rax), %ecx
addl (%rdx), %ecx
movl 0x24(%rdi), %eax
movq %rsi, 0x10(%rsp)
leal (%rax,%rsi), %r13d
shrl %cl, %r13d
shrl %cl, %eax
movl 0x20(%rdi), %ebp
movl 0x1c(%rdi), %ebx
subl %eax, %r13d
leaq 0xc(%rsp), %r15
testl %r13d, %r13d
je 0x3128
movq (%r14), %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x1fb2
testl %eax, %eax
js 0x311f
movl %ebp, %ebx
movl 0xc(%rsp), %ebp
decl %r13d
jmp 0x3122
movl %eax, %r12d
testl %eax, %eax
jns 0x30fe
jmp 0x313c
movl %ebx, 0x1c(%r14)
movl %ebp, 0x20(%r14)
movq 0x10(%rsp), %rax
addl %eax, 0x24(%r14)
xorl %r12d, %r12d
movl %r12d, %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_file.c
// Function: ufat_file_read
int ufat_file_read(struct ufat_file *f, void *buf, ufat_size_t size)
{
	ufat_size_t total;
	int len;

	if (size > f->file_size - f->cur_pos)
		size = f->file_size - f->cur_pos;
	total = size;

	/* Read partial block ends */
	len = read_block_fragment(f, buf, size);
	if (len < 0)
		return len;

	buf = (char*)buf + len;
	size -= len;

	/* Read contiguous blocks within a cluster */
	for (;;) {
		len = read_blocks(f, buf, size);

		if (len < 0)
			return len;

		if (!len)
			break;

		buf = (char*)buf + len;
		size -= len;
	}

	/* Read remaining block fragment */
	len = read_block_fragment(f, buf, size);
	if (len < 0)
		return len;

	return total;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
movl 0x18(%rdi), %ebx
subl 0x24(%rdi), %ebx
movq %rsi, %r15
cmpl %edx, %ebx
cmovael %edx, %ebx
movl %ebx, %edx
callq 0x3295
testl %eax, %eax
js 0x3286
movl %eax, %ecx
addq %rcx, %r15
movl %ebx, 0xc(%rsp)
subl %eax, %ebx
movq %r14, (%rsp)
movq (%r14), %r12
movq (%r12), %rax
movl (%rax), %r13d
movl 0x2c(%r12), %edx
movl $0x1, %eax
movl %edx, %ecx
shll %cl, %eax
movl 0x24(%r14), %edi
movl %r13d, %ecx
shrl %cl, %edi
leal -0x1(%rax), %esi
andl %edi, %esi
subl %esi, %eax
movl %ebx, %ebp
shrl %cl, %ebp
cmpl %eax, %ebp
cmovael %eax, %ebp
testl %ebp, %ebp
je 0x3244
movl 0x20(%r14), %edi
addl $-0x2, %edi
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
cmpl $0xfffffed, %edi        # imm = 0xFFFFFED
ja 0x325c
movq %r15, 0x10(%rsp)
movl %edx, %ecx
shll %cl, %edi
movl %esi, %r15d
addq %rdi, %r15
addq 0x48(%r12), %r15
movl %ebp, %r14d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x192c
testl %eax, %eax
js 0x3248
movq (%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq 0x10(%rsp), %r15
movq %r15, %rcx
callq *0x8(%rdi)
testl %eax, %eax
js 0x3253
incl 0x8(%r12)
addl %ebp, 0x10(%r12)
movl %r13d, %ecx
shll %cl, %ebp
movq (%rsp), %r14
movq %r14, %rdi
movl %ebp, %esi
callq 0x30c3
testl %eax, %eax
cmovsl %eax, %ebp
movl %ebp, %eax
jmp 0x325c
xorl %eax, %eax
jmp 0x325c
movq (%rsp), %r14
movq 0x10(%rsp), %r15
jmp 0x325c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq (%rsp), %r14
testl %eax, %eax
js 0x3286
je 0x326e
movl %eax, %ecx
addq %rcx, %r15
subl %eax, %ebx
jmp 0x318b
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0x3295
testl %eax, %eax
movl 0xc(%rsp), %ecx
cmovsl %eax, %ecx
movl %ecx, %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_file.c
// Function: read_block_fragment
static int read_block_fragment(struct ufat_file *f, char *buf, ufat_size_t size)
{
	const struct ufat_bpb *bpb = &f->uf->bpb;
	const unsigned int log2_block_size = f->uf->dev->log2_block_size;
	const unsigned int block_size = 1 << log2_block_size;
	const unsigned int offset = f->cur_pos & (block_size - 1);
	const unsigned int remainder = block_size - offset;
	const ufat_block_t cur_block =
		cluster_to_block(bpb, f->cur_cluster) +
		((f->cur_pos >> log2_block_size) &
		 ((1 << bpb->log2_blocks_per_cluster) - 1));
	int i;

	if (size > remainder)
		size = remainder;
	size &= (block_size - 1);
	if (!size)
		return 0;

	if (!UFAT_CLUSTER_IS_PTR(f->cur_cluster))
		return -UFAT_ERR_INVALID_CLUSTER;

	i = ufat_cache_open(f->uf, cur_block, 0);
	if (i < 0)
		return i;

	memcpy(buf, ufat_cache_data(f->uf, i) + offset, size);
	i = advance_ptr(f, size);
	if (i < 0)
		return i;

	return size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r14
movq (%rdi), %rdi
movq (%rdi), %rax
movb (%rax), %al
movl $0x1, %ebx
movl %eax, %ecx
shll %cl, %ebx
movq %rsi, %r15
movl 0x24(%r14), %esi
leal -0x1(%rbx), %r12d
movl %r12d, %ebp
andl %esi, %ebp
subl %ebp, %ebx
movl 0x20(%r14), %r10d
addl $-0x2, %r10d
movb 0x2c(%rdi), %r8b
movl %r10d, %r9d
movl %r8d, %ecx
shll %cl, %r9d
movl %eax, %ecx
shrl %cl, %esi
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
movl %r8d, %ecx
shll %cl, %r11d
cmpl %edx, %ebx
cmovael %edx, %ebx
andl %r12d, %ebx
je 0x334f
movl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
cmpl $0xfffffed, %r10d       # imm = 0xFFFFFED
ja 0x3351
addq 0x48(%rdi), %r9
notl %r11d
andl %r11d, %esi
addq %r9, %rsi
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x3351
movq (%r14), %rdx
movq (%rdx), %rcx
movb (%rcx), %cl
shll %cl, %eax
addq %rdx, %rax
movl %ebp, %ecx
leaq (%rcx,%rax), %rsi
addq $0x180, %rsi            # imm = 0x180
movl %ebx, %edx
movq %r15, %rdi
callq 0x1160
movq %r14, %rdi
movl %ebx, %esi
callq 0x30c3
testl %eax, %eax
cmovsl %eax, %ebx
movl %ebx, %eax
jmp 0x3351
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_file.c
// Function: ufat_file_write
int ufat_file_write(struct ufat_file *f, const void *buf, ufat_size_t len)
{
	const ufat_size_t max_write = ~f->cur_pos;
	ufat_size_t total;
	int i;

	if (len > max_write)
		len = max_write;
	total = len;

	/* Write a partial block fragment */
	i = write_block_fragment(f, buf, len);
	if (i < 0)
		return i;

	buf = (const char*)buf + i;
	len -= i;

	/* Write complete blocks */
	for (;;) {
		i = write_blocks(f, buf, len);

		if (i < 0)
			return i;

		if (!i)
			break;

		buf = (const char*)buf + i;
		len -= i;
	}

	/* Write a partial block fragment */
	i = write_block_fragment(f, buf, len);
	if (i < 0)
		return i;

	if (f->cur_pos > f->file_size) {
		i = set_size(f, f->cur_pos);
		if (i < 0)
			return i;
	}

	return total;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %r15
movl 0x24(%rdi), %ebx
notl %ebx
cmpl %edx, %ebx
cmovael %edx, %ebx
movl %ebx, %edx
callq 0x34a8
testl %eax, %eax
js 0x3499
movl %eax, %ecx
addq %rcx, %r14
movq %r14, (%rsp)
movl %ebx, 0xc(%rsp)
subl %eax, %ebx
movq %r15, 0x10(%rsp)
movq (%r15), %r12
movq (%r12), %rax
movl (%rax), %r13d
movb 0x2c(%r12), %cl
movl $0x1, %eax
shll %cl, %eax
movl 0x24(%r15), %edx
movl %r13d, %ecx
shrl %cl, %edx
leal -0x1(%rax), %r14d
andl %edx, %r14d
subl %r14d, %eax
movl %ebx, %ebp
shrl %cl, %ebp
cmpl %eax, %ebp
cmovael %eax, %ebp
testl %ebp, %ebp
je 0x3446
movq %r15, %rdi
callq 0x375c
testl %eax, %eax
js 0x3448
movl 0x20(%r15), %eax
addl $-0x2, %eax
movb 0x2c(%r12), %cl
shll %cl, %eax
movl %r14d, %r15d
addq 0x48(%r12), %r15
addq %rax, %r15
movl %ebp, %r14d
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1a8a
movq (%r12), %rdi
movq %r15, %rsi
movq %r14, %rdx
movq (%rsp), %r14
movq %r14, %rcx
callq *0x10(%rdi)
testl %eax, %eax
js 0x3462
incl 0xc(%r12)
addl %ebp, 0x14(%r12)
movl %r13d, %ecx
shll %cl, %ebp
movq 0x10(%rsp), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x30c3
testl %eax, %eax
cmovsl %eax, %ebp
movl %ebp, %eax
jmp 0x344c
xorl %eax, %eax
movq (%rsp), %r14
testl %eax, %eax
js 0x3499
je 0x346e
movl %eax, %ecx
addq %rcx, %r14
movq %r14, (%rsp)
subl %eax, %ebx
jmp 0x339b
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %r15
jmp 0x344c
movq %r15, %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x34a8
testl %eax, %eax
js 0x3499
movl 0x24(%r15), %esi
cmpl 0x18(%r15), %esi
jbe 0x3495
movq %r15, %rdi
callq 0x3585
testl %eax, %eax
js 0x3499
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_file.c
// Function: write_block_fragment
static int write_block_fragment(struct ufat_file *f, const char *buf,
				ufat_size_t size)
{
	const struct ufat_bpb *bpb = &f->uf->bpb;
	const unsigned int log2_block_size = f->uf->dev->log2_block_size;
	const unsigned int block_size = 1 << log2_block_size;
	const unsigned int offset = f->cur_pos & (block_size - 1);
	const unsigned int remainder = block_size - offset;
	ufat_block_t cur_block;
	int i;

	if (size > remainder)
		size = remainder;
	size &= (block_size - 1);
	if (!size)
		return 0;

	i = ensure_room(f);
	if (i < 0)
		return i;

	cur_block =
		cluster_to_block(bpb, f->cur_cluster) +
		((f->cur_pos >> log2_block_size) &
		 ((1 << bpb->log2_blocks_per_cluster) - 1));

	i = ufat_cache_open(f->uf, cur_block, 0);
	if (i < 0)
		return i;

	ufat_cache_write(f->uf, i);
	memcpy(ufat_cache_data(f->uf, i) + offset, buf, size);

	i = advance_ptr(f, size);
	if (i < 0)
		return i;

	return size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %r13
movq (%r13), %rax
movl (%rax), %ebp
movl $0x1, %ebx
movl %ebp, %ecx
shll %cl, %ebx
leal -0x1(%rbx), %eax
movl 0x24(%rdi), %r12d
andl %eax, %r12d
subl %r12d, %ebx
cmpl %edx, %ebx
cmovael %edx, %ebx
andl %eax, %ebx
je 0x3574
movq %rsi, %r15
movq %rdi, %r14
callq 0x375c
testl %eax, %eax
js 0x3576
movl 0x20(%r14), %edx
addl $-0x2, %edx
movb 0x2c(%r13), %al
movl %eax, %ecx
shll %cl, %edx
addq 0x48(%r13), %rdx
movl 0x24(%r14), %edi
movl %ebp, %ecx
shrl %cl, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %eax, %ecx
shll %cl, %esi
notl %esi
andl %edi, %esi
addq %rdx, %rsi
movq (%r14), %rdi
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x3576
movq (%r14), %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 %r12d, %ecx
leaq (%rcx,%rax), %rdi
addq $0x180, %rdi            # imm = 0x180
movl %ebx, %edx
movq %r15, %rsi
callq 0x1160
movq %r14, %rdi
movl %ebx, %esi
callq 0x30c3
testl %eax, %eax
cmovsl %eax, %ebx
movl %ebx, %eax
jmp 0x3576
xorl %eax, %eax
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_file.c
// Function: set_size
static int set_size(struct ufat_file *f, ufat_size_t s)
{
	int idx = ufat_cache_open(f->uf, f->dirent_block, 0);

	if (idx < 0)
		return idx;

	ufat_cache_write(f->uf, idx);
	w32(ufat_cache_data(f->uf, idx) +
	    f->dirent_pos * UFAT_DIRENT_SIZE + 0x1c, s);

	f->file_size = s;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rdi
movq 0x8(%r14), %rsi
xorl %ebx, %ebx
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x35d4
movq (%r14), %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 0x10(%r14), %ecx
shll $0x5, %ecx
movl %ebp, 0x19c(%rcx,%rax)
movl %ebp, 0x18(%r14)
jmp 0x35d6
movl %eax, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_file.c
// Function: ufat_file_truncate
int ufat_file_truncate(struct ufat_file *f)
{
	const unsigned int
		cluster_size = 1 << (f->uf->bpb.log2_blocks_per_cluster +
				     f->uf->dev->log2_block_size);
	int err;

	err = set_size(f, f->cur_pos);
	if (err < 0)
		return err;

	if (!f->file_size) {
		ufat_cluster_t old_start = f->start;

		err = set_start(f, 0);
		if (err < 0)
			return err;

		if (UFAT_CLUSTER_IS_PTR(old_start)) {
			err = ufat_free_chain(f->uf, old_start);
			if (err < 0)
				return err;
		}

		f->cur_cluster = 0;
		return 0;
	}

	if (f->file_size & (cluster_size - 1)) {
		ufat_cluster_t tail;

		err = ufat_read_fat(f->uf, f->cur_cluster, &tail);
		if (err < 0)
			return err;

		err = ufat_write_fat(f->uf, f->cur_cluster, UFAT_CLUSTER_EOC);
		if (err < 0)
			return err;

		if (UFAT_CLUSTER_IS_PTR(tail))
			return ufat_free_chain(f->uf, tail);

		return 0;
	}

	if (UFAT_CLUSTER_IS_PTR(f->cur_cluster)) {
		err = ufat_write_fat(f->uf, f->prev_cluster, UFAT_CLUSTER_EOC);
		if (err < 0)
			return err;

		ufat_free_chain(f->uf, f->cur_cluster);
		f->cur_cluster = 0;
		return 0;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq (%rdi), %rax
movq (%rax), %rcx
movl (%rcx), %r14d
addl 0x2c(%rax), %r14d
movl 0x24(%rdi), %esi
callq 0x3585
testl %eax, %eax
js 0x36d8
movl 0x18(%rbx), %eax
testl %eax, %eax
je 0x366a
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %r14d, %ecx
shll %cl, %edx
notl %edx
testl %edx, %eax
je 0x36a1
movq (%rbx), %rdi
movl 0x20(%rbx), %esi
leaq 0xc(%rsp), %rdx
callq 0x1fb2
testl %eax, %eax
js 0x36d8
movq (%rbx), %rdi
movl 0x20(%rbx), %esi
movl $0xffffff8, %edx        # imm = 0xFFFFFF8
callq 0x21ad
testl %eax, %eax
js 0x36d8
movl 0xc(%rsp), %esi
leal -0x2(%rsi), %eax
xorl %ebp, %ebp
cmpl $0xfffffed, %eax        # imm = 0xFFFFFED
ja 0x36da
movq (%rbx), %rdi
callq 0x2342
jmp 0x36d8
movl 0x14(%rbx), %r14d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x36e5
testl %eax, %eax
js 0x36d8
leal -0x2(%r14), %eax
cmpl $0xfffffed, %eax        # imm = 0xFFFFFED
ja 0x3696
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x2342
testl %eax, %eax
js 0x36d8
movl $0x0, 0x20(%rbx)
xorl %ebp, %ebp
jmp 0x36da
movl 0x20(%rbx), %eax
addl $-0x2, %eax
xorl %ebp, %ebp
cmpl $0xfffffed, %eax        # imm = 0xFFFFFED
ja 0x36da
movq (%rbx), %rdi
movl 0x1c(%rbx), %esi
movl $0xffffff8, %edx        # imm = 0xFFFFFF8
callq 0x21ad
testl %eax, %eax
js 0x36d8
movq (%rbx), %rdi
movl 0x20(%rbx), %esi
callq 0x2342
movl $0x0, 0x20(%rbx)
jmp 0x36da
movl %eax, %ebp
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_file.c
// Function: set_start
static int set_start(struct ufat_file *f, ufat_cluster_t s)
{
	int idx = ufat_cache_open(f->uf, f->dirent_block, 0);
	uint8_t *data;

	if (idx < 0)
		return idx;

	ufat_cache_write(f->uf, idx);
	data = ufat_cache_data(f->uf, idx) + f->dirent_pos * UFAT_DIRENT_SIZE;
	w16(data + 0x14, s >> 16);
	w16(data + 0x1a, s & 0xffff);

	f->start = s;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rdi
movq 0x8(%r14), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x1ad5
testl %eax, %eax
js 0x3753
movq (%r14), %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 0x10(%r14), %ecx
shll $0x5, %ecx
movl %ebx, %edx
shrl $0x10, %edx
movb %dl, 0x194(%rcx,%rax)
movl %ebx, %edx
shrl $0x18, %edx
movb %dl, 0x195(%rcx,%rax)
movb %bl, 0x19a(%rcx,%rax)
movb %bh, 0x19b(%rcx,%rax)
movl %ebx, 0x14(%r14)
jmp 0x3755
movl %eax, %ebp
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]ufat/ufat_file.c
// Function: ensure_room
static int ensure_room(struct ufat_file *f)
{
	ufat_cluster_t c;
	int err;

	if (UFAT_CLUSTER_IS_PTR(f->cur_cluster))
		return 0;

	err = ufat_alloc_chain(f->uf, 1, &c);
	if (err < 0)
		return err;

	if (UFAT_CLUSTER_IS_PTR(f->prev_cluster))
		err = ufat_write_fat(f->uf, f->prev_cluster, c);
	else
		err = set_start(f, c);

	if (err < 0) {
		ufat_free_chain(f->uf, c);
		return err;
	}

	f->cur_cluster = c;
	return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl 0x20(%rdi), %eax
addl $-0x2, %eax
xorl %ebp, %ebp
cmpl $0xfffffee, %eax        # imm = 0xFFFFFEE
jb 0x37cf
movq %rdi, %rbx
movq (%rdi), %rdi
leaq 0x4(%rsp), %rdx
movl $0x1, %esi
callq 0x23ae
testl %eax, %eax
js 0x37a2
movl 0x1c(%rbx), %esi
leal -0x2(%rsi), %eax
cmpl $0xfffffed, %eax        # imm = 0xFFFFFED
ja 0x37a6
movq (%rbx), %rdi
movl 0x4(%rsp), %edx
callq 0x21ad
jmp 0x37b2
movl %eax, %ebp
jmp 0x37cf
movl 0x4(%rsp), %esi
movq %rbx, %rdi
callq 0x36e5
movl %eax, %ebp
testl %eax, %eax
js 0x37c3
movl 0x4(%rsp), %eax
movl %eax, 0x20(%rbx)
xorl %ebp, %ebp
jmp 0x37cf
movq (%rbx), %rdi
movl 0x4(%rsp), %esi
callq 0x2342
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq