// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/fat.c
// Function: handle_vfat_lfn
static void handle_vfat_lfn(deark *c, lctx *d, struct dirctx *dctx,
	struct member_data *md)
{
	u8 cksum_calc = 0;
	i64 max_len_in_ucs2_chars;
	i64 len_in_ucs2_chars = 0;
	i64 i;

	if(!dctx->lfn_valid) goto done;
	if(dctx->prev_seq_num != 1) goto done;
	if(md->long_fn) goto done;

	vfat_cksum_update(md->fn_base, 8, &cksum_calc);
	vfat_cksum_update(md->fn_ext, 3, &cksum_calc);
	de_dbg(c, "filename checksum (calculated): 0x%02x", (UI)cksum_calc);
	if(cksum_calc != dctx->name_cksum) goto done;

	max_len_in_ucs2_chars = LFN_CHARS_PER_FRAGMENT * (i64)dctx->first_seq_num;
	if(max_len_in_ucs2_chars > (i64)(sizeof(dctx->pending_lfn)/2)) goto done;
	for(i=0; i<max_len_in_ucs2_chars; i++) {
		if(dctx->pending_lfn[i*2]==0x00 && dctx->pending_lfn[i*2+1]==0x00) break;
		if(dctx->pending_lfn[i*2]==0xff && dctx->pending_lfn[i*2+1]==0xff) break;
		len_in_ucs2_chars++;
	}

	md->long_fn = ucstring_create(c);
	ucstring_append_bytes(md->long_fn, dctx->pending_lfn, len_in_ucs2_chars*2,
		0, DE_ENCODING_UTF16LE);
	de_dbg(c, "long filename: \"%s\"", ucstring_getpsz_d(md->long_fn));

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movb $0x0, -0x21(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x84942
jmp 0x84ac0
movq -0x18(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x1, %eax
je 0x84954
jmp 0x84ac0
movq -0x20(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x84964
jmp 0x84ac0
movq -0x20(%rbp), %rdi
movl $0x8, %esi
leaq -0x21(%rbp), %rdx
callq 0x85210
movq -0x20(%rbp), %rdi
addq $0x8, %rdi
movl $0x3, %esi
leaq -0x21(%rbp), %rdx
callq 0x85210
movq -0x8(%rbp), %rdi
movzbl -0x21(%rbp), %edx
leaq 0x1299eb(%rip), %rsi    # 0x1ae386
movb $0x0, %al
callq 0x15b0d0
movzbl -0x21(%rbp), %eax
movq -0x18(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
cmpl %ecx, %eax
je 0x849b7
jmp 0x84ac0
movq -0x18(%rbp), %rax
movzbl 0x1(%rax), %eax
imulq $0xd, %rax, %rax
movq %rax, -0x30(%rbp)
cmpq $0x104, -0x30(%rbp)     # imm = 0x104
jle 0x849d6
jmp 0x84ac0
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x84a5e
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq %rcx
movzbl 0x18(%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x84a14
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq %rcx
movzbl 0x19(%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x84a14
jmp 0x84a5e
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq %rcx
movzbl 0x18(%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x84a44
movq -0x18(%rbp), %rax
movq -0x40(%rbp), %rcx
shlq %rcx
movzbl 0x19(%rax,%rcx), %eax
cmpl $0xff, %eax
jne 0x84a44
jmp 0x84a5e
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x849de
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x18(%rbp), %rsi
addq $0x18, %rsi
movq -0x38(%rbp), %rdx
shlq %rdx
xorl %ecx, %ecx
movl $0x3, %r8d
callq 0x171fa0
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x172650
movq -0x48(%rbp), %rdi
movq %rax, %rdx
leaq 0x1298f4(%rip), %rsi    # 0x1ae3ad
movb $0x0, %al
callq 0x15b0d0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)