// File: /workspace/github_c_makefile_star2_O1/jsummers[P]deark/modules/zip.c
// Function: ef_zip64extinfo
static void ef_zip64extinfo(deark *c, lctx *d, struct extra_item_info_struct *eii)
{
	i64 n;
	i64 pos = eii->dpos;
	u8 has_uncmpr_size = 0;
	u8 has_cmpr_size = 0;
	u8 has_ldir_offset = 0;
	u8 has_segment_num = 0;

	// IMO, the documentation isn't very clear about when a field is present,
	// and when it isn't. This is my best guess. It shouldn't really matter,
	// provided the encoder was sane.
	if(!eii->is_central || eii->dd->uncmpr_size==0xffffffffLL) {
		has_uncmpr_size = 1;
	}
	if(!eii->is_central || eii->dd->cmpr_size==0xffffffffLL) {
		has_cmpr_size = 1;
	}
	if(eii->is_central && eii->md->offset_of_local_header==0xffffffffLL) {
		has_ldir_offset = 1;
	}
	if(eii->is_central && eii->md->seg_number_start==0xffff) {
		has_segment_num = 1;
	}

	if(has_uncmpr_size) {
		if(pos+8 > eii->dpos+eii->dlen) goto done;
		n = de_geti64le(pos); pos += 8;
		de_dbg(c, "orig uncmpr file size: %"I64_FMT, n);
		if(eii->dd->uncmpr_size==0xffffffffLL) {
			de_sanitize_length(&n);
			eii->dd->uncmpr_size = n;
		}
	}

	if(has_cmpr_size) {
		if(pos+8 > eii->dpos+eii->dlen) goto done;
		n = de_geti64le(pos); pos += 8;
		de_dbg(c, "cmpr data size: %"I64_FMT, n);
		if(eii->dd->cmpr_size==0xffffffffLL) {
			de_sanitize_length(&n);
			eii->dd->cmpr_size = n;
		}
	}

	if(has_ldir_offset) {
		if(pos+8 > eii->dpos+eii->dlen) goto done;
		n = de_geti64le(pos); pos += 8;
		de_dbg(c, "offset of local header: %"I64_FMT, n);
		de_sanitize_offset(&n);
		eii->md->offset_of_local_header = n;
	}

	if(has_segment_num) {
		if(pos+4 > eii->dpos+eii->dlen) goto done;
		n = de_getu32le_p(&pos);
		de_dbg(c, "segment start number: %"I64_FMT, n);
		eii->md->seg_number_start = n;
	}

done:
	;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rdi, %r14
movq 0x8(%rdx), %rsi
movq %rsi, 0x8(%rsp)
movl 0x30(%rdx), %ecx
testl %ecx, %ecx
je 0xdf21c
movq 0x28(%rbx), %rdx
movb $0x1, %al
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
cmpq %rdi, 0x18(%rdx)
jne 0xdf21e
xorl %eax, %eax
testl %ecx, %ecx
je 0xdf234
movq 0x28(%rbx), %rdx
movb $0x1, %r13b
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
cmpq %rdi, 0x10(%rdx)
jne 0xdf237
xorl %r13d, %r13d
movb $0x1, %bpl
movb $0x1, %r12b
testl %ecx, %ecx
je 0xdf252
movq 0x20(%rbx), %rdx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
cmpq %rdi, 0x18(%rdx)
setne %r12b
testl %ecx, %ecx
je 0xdf266
movq 0x20(%rbx), %rcx
cmpq $0xffff, 0x20(%rcx)     # imm = 0xFFFF
setne %bpl
testb %al, %al
je 0xdf32d
testb %r13b, %r13b
je 0xdf38c
testb %r12b, %r12b
jne 0xdf2d4
movq 0x8(%rsp), %rsi
leaq 0x8(%rsi), %rax
movq 0x10(%rbx), %rcx
addq 0x8(%rbx), %rcx
cmpq %rcx, %rax
jg 0xdf3a2
movq 0x18(%r14), %rdi
callq 0xef536
leaq 0x10(%rsp), %r15
movq %rax, (%r15)
addq $0x8, 0x8(%rsp)
leaq 0x64879(%rip), %rsi     # 0x143b2d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r15, %rdi
callq 0xec0d1
movq (%r15), %rax
movq 0x20(%rbx), %rcx
movq %rax, 0x18(%rcx)
testb %bpl, %bpl
jne 0xdf3a2
movq 0x8(%rsp), %rax
addq $0x4, %rax
movq 0x10(%rbx), %rcx
addq 0x8(%rbx), %rcx
cmpq %rcx, %rax
jg 0xdf3a2
movq 0x18(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0xef3a0
movq %rax, 0x10(%rsp)
leaq 0x64838(%rip), %rsi     # 0x143b49
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x10(%rsp), %rax
movq 0x20(%rbx), %rcx
movq %rax, 0x20(%rcx)
jmp 0xdf3a2
cmpq $0x8, 0x10(%rbx)
jl 0xdf3a2
movq 0x18(%r14), %rdi
callq 0xef536
movq %rax, 0x10(%rsp)
addq $0x8, 0x8(%rsp)
leaq 0x647af(%rip), %rsi     # 0x143afe
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x28(%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x18(%rax)
jne 0xdf26e
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xec0d1
movq (%r15), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x18(%rcx)
jmp 0xdf26e
movq 0x8(%rsp), %rsi
leaq 0x8(%rsi), %rax
movq 0x10(%rbx), %rcx
addq 0x8(%rbx), %rcx
cmpq %rcx, %rax
jle 0xdf3b1
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%r14), %rdi
callq 0xef536
movq %rax, 0x10(%rsp)
addq $0x8, 0x8(%rsp)
leaq 0x6474d(%rip), %rsi     # 0x143b19
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x28(%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x10(%rax)
jne 0xdf277
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xec0d1
movq (%r15), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x10(%rcx)
jmp 0xdf277