// File: /workspace/github_c_makefile_star2_O1/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
subq $0x18, %rsp
movq (%rdi), %r12
movb $0x0, 0x1a(%rsi)
cmpq $0x0, 0x38(%rdi)
je 0x7c30
movq %rsi, %rbx
leaq 0x1a(%rsi), %r9
cmpb $0x4, (%r12)
jne 0x7a01
movq 0x18(%r12), %r14
movl $0x40, %r13d
xorl %r8d, %r8d
xorl %r12d, %r12d
xorl %r15d, %r15d
movzbl 0x23(%r14), %eax
cmpl %eax, %r12d
cmoval %r12d, %eax
incl %eax
xorl %ecx, %ecx
movl %ecx, %ebp
incl %r12d
cmpl %r12d, %eax
je 0x7b91
cmpl $0x25f, %r13d           # imm = 0x25F
ja 0x7b94
movl %r13d, %esi
orl $0x2, %esi
testb $0x1f, %r13b
cmovnel %r13d, %esi
movzbl 0x1(%r14,%rsi), %edx
movl %edx, %edi
shll $0x8, %edi
movzbl (%r14,%rsi), %ecx
orl %edi, %ecx
movl %esi, %r13d
addl $0x2, %r13d
testw %bp, %bp
jne 0x79c0
andl $-0x8, %edx
movzwl %dx, %edx
cmpl $0xd8, %edx
je 0x796b
movl %ebp, %edi
shll $0x10, %edi
orl %ecx, %edi
movl %r8d, %esi
addq %r9, %rsi
movl $0xff, %edx
subl %r8d, %edx
movq %r9, 0x8(%rsp)
movl %r8d, 0x14(%rsp)
callq 0x8f47
movl 0x14(%rsp), %r8d
movq 0x8(%rsp), %r9
movzbl %al, %eax
addl %eax, %r8d
testb %al, %al
jne 0x795b
jmp 0x7b94
movq %rdi, %r14
cmpl $-0x1, 0x54(%rdi)
je 0x7a81
xorl %ebp, %ebp
xorl %r13d, %r13d
movq 0x10(%r12), %rcx
xorl %eax, %eax
movl %eax, %r15d
movl %r13d, %eax
movzwl (%rcx,%rax,2), %eax
testl %eax, %eax
je 0x7a70
incl %r13d
testw %r15w, %r15w
jne 0x7a40
movl %eax, %edx
andl $0xf800, %edx           # imm = 0xF800
movzwl %dx, %edx
cmpl $0xd800, %edx           # imm = 0xD800
je 0x7a16
movl %r15d, %edi
shll $0x10, %edi
orl %eax, %edi
movl %ebp, %esi
addq %r9, %rsi
movl $0xff, %edx
subl %ebp, %edx
movq %r9, 0x8(%rsp)
callq 0x8f47
movq 0x8(%rsp), %r9
movzbl %al, %eax
addl %eax, %ebp
testb %al, %al
jne 0x7a0f
xorl %ecx, %ecx
jmp 0x7a72
movl %ebp, %ecx
xorl %eax, %eax
testw %r15w, %r15w
cmoveq %rcx, %rax
movb $0x0, (%r9,%rax)
leaq 0xd(%rbx), %rax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
movl $0xb, %ecx
movl $0xe5, %edx
xorl %eax, %eax
xorl %r15d, %r15d
movl %eax, %r13d
cmpl $0xc, %eax
cmovbl %ecx, %eax
cmpq %r13, %rax
je 0x7b30
movq 0x40(%r14), %rcx
movb (%rcx,%r13), %cl
incq %r13
cmpb $0x20, %cl
je 0x7aa4
cmpb $0x5, %cl
movzbl %cl, %eax
cmovel %edx, %eax
cmpq $0x9, %r13
jne 0x7adf
cmpl $0xb, %ebp
ja 0x7adf
movq %r9, %r12
movl %ebp, %ecx
incl %ebp
movb $0x2e, 0xd(%rbx,%rcx)
jmp 0x7ae2
movq %r9, %r12
movzbl %al, %eax
movzwl %ax, %edi
movl $0x1b5, %esi            # imm = 0x1B5
callq 0xbe1b
testw %ax, %ax
je 0x7c3f
movzwl %ax, %edi
movl %ebp, %esi
addq 0x8(%rsp), %rsi
movl $0xc, %edx
subl %ebp, %edx
callq 0x8f47
movzbl %al, %ecx
addl %ecx, %ebp
movl %r13d, %eax
testb %cl, %cl
movq %r12, %r9
movl $0xb, %ecx
movl $0xe5, %edx
jne 0x7a9b
jmp 0x7b33
movl %ebp, %r15d
movl %r15d, %eax
movb $0x0, 0xd(%rbx,%rax)
cmpb $0x0, 0x1a(%rbx)
jne 0x7bfd
testq %rax, %rax
je 0x7be0
movb $0x8, %cl
xorl %eax, %eax
movl %eax, %edx
movzbl 0xd(%rbx,%rdx), %esi
cmpl $0x2e, %esi
je 0x7b67
testl %esi, %esi
jne 0x7b69
jmp 0x7bea
movb $0x10, %cl
leal -0x41(%rsi), %edi
cmpb $0x19, %dil
ja 0x7b89
movq 0x40(%r14), %rdi
movzbl %sil, %r8d
orb $0x20, %sil
testb %cl, 0xc(%rdi)
movzbl %sil, %esi
cmovel %r8d, %esi
movb %sil, (%r9,%rdx)
incl %eax
jmp 0x7b52
movl %r8d, %r15d
xorl %eax, %eax
testw %bp, %bp
cmovel %r15d, %eax
testl %eax, %eax
jne 0x7baa
movb $0x3f, (%r9)
movl $0x1, %eax
movl %eax, %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 0x7bca
leaq 0x38(%r14), %rdi
callq 0xaded
movq %rax, (%rbx)
movzwl 0xc(%r14), %eax
movw %ax, 0xa(%rbx)
leaq 0xe(%r14), %rax
addq $0xf, %r14
jmp 0x7c20
movb $0x3f, (%r9,%rax)
movl $0x1, %edx
movb $0x0, (%r9,%rdx)
movq 0x40(%r14), %rax
cmpb $0x0, 0xc(%rax)
jne 0x7bfd
movb $0x0, 0xd(%rbx)
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)
leaq 0x18(%r14), %rax
addq $0x19, %r14
movzbl (%r14), %ecx
shll $0x8, %ecx
movzbl (%rax), %eax
orl %ecx, %eax
movw %ax, 0x8(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %r9
jmp 0x7b33