// File: /workspace/github_c_makefile_star2_O0/dlbeer[P]ufat/ufat.c
// Function: cache_flush
static int cache_flush(struct ufat *uf, unsigned int cache_index)
{
	struct ufat_cache_desc *d = &uf->cache_desc[cache_index];

	if (!(d->flags & UFAT_CACHE_FLAG_DIRTY) ||
	    !(d->flags & UFAT_CACHE_FLAG_PRESENT))
		return 0;

	if (uf->dev->write(uf->dev, d->index, 1,
			   ufat_cache_data(uf, cache_index)) < 0)
		return -UFAT_ERR_IO;

	uf->stat.cache_flush++;
	uf->stat.write++;
	uf->stat.write_blocks++;

	/* If this block is part of the FAT, mirror it to the other FATs. Not
	 * a fatal error if this fails.
	 */
	if (d->index >= uf->bpb.fat_start &&
	    d->index < uf->bpb.fat_start + uf->bpb.fat_size) {
		unsigned int i;
		ufat_block_t b = d->index;

		for (i = 1; i < uf->bpb.fat_count; i++) {
			b += uf->bpb.fat_size;
			uf->dev->write(uf->dev, b, 1,
				       ufat_cache_data(uf, cache_index));

			uf->stat.write++;
			uf->stat.write_blocks++;
		}
	}

	d->flags &= ~UFAT_CACHE_FLAG_DIRTY;
	return 0;
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x58(%rsp)
movl %esi, 0x54(%rsp)
movq 0x58(%rsp), %rax
addq $0x80, %rax
movl 0x54(%rsp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x2406
movq 0x48(%rsp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x2413
movl $0x0, 0x64(%rsp)
jmp 0x25aa
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x58(%rsp), %rdi
movl 0x54(%rsp), %esi
callq 0x2900
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rax, %rcx
movq 0x30(%rsp), %rax
movl $0x1, %edx
callq *%rax
cmpl $0x0, %eax
jge 0x2478
movl $0xffffffff, 0x64(%rsp) # imm = 0xFFFFFFFF
jmp 0x25aa
movq 0x58(%rsp), %rax
movl 0x24(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x24(%rax)
movq 0x58(%rsp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq 0x58(%rsp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x58(%rsp), %rcx
cmpq 0x30(%rcx), %rax
jb 0x2596
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x58(%rsp), %rcx
movq 0x30(%rcx), %rcx
movq 0x58(%rsp), %rdx
addq 0x38(%rdx), %rcx
cmpq %rcx, %rax
jae 0x2596
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movl $0x1, 0x44(%rsp)
movl 0x44(%rsp), %eax
movq 0x58(%rsp), %rcx
cmpl 0x40(%rcx), %eax
jae 0x2594
movq 0x58(%rsp), %rax
movq 0x38(%rax), %rax
addq 0x38(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rdi
movl 0x54(%rsp), %esi
callq 0x2900
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rax, %rcx
movq 0x18(%rsp), %rax
movl $0x1, %edx
callq *%rax
movq 0x58(%rsp), %rax
movl 0xc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xc(%rax)
movq 0x58(%rsp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
movl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x44(%rsp)
jmp 0x24f4
jmp 0x2596
movq 0x48(%rsp), %rax
movl (%rax), %ecx
andl $-0x2, %ecx
movl %ecx, (%rax)
movl $0x0, 0x64(%rsp)
movl 0x64(%rsp), %eax
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)