// File: /workspace/github_c_makefile_star2_O2/lb3361[P]dosfs/ff.c
// Function: get_fileinfo
static void get_fileinfo (
	DIR* dp,			/* Pointer to the directory object */
	FILINFO* fno		/* Pointer to the file information to be filled */
)
{
	UINT si, di;
#if FF_USE_LFN
	BYTE lcf;
	WCHAR wc, hs;
	FATFS *fs = dp->obj.fs;
#else
	TCHAR c;
#endif


	fno->fname[0] = 0;			/* Invaidate file info */
	if (dp->sect == 0) return;	/* Exit if read pointer has reached end of directory */

#if FF_USE_LFN		/* LFN configuration */
#if FF_FS_EXFAT
	if (fs->fs_type == FS_EXFAT) {	/* On the exFAT volume */
		get_xfileinfo(fs->dirbuf, fno);
		return;
	} else
#endif
	{	/* On the FAT/FAT32 volume */
		if (dp->blk_ofs != 0xFFFFFFFF) {	/* Get LFN if available */
			si = di = hs = 0;
			while (fs->lfnbuf[si] != 0) {
				wc = fs->lfnbuf[si++];		/* Get an LFN character (UTF-16) */
				if (hs == 0 && IsSurrogate(wc)) {	/* Is it a surrogate? */
					hs = wc; continue;		/* Get low surrogate */
				}
				wc = put_utf((DWORD)hs << 16 | wc, &fno->fname[di], FF_LFN_BUF - di);	/* Store it in UTF-16 or UTF-8 encoding */
				if (wc == 0) { di = 0; break; }	/* Invalid char or buffer overflow? */
				di += wc;
				hs = 0;
			}
			if (hs != 0) di = 0;	/* Broken surrogate pair? */
			fno->fname[di] = 0;		/* Terminate the LFN (null string means LFN is invalid) */
		}
	}

	si = di = 0;
	while (si < 11) {		/* Get SFN from SFN entry */
		wc = dp->dir[si++];			/* Get a char */
		if (wc == ' ') continue;	/* Skip padding spaces */
		if (wc == RDDEM) wc = DDEM;	/* Restore replaced DDEM character */
		if (si == 9 && di < FF_SFN_BUF) fno->altname[di++] = '.';	/* Insert a . if extension is exist */
#if FF_LFN_UNICODE >= 1	/* Unicode output */
		if (dbc_1st((BYTE)wc) && si != 8 && si != 11 && dbc_2nd(dp->dir[si])) {	/* Make a DBC if needed */
			wc = wc << 8 | dp->dir[si++];
		}
		wc = ff_oem2uni(wc, CODEPAGE);		/* ANSI/OEM -> Unicode */
		if (wc == 0) { di = 0; break; }		/* Wrong char in the current code page? */
		wc = put_utf(wc, &fno->altname[di], FF_SFN_BUF - di);	/* Store it in Unicode */
		if (wc == 0) { di = 0; break; }		/* Buffer overflow? */
		di += wc;
#else					/* ANSI/OEM output */
		fno->altname[di++] = (TCHAR)wc;	/* Store it without any conversion */
#endif
	}
	fno->altname[di] = 0;	/* Terminate the SFN  (null string means SFN is invalid) */

	if (fno->fname[0] == 0) {	/* If LFN is invalid, altname[] needs to be copied to fname[] */
		if (di == 0) {	/* If LFN and SFN both are invalid, this object is inaccesible */
			fno->fname[di++] = '?';
		} else {
			for (si = di = 0, lcf = NS_BODY; fno->altname[si]; si++, di++) {	/* Copy altname[] to fname[] with case information */
				wc = (WCHAR)fno->altname[si];
				if (wc == '.') lcf = NS_EXT;
				if (IsUpper(wc) && (dp->dir[DIR_NTres] & lcf)) wc += 0x20;
				fno->fname[di] = (TCHAR)wc;
			}
		}
		fno->fname[di] = 0;	/* Terminate the LFN */
		if (!dp->dir[DIR_NTres]) fno->altname[0] = 0;	/* Altname is not needed if neither LFN nor case info is exist. */
	}

#else	/* Non-LFN configuration */
	si = di = 0;
	while (si < 11) {		/* Copy name body and extension */
		c = (TCHAR)dp->dir[si++];
		if (c == ' ') continue;		/* Skip padding spaces */
		if (c == RDDEM) c = DDEM;	/* Restore replaced DDEM character */
		if (si == 9) fno->fname[di++] = '.';/* Insert a . if extension is exist */
		fno->fname[di++] = c;
	}
	fno->fname[di] = 0;
#endif

	fno->fattrib = dp->dir[DIR_Attr];					/* Attribute */
	fno->fsize = ld_dword(dp->dir + DIR_FileSize);		/* Size */
	fno->ftime = ld_word(dp->dir + DIR_ModTime + 0);	/* Time */
	fno->fdate = ld_word(dp->dir + DIR_ModTime + 2);	/* Date */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %r12
movb $0x0, 0x1a(%rsi)
cmpq $0x0, 0x38(%rdi)
je 0x7327
movq %rsi, %rbx
leaq 0x1a(%rsi), %r15
cmpb $0x4, (%r12)
jne 0x715a
movq 0x18(%r12), %r14
pushq $0x40
popq %r12
xorl %ebp, %ebp
xorl %r13d, %r13d
movzbl 0x23(%r14), %eax
xorl %ecx, %ecx
movl %ecx, %edi
cmpl %eax, %r13d
jae 0x72a2
cmpl $0x25f, %r12d           # imm = 0x25F
ja 0x72ab
incl %r13d
movl %r12d, %edx
orl $0x2, %edx
testb $0x1f, %r12b
cmovnel %r12d, %edx
movzwl (%r14,%rdx), %ecx
movl %edx, %r12d
addl $0x2, %r12d
testw %di, %di
jne 0x7133
movl %ecx, %edx
andl $0xf800, %edx           # imm = 0xF800
cmpw $0xd800, %dx            # imm = 0xD800
je 0x70ea
movzwl %cx, %eax
shll $0x10, %edi
orl %eax, %edi
movl %ebp, %esi
addq %r15, %rsi
movl $0xff, %edx
subl %ebp, %edx
callq 0x83d8
movzbl %al, %eax
addl %eax, %ebp
testb %al, %al
jne 0x70e3
jmp 0x72ab
movq %rdi, %r14
cmpl $-0x1, 0x54(%rdi)
movq %rbx, (%rsp)
je 0x71cc
xorl %ebp, %ebp
xorl %r13d, %r13d
movq 0x10(%r12), %rcx
xorl %eax, %eax
movl %eax, %ebx
movl %r13d, %eax
movzwl (%rcx,%rax,2), %eax
movl %ebp, %esi
testl %eax, %eax
je 0x71ba
incl %r13d
testw %bx, %bx
jne 0x7199
movl %eax, %edx
andl $0xf800, %edx           # imm = 0xF800
cmpw $0xd800, %dx            # imm = 0xD800
je 0x7173
movl %ebx, %edi
shll $0x10, %edi
orl %eax, %edi
addq %r15, %rsi
movl $0xff, %edx
subl %ebp, %edx
callq 0x83d8
movzbl %al, %eax
addl %eax, %ebp
testb %al, %al
jne 0x716c
xorl %esi, %esi
xorl %eax, %eax
testw %bx, %bx
cmoveq %rsi, %rax
movb $0x0, (%r15,%rax)
movq (%rsp), %rbx
leaq 0xd(%rbx), %r12
xorl %r13d, %r13d
movl $0xe5, %ecx
xorl %ebp, %ebp
xorl %ebx, %ebx
cmpq $0xa, %rbp
ja 0x7249
movq 0x40(%r14), %rax
movb (%rax,%rbp), %al
incq %rbp
cmpb $0x20, %al
je 0x71dc
cmpb $0x5, %al
movzbl %al, %eax
cmovel %ecx, %eax
cmpq $0x9, %rbp
jne 0x720f
cmpl $0xb, %r13d
ja 0x720f
movl %r13d, %ecx
incl %r13d
movb $0x2e, (%r12,%rcx)
movzbl %al, %eax
movzwl %ax, %edi
movl $0x1b5, %esi            # imm = 0x1B5
callq 0xad4d
testw %ax, %ax
je 0x724c
movzwl %ax, %edi
movl %r13d, %esi
addq %r12, %rsi
pushq $0xc
popq %rdx
subl %r13d, %edx
callq 0x83d8
movzbl %al, %eax
addl %eax, %r13d
testb %al, %al
movl $0xe5, %ecx
jne 0x71dc
jmp 0x724c
movl %r13d, %ebx
movl %ebx, %eax
movb $0x0, (%r12,%rax)
cmpb $0x0, (%r15)
movq (%rsp), %rbx
jne 0x7300
testq %rax, %rax
je 0x72e4
movb $0x8, %al
xorl %ecx, %ecx
movl %ecx, %ecx
movzbl (%r12,%rcx), %edx
cmpl $0x2e, %edx
je 0x7298
testl %edx, %edx
je 0x72ec
leal -0x41(%rdx), %esi
cmpb $0x19, %sil
ja 0x729a
movq 0x40(%r14), %rsi
movzbl %dl, %edi
orb $0x20, %dl
testb %al, 0xc(%rsi)
movzbl %dl, %edx
cmovel %edi, %edx
jmp 0x729a
movb $0x10, %al
movb %dl, (%r15,%rcx)
incl %ecx
jmp 0x726a
testw %di, %di
jne 0x72ab
testl %ebp, %ebp
jne 0x72b2
movb $0x3f, (%r15)
pushq $0x1
popq %rbp
movl %ebp, %ecx
xorl %eax, %eax
movb %al, 0x1a(%rbx,%rcx)
movb %al, 0xd(%rbx)
movb 0x4(%r14), %cl
movb %cl, 0xc(%rbx)
testb $0x10, %cl
jne 0x72d2
leaq 0x38(%r14), %rdi
callq 0x9f79
movq %rax, (%rbx)
movzwl 0xc(%r14), %eax
movw %ax, 0xa(%rbx)
addq $0xe, %r14
jmp 0x731f
movb $0x3f, (%r15,%rax)
pushq $0x1
popq %rcx
movb $0x0, (%r15,%rcx)
movq 0x40(%r14), %rax
cmpb $0x0, 0xc(%rax)
jne 0x7300
movb $0x0, (%r12)
movq 0x40(%r14), %r14
movb 0xb(%r14), %al
movb %al, 0xc(%rbx)
movl 0x1c(%r14), %eax
movq %rax, (%rbx)
movzwl 0x16(%r14), %eax
movw %ax, 0xa(%rbx)
addq $0x18, %r14
movzwl (%r14), %eax
movw %ax, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq