// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/tar.c
// Function: read_gnu_longpath
static void read_gnu_longpath(deark *c, lctx *d, struct phys_member_data *pmd,
	struct extattr_data *ea)
{
	i64 pos = pmd->file_data_pos;
	i64 ext_name_len = pmd->filesize;

	de_dbg(c, "LongPath data at %"I64_FMT, pos);
	de_dbg_indent(c, 1);
	if(ext_name_len<1) goto done;

	if(pmd->linkflag=='K') {
		if(!ea->linkname) {
			ea->linkname = ucstring_create(c);
		}
		ucstring_empty(ea->linkname);
		// TODO: It's a little inconsistent that we convert a GNU extended linkname
		// to a ucstring, while we keep the original bytes of old-style linknames.
		dbuf_read_to_ucstring_n(c->infile, pos, ext_name_len-1, 32767, ea->linkname, 0,
			d->input_encoding);
		de_dbg(c, "ext. linkname: \"%s\"", ucstring_getpsz_d(ea->linkname));
	}
	else { // 'L', presumably
		if(!ea->alt_name) {
			ea->alt_name = ucstring_create(c);
		}
		ucstring_empty(ea->alt_name);
		dbuf_read_to_ucstring_n(c->infile, pos, ext_name_len-1, 32767, ea->alt_name, 0,
			d->input_encoding);
		de_dbg(c, "ext. filename: \"%s\"", ucstring_getpsz_d(ea->alt_name));
	}

done:
	de_dbg_indent(c, -1);
}

// 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)
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rdx
leaq 0x9d776(%rip), %rsi     # 0x1c7555
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
cmpq $0x1, -0x30(%rbp)
jge 0x129e00
jmp 0x129f23
movq -0x18(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x4b, %eax
jne 0x129e9e
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x129e30
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x171210
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
subq $0x1, %rdx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %r8
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl $0x7fff, %ecx           # imm = 0x7FFF
xorl %r9d, %r9d
movl %eax, (%rsp)
callq 0x166a40
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x172650
movq -0x38(%rbp), %rdi
movq %rax, %rdx
leaq 0x9d6d8(%rip), %rsi     # 0x1c756a
movb $0x0, %al
callq 0x15b0d0
jmp 0x129f21
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x129ebb
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x171210
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
subq $0x1, %rdx
movq -0x20(%rbp), %rax
movq (%rax), %r8
movq -0x10(%rbp), %rax
movl (%rax), %eax
movl $0x7fff, %ecx           # imm = 0x7FFF
xorl %r9d, %r9d
movl %eax, (%rsp)
callq 0x166a40
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x172650
movq -0x40(%rbp), %rdi
movq %rax, %rdx
leaq 0x9d664(%rip), %rsi     # 0x1c757e
movb $0x0, %al
callq 0x15b0d0
jmp 0x129f23
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)