// File: /workspace/github_c_makefile_star2_O0/lb3361[P]dosfs/ff.c
// Function: load_xdir
static FRESULT load_xdir (	/* FR_INT_ERR: invalid entry block */
	DIR* dp					/* Reading direcotry object pointing top of the entry block to load */
)
{
	FRESULT res;
	UINT i, sz_ent;
	BYTE* dirb = dp->obj.fs->dirbuf;	/* Pointer to the on-memory direcotry entry block 85+C0+C1s */


	/* Load file-directory entry */
	res = move_window(dp->obj.fs, dp->sect);
	if (res != FR_OK) return res;
	if (dp->dir[XDIR_Type] != ET_FILEDIR) return FR_INT_ERR;	/* Invalid order */
	mem_cpy(dirb + 0 * SZDIRE, dp->dir, SZDIRE);
	sz_ent = (dirb[XDIR_NumSec] + 1) * SZDIRE;
	if (sz_ent < 3 * SZDIRE || sz_ent > 19 * SZDIRE) return FR_INT_ERR;

	/* Load stream-extension entry */
	res = dir_next(dp, 0);
	if (res == FR_NO_FILE) res = FR_INT_ERR;	/* It cannot be */
	if (res != FR_OK) return res;
	res = move_window(dp->obj.fs, dp->sect);
	if (res != FR_OK) return res;
	if (dp->dir[XDIR_Type] != ET_STREAM) return FR_INT_ERR;	/* Invalid order */
	mem_cpy(dirb + 1 * SZDIRE, dp->dir, SZDIRE);
	if (MAXDIRB(dirb[XDIR_NumName]) > sz_ent) return FR_INT_ERR;

	/* Load file-name entries */
	i = 2 * SZDIRE;	/* Name offset to load */
	do {
		res = dir_next(dp, 0);
		if (res == FR_NO_FILE) res = FR_INT_ERR;	/* It cannot be */
		if (res != FR_OK) return res;
		res = move_window(dp->obj.fs, dp->sect);
		if (res != FR_OK) return res;
		if (dp->dir[XDIR_Type] != ET_FILENAME) return FR_INT_ERR;	/* Invalid order */
		if (i < MAXDIRB(FF_MAX_LFN)) mem_cpy(dirb + i, dp->dir, SZDIRE);
	} while ((i += SZDIRE) < sz_ent);

	/* Sanity check (do it for only accessible object) */
	if (i <= MAXDIRB(FF_MAX_LFN)) {
		if (xdir_sum(dirb) != ld_word(dirb + XDIR_SetSum)) return FR_INT_ERR;
	}
	return FR_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x6480
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xf7a3
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf9aa
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movzbl (%rax), %eax
cmpl $0x85, %eax
je 0xf7c1
movl $0x2, -0x4(%rbp)
jmp 0xf9aa
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movl $0x20, %edx
callq 0x6d20
movq -0x28(%rbp), %rax
movzbl 0x1(%rax), %eax
addl $0x1, %eax
shll $0x5, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x60, -0x1c(%rbp)
jb 0xf7f7
cmpl $0x260, -0x1c(%rbp)     # imm = 0x260
jbe 0xf803
movl $0x2, -0x4(%rbp)
jmp 0xf9aa
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x8b90
movl %eax, -0x14(%rbp)
cmpl $0x4, -0x14(%rbp)
jne 0xf81e
movl $0x2, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xf82f
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf9aa
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x6480
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xf857
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf9aa
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movzbl (%rax), %eax
cmpl $0xc0, %eax
je 0xf875
movl $0x2, -0x4(%rbp)
jmp 0xf9aa
movq -0x28(%rbp), %rdi
addq $0x20, %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movl $0x20, %edx
callq 0x6d20
movq -0x28(%rbp), %rax
movzbl 0x23(%rax), %eax
addl $0x2c, %eax
movl $0xf, %ecx
xorl %edx, %edx
divl %ecx
shll $0x5, %eax
cmpl -0x1c(%rbp), %eax
jbe 0xf8b7
movl $0x2, -0x4(%rbp)
jmp 0xf9aa
movl $0x40, -0x18(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x8b90
movl %eax, -0x14(%rbp)
cmpl $0x4, -0x14(%rbp)
jne 0xf8d9
movl $0x2, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xf8ea
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf9aa
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x6480
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xf912
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0xf9aa
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movzbl (%rax), %eax
cmpl $0xc1, %eax
je 0xf92d
movl $0x2, -0x4(%rbp)
jmp 0xf9aa
cmpl $0x260, -0x18(%rbp)     # imm = 0x260
jae 0xf952
movq -0x28(%rbp), %rdi
movl -0x18(%rbp), %eax
addq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rsi
movl $0x20, %edx
callq 0x6d20
jmp 0xf954
movl -0x18(%rbp), %eax
addl $0x20, %eax
movl %eax, -0x18(%rbp)
cmpl -0x1c(%rbp), %eax
jb 0xf8be
cmpl $0x260, -0x18(%rbp)     # imm = 0x260
ja 0xf9a3
movq -0x28(%rbp), %rdi
callq 0xf100
movzwl %ax, %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rdi
addq $0x2, %rdi
callq 0x9390
movw %ax, %cx
movl -0x2c(%rbp), %eax
movzwl %cx, %ecx
cmpl %ecx, %eax
je 0xf9a1
movl $0x2, -0x4(%rbp)
jmp 0xf9aa
jmp 0xf9a3
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)