// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
movq 0x38(%rbx), %rsi
movq 0x18(%rdi), %r14
callq 0x6314
testl %eax, %eax
jne 0xbd02
movq 0x40(%rbx), %rcx
movl $0x2, %eax
cmpb $-0x7b, (%rcx)
jne 0xbd02
xorl %edx, %edx
movb (%rcx,%rdx), %sil
movb %sil, (%r14,%rdx)
incq %rdx
cmpl $0x20, %edx
jne 0xbc75
movzbl 0x1(%r14), %r15d
leal -0x13(%r15), %ecx
cmpb $-0x11, %cl
jb 0xbd02
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7c47
movl %eax, %ecx
cmpl $0x4, %eax
movl $0x2, %eax
cmovnel %ecx, %eax
testl %eax, %eax
jne 0xbd02
movq (%rbx), %rdi
movq 0x38(%rbx), %rsi
callq 0x6314
testl %eax, %eax
jne 0xbd02
movq 0x40(%rbx), %rcx
movl $0x2, %eax
cmpb $-0x40, (%rcx)
jne 0xbd02
shll $0x5, %r15d
addq $0x20, %r15
xorl %edx, %edx
movb (%rcx,%rdx), %sil
movb %sil, 0x20(%r14,%rdx)
incq %rdx
cmpl $0x20, %edx
jne 0xbcd6
movzbl 0x23(%r14), %ecx
addl $0x2c, %ecx
imulq $0x11111112, %rcx, %rcx # imm = 0x11111112
shrq $0x20, %rcx
shll $0x5, %ecx
cmpl %r15d, %ecx
jbe 0xbd11
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40(%r14), %r12
movl $0x40, %ecx
movl $0x2, %ebp
movq %rcx, %r13
movq %rbx, %rdi
xorl %esi, %esi
callq 0x7c47
cmpl $0x4, %eax
cmovel %ebp, %eax
testl %eax, %eax
jne 0xbd02
movq (%rbx), %rdi
movq 0x38(%rbx), %rsi
callq 0x6314
testl %eax, %eax
jne 0xbd02
movq 0x40(%rbx), %rcx
movl $0x2, %eax
cmpb $-0x3f, (%rcx)
jne 0xbd02
cmpq $0x25f, %r13            # imm = 0x25F
ja 0xbd6f
xorl %edx, %edx
movb (%rcx,%rdx), %sil
movb %sil, (%r12,%rdx)
incq %rdx
cmpl $0x20, %edx
jne 0xbd5f
leaq 0x20(%r13), %rcx
addq $0x20, %r12
cmpq %r15, %rcx
jb 0xbd1f
cmpq $0x240, %r13            # imm = 0x240
ja 0xbdc5
movzbl 0x1(%r14), %ecx
shll $0x5, %ecx
addl $0x20, %ecx
xorl %edx, %edx
xorl %esi, %esi
movl $0x4, %edi
cmpl $0x2, %esi
jne 0xbda2
movl %edi, %esi
jmp 0xbdb6
rorw %dx
movl %esi, %edi
movzbl (%r14,%rdi), %r8d
addl %edx, %r8d
incl %esi
movl %esi, %edi
movl %r8d, %edx
cmpl %ecx, %edi
jb 0xbd94
cmpw 0x2(%r14), %dx
jne 0xbd02
xorl %eax, %eax
jmp 0xbd02