// File: /workspace/github_c_makefile_star2_O0/lb3361[P]dosfs/ff.c
// Function: tchar2uni
static DWORD tchar2uni (	/* Returns a character in UTF-16 encoding (>=0x10000 on surrogate pair, 0xFFFFFFFF on decode error) */
	const TCHAR** str		/* Pointer to pointer to TCHAR string in configured encoding */
)
{
	DWORD uc;
	const TCHAR *p = *str;

#if FF_LFN_UNICODE == 1		/* UTF-16 input */
	WCHAR wc;

	uc = *p++;	/* Get a unit */
	if (IsSurrogate(uc)) {	/* Surrogate? */
		wc = *p++;		/* Get low surrogate */
		if (!IsSurrogateH(uc) || !IsSurrogateL(wc)) return 0xFFFFFFFF;	/* Wrong surrogate? */
		uc = uc << 16 | wc;
	}

#elif FF_LFN_UNICODE == 2	/* UTF-8 input */
	BYTE b;
	int nf;

	uc = (BYTE)*p++;	/* Get an encoding unit */
	if (uc & 0x80) {	/* Multiple byte code? */
		if ((uc & 0xE0) == 0xC0) {	/* 2-byte sequence? */
			uc &= 0x1F; nf = 1;
		} else {
			if ((uc & 0xF0) == 0xE0) {	/* 3-byte sequence? */
				uc &= 0x0F; nf = 2;
			} else {
				if ((uc & 0xF8) == 0xF0) {	/* 4-byte sequence? */
					uc &= 0x07; nf = 3;
				} else {					/* Wrong sequence */
					return 0xFFFFFFFF;
				}
			}
		}
		do {	/* Get trailing bytes */
			b = (BYTE)*p++;
			if ((b & 0xC0) != 0x80) return 0xFFFFFFFF;	/* Wrong sequence? */
			uc = uc << 6 | (b & 0x3F);
		} while (--nf != 0);
		if (uc < 0x80 || IsSurrogate(uc) || uc >= 0x110000) return 0xFFFFFFFF;	/* Wrong code? */
		if (uc >= 0x010000) uc = 0xD800DC00 | ((uc - 0x10000) << 6 & 0x3FF0000) | (uc & 0x3FF);	/* Make a surrogate pair if needed */
	}

#elif FF_LFN_UNICODE == 3	/* UTF-32 input */
	uc = (TCHAR)*p++;	/* Get a unit */
	if (uc >= 0x110000 || IsSurrogate(uc)) return 0xFFFFFFFF;	/* Wrong code? */
	if (uc >= 0x010000) uc = 0xD800DC00 | ((uc - 0x10000) << 6 & 0x3FF0000) | (uc & 0x3FF);	/* Make a surrogate pair if needed */

#else		/* ANSI/OEM input */
	BYTE b;
	WCHAR wc;

	wc = (BYTE)*p++;			/* Get a byte */
	if (dbc_1st((BYTE)wc)) {	/* Is it a DBC 1st byte? */
		b = (BYTE)*p++;			/* Get 2nd byte */
		if (!dbc_2nd(b)) return 0xFFFFFFFF;	/* Invalid code? */
		wc = (wc << 8) + b;		/* Make a DBC */
	}
	if (wc != 0) {
		wc = ff_oem2uni(wc, CODEPAGE);	/* ANSI/OEM ==> Unicode */
		if (wc == 0) return 0xFFFFFFFF;	/* Invalid code? */
	}
	uc = wc;

#endif
	*str = p;	/* Next read pointer */
	return uc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movzbl (%rax), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xaf59
movl -0x14(%rbp), %eax
andl $0xe0, %eax
cmpl $0xc0, %eax
jne 0xae5a
movl -0x14(%rbp), %eax
andl $0x1f, %eax
movl %eax, -0x14(%rbp)
movl $0x1, -0x28(%rbp)
jmp 0xaeac
movl -0x14(%rbp), %eax
andl $0xf0, %eax
cmpl $0xe0, %eax
jne 0xae7b
movl -0x14(%rbp), %eax
andl $0xf, %eax
movl %eax, -0x14(%rbp)
movl $0x2, -0x28(%rbp)
jmp 0xaeaa
movl -0x14(%rbp), %eax
andl $0xf8, %eax
cmpl $0xf0, %eax
jne 0xae9c
movl -0x14(%rbp), %eax
andl $0x7, %eax
movl %eax, -0x14(%rbp)
movl $0x3, -0x28(%rbp)
jmp 0xaea8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaf6a
jmp 0xaeaa
jmp 0xaeac
jmp 0xaeae
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb (%rax), %al
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
andl $0xc0, %eax
cmpl $0x80, %eax
je 0xaede
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaf6a
movl -0x14(%rbp), %eax
shll $0x6, %eax
movzbl -0x21(%rbp), %ecx
andl $0x3f, %ecx
orl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, %eax
jne 0xaeae
cmpl $0x80, -0x14(%rbp)
jb 0xaf22
cmpl $0xd800, -0x14(%rbp)    # imm = 0xD800
jb 0xaf19
cmpl $0xdfff, -0x14(%rbp)    # imm = 0xDFFF
jbe 0xaf22
cmpl $0x110000, -0x14(%rbp)  # imm = 0x110000
jb 0xaf2b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaf6a
cmpl $0x10000, -0x14(%rbp)   # imm = 0x10000
jb 0xaf57
movl -0x14(%rbp), %eax
subl $0x10000, %eax          # imm = 0x10000
shll $0x6, %eax
andl $0x3ff0000, %eax        # imm = 0x3FF0000
orl $0xd800dc00, %eax       # imm = 0xD800DC00
movl -0x14(%rbp), %ecx
andl $0x3ff, %ecx            # imm = 0x3FF
orl %ecx, %eax
movl %eax, -0x14(%rbp)
jmp 0xaf59
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nop