// File: /workspace/github_c_makefile_star2_O0/dlbeer[P]ufat/ufat_dir.c
// Function: create_empty_dir
static int create_empty_dir(struct ufat_directory *parent,
			    ufat_cluster_t *out,
			    const struct ufat_dirent *downptr)
{
	struct ufat_dirent ent;
	ufat_cluster_t c;
	int err = ufat_alloc_chain(parent->uf, 1, &c);
	int idx;

	if (err < 0)
		return err;

	/* Clear all entries */
	err = ufat_init_dirent_cluster(parent->uf, c);
	if (err < 0) {
		ufat_free_chain(parent->uf, c);
		return err;
	}

	/* Get the first block of the dirent */
	idx = ufat_cache_open(parent->uf,
			      cluster_to_block(&parent->uf->bpb, c), 0);
	if (idx < 0) {
		ufat_free_chain(parent->uf, c);
		return idx;
	}

	ufat_cache_write(parent->uf, idx);

	/* Create "." */
	memcpy(&ent, downptr, sizeof(ent));
	ent.short_name[0] = '.';
	ent.short_name[1] = 0;
	ent.short_ext[0] = 0;
	ent.attributes = UFAT_ATTR_DIRECTORY;
	ent.first_cluster = c;
	ent.file_size = 0;
	ufat_pack_dirent(&ent, ufat_cache_data(parent->uf, idx));

	/* Create ".." */
	ent.short_name[1] = '.';
	ent.short_name[2] = 0;

	if (parent->start >= parent->uf->bpb.cluster_start)
		ent.first_cluster = block_to_cluster(&parent->uf->bpb,
						     parent->start);
	else
		ent.first_cluster = 0;

	ufat_pack_dirent(&ent,
			 ufat_cache_data(parent->uf, idx) + UFAT_DIRENT_SIZE);

	*out = c;
	return 0;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
movl $0x1, %esi
leaq 0x1c(%rsp), %rdx
callq 0x33e0
movl %eax, 0x18(%rsp)
cmpl $0x0, 0x18(%rsp)
jge 0x44f8
movl 0x18(%rsp), %eax
movl %eax, 0x84(%rsp)
jmp 0x467d
movq 0x78(%rsp), %rax
movq (%rax), %rdi
movl 0x1c(%rsp), %esi
callq 0x6560
movl %eax, 0x18(%rsp)
cmpl $0x0, 0x18(%rsp)
jge 0x4535
movq 0x78(%rsp), %rax
movq (%rax), %rdi
movl 0x1c(%rsp), %esi
callq 0x3340
movl 0x18(%rsp), %eax
movl %eax, 0x84(%rsp)
jmp 0x467d
movq 0x78(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x8(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
addq $0x28, %rdi
movl 0x1c(%rsp), %esi
callq 0x3cb0
movq 0x8(%rsp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x2660
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x14(%rsp)
jge 0x4592
movq 0x78(%rsp), %rax
movq (%rax), %rdi
movl 0x1c(%rsp), %esi
callq 0x3340
movl 0x14(%rsp), %eax
movl %eax, 0x84(%rsp)
jmp 0x467d
movq 0x78(%rsp), %rax
movq (%rax), %rdi
movl 0x14(%rsp), %esi
callq 0x4e60
movq 0x68(%rsp), %rsi
leaq 0x20(%rsp), %rdi
movl $0x48, %edx
callq 0x2140
movb $0x2e, 0x3c(%rsp)
movb $0x0, 0x3d(%rsp)
movb $0x0, 0x45(%rsp)
movl $0x10, 0x4c(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x5c(%rsp)
movl $0x0, 0x60(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
movl 0x14(%rsp), %esi
callq 0x4ea0
movq %rax, %rsi
leaq 0x20(%rsp), %rdi
callq 0x68a0
movb $0x2e, 0x3d(%rsp)
movb $0x0, 0x3e(%rsp)
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x78(%rsp), %rcx
movq (%rcx), %rcx
cmpq 0x48(%rcx), %rax
jb 0x463d
movq 0x78(%rsp), %rax
movq (%rax), %rdi
addq $0x28, %rdi
movq 0x78(%rsp), %rax
movq 0x18(%rax), %rsi
callq 0x4ed0
movl %eax, 0x5c(%rsp)
jmp 0x4645
movl $0x0, 0x5c(%rsp)
movq 0x78(%rsp), %rax
movq (%rax), %rdi
movl 0x14(%rsp), %esi
callq 0x4ea0
movq %rax, %rsi
addq $0x20, %rsi
leaq 0x20(%rsp), %rdi
callq 0x68a0
movl 0x1c(%rsp), %ecx
movq 0x70(%rsp), %rax
movl %ecx, (%rax)
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
addq $0x88, %rsp
retq
nopl (%rax)