// File: /workspace/github_c_makefile_star2_O0/lb3361[P]dosfs/ff.c
// Function: f_getlabel
FRESULT f_getlabel (
	const TCHAR* path,	/* Logical drive number */
	TCHAR* label,		/* Buffer to store the volume label */
	DWORD* vsn			/* Variable to store the volume serial number */
)
{
	FRESULT res;
	DIR dj;
	FATFS *fs;
	UINT si, di;
	WCHAR wc;

	/* Get logical drive */
	res = mount_volume(&path, &fs, 0);

	/* Get volume label */
	if (res == FR_OK && label) {
		dj.obj.fs = fs; dj.obj.sclust = 0;	/* Open root directory */
		res = dir_sdi(&dj, 0);
		if (res == FR_OK) {
		 	res = DIR_READ_LABEL(&dj);		/* Find a volume label entry */
		 	if (res == FR_OK) {
#if FF_FS_EXFAT
				if (fs->fs_type == FS_EXFAT) {
					WCHAR hs;

					for (si = di = hs = 0; si < dj.dir[XDIR_NumLabel]; si++) {	/* Extract volume label from 83 entry */
						wc = ld_word(dj.dir + XDIR_Label + si * 2);
						if (hs == 0 && IsSurrogate(wc)) {	/* Is the code a surrogate? */
							hs = wc; continue;
						}
						wc = put_utf((DWORD)hs << 16 | wc, &label[di], 4);
						if (wc == 0) { di = 0; break; }
						di += wc;
						hs = 0;
					}
					if (hs != 0) di = 0;	/* Broken surrogate pair? */
					label[di] = 0;
				} else
#endif
				{
					si = di = 0;		/* Extract volume label from AM_VOL entry */
					while (si < 11) {
						wc = dj.dir[si++];
#if FF_USE_LFN && FF_LFN_UNICODE >= 1 	/* Unicode output */
						if (dbc_1st((BYTE)wc) && si < 11) wc = wc << 8 | dj.dir[si++];	/* Is it a DBC? */
						wc = ff_oem2uni(wc, CODEPAGE);					/* Convert it into Unicode */
						if (wc != 0) wc = put_utf(wc, &label[di], 4);	/* Put it in Unicode */
						if (wc == 0) { di = 0; break; }
						di += wc;
#else									/* ANSI/OEM output */
						label[di++] = (TCHAR)wc;
#endif
					}
					do {				/* Truncate trailing spaces */
						label[di] = 0;
						if (di == 0) break;
					} while (label[--di] == ' ');
				}
			}
		}
		if (res == FR_NO_FILE) {	/* No label entry and return nul string */
			label[0] = 0;
			res = FR_OK;
		}
	}

	/* Get volume serial number */
	if (res == FR_OK && vsn) {
		res = move_window(fs, fs->volbase);
		if (res == FR_OK) {
			switch (fs->fs_type) {
			case FS_EXFAT:
				di = BPB_VolIDEx;
				break;

			case FS_FAT32:
				di = BS_VolID32;
				break;

			default:
				di = BS_VolID;
			}
			*vsn = ld_dword(fs->win + di);
		}
	}

	LEAVE_FF(fs, res);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
xorl %edx, %edx
callq 0x4940
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0xa67b
cmpq $0x0, -0x10(%rbp)
je 0xa67b
movq -0x88(%rbp), %rax
movq %rax, -0x80(%rbp)
movl $0x0, -0x74(%rbp)
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
callq 0x82b0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0xa665
leaq -0x80(%rbp), %rdi
movl $0x1, %esi
callq 0x8550
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0xa663
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x4, %eax
jne 0xa51a
movw $0x0, -0x94(%rbp)
movl $0x0, -0x90(%rbp)
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movq -0x40(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jae 0xa4f1
movq -0x40(%rbp), %rdi
addq $0x2, %rdi
movl -0x8c(%rbp), %eax
shll %eax
movl %eax, %eax
addq %rax, %rdi
callq 0x9390
movw %ax, -0x92(%rbp)
movzwl -0x94(%rbp), %eax
cmpl $0x0, %eax
jne 0xa475
movzwl -0x92(%rbp), %eax
cmpl $0xd800, %eax           # imm = 0xD800
jl 0xa475
movzwl -0x92(%rbp), %eax
cmpl $0xdfff, %eax           # imm = 0xDFFF
jg 0xa475
movw -0x92(%rbp), %ax
movw %ax, -0x94(%rbp)
jmp 0xa4dd
movzwl -0x94(%rbp), %edi
shll $0x10, %edi
movzwl -0x92(%rbp), %eax
orl %eax, %edi
movq -0x10(%rbp), %rsi
movl -0x90(%rbp), %eax
addq %rax, %rsi
movl $0x4, %edx
callq 0xa730
movzbl %al, %eax
movw %ax, -0x92(%rbp)
movzwl -0x92(%rbp), %eax
cmpl $0x0, %eax
jne 0xa4c1
movl $0x0, -0x90(%rbp)
jmp 0xa4f1
movzwl -0x92(%rbp), %eax
addl -0x90(%rbp), %eax
movl %eax, -0x90(%rbp)
movw $0x0, -0x94(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0xa406
movzwl -0x94(%rbp), %eax
cmpl $0x0, %eax
je 0xa507
movl $0x0, -0x90(%rbp)
movq -0x10(%rbp), %rax
movl -0x90(%rbp), %ecx
movb $0x0, (%rax,%rcx)
jmp 0xa661
movl $0x0, -0x90(%rbp)
movl $0x0, -0x8c(%rbp)
cmpl $0xb, -0x8c(%rbp)
jae 0xa624
movq -0x40(%rbp), %rax
movl -0x8c(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x8c(%rbp)
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movw %ax, -0x92(%rbp)
movw -0x92(%rbp), %ax
movzbl %al, %edi
callq 0xa950
cmpl $0x0, %eax
je 0xa5a8
cmpl $0xb, -0x8c(%rbp)
jae 0xa5a8
movzwl -0x92(%rbp), %eax
shll $0x8, %eax
movq -0x40(%rbp), %rcx
movl -0x8c(%rbp), %edx
movl %edx, %esi
addl $0x1, %esi
movl %esi, -0x8c(%rbp)
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
orl %ecx, %eax
movw %ax, -0x92(%rbp)
movl $0x1b5, %esi            # imm = 0x1B5
movzwl -0x92(%rbp), %edi
callq 0xfee0
movw %ax, -0x92(%rbp)
movzwl -0x92(%rbp), %eax
cmpl $0x0, %eax
je 0xa5f4
movzwl -0x92(%rbp), %edi
movq -0x10(%rbp), %rsi
movl -0x90(%rbp), %eax
addq %rax, %rsi
movl $0x4, %edx
callq 0xa730
movzbl %al, %eax
movw %ax, -0x92(%rbp)
movzwl -0x92(%rbp), %eax
cmpl $0x0, %eax
jne 0xa60c
movl $0x0, -0x90(%rbp)
jmp 0xa624
movzwl -0x92(%rbp), %eax
addl -0x90(%rbp), %eax
movl %eax, -0x90(%rbp)
jmp 0xa52e
jmp 0xa626
movq -0x10(%rbp), %rax
movl -0x90(%rbp), %ecx
movb $0x0, (%rax,%rcx)
cmpl $0x0, -0x90(%rbp)
jne 0xa63f
jmp 0xa65f
jmp 0xa641
movq -0x10(%rbp), %rax
movl -0x90(%rbp), %ecx
addl $-0x1, %ecx
movl %ecx, -0x90(%rbp)
movl %ecx, %ecx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
je 0xa626
jmp 0xa661
jmp 0xa663
jmp 0xa665
cmpl $0x4, -0x1c(%rbp)
jne 0xa679
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movl $0x0, -0x1c(%rbp)
jmp 0xa67b
cmpl $0x0, -0x1c(%rbp)
jne 0xa719
cmpq $0x0, -0x18(%rbp)
je 0xa719
movq -0x88(%rbp), %rdi
movq -0x88(%rbp), %rax
movq 0x30(%rax), %rsi
callq 0x6480
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0xa717
movq -0x88(%rbp), %rax
movzbl (%rax), %eax
movl %eax, -0x98(%rbp)
subl $0x3, %eax
je 0xa6e0
jmp 0xa6c7
movl -0x98(%rbp), %eax
subl $0x4, %eax
jne 0xa6ec
jmp 0xa6d4
movl $0x64, -0x90(%rbp)
jmp 0xa6f6
movl $0x43, -0x90(%rbp)
jmp 0xa6f6
movl $0x27, -0x90(%rbp)
movq -0x88(%rbp), %rdi
addq $0x60, %rdi
movl -0x90(%rbp), %eax
addq %rax, %rdi
callq 0x6510
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xa719
movl -0x1c(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)