// File: /workspace/github_c_makefile_star2_O3/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), %r15
movq %r15, 0x10(%rsp)
cmpl $0x0, 0x30(%rdx)
je 0xde853
movq 0x28(%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x10(%rax)
movq 0x20(%rbx), %rdx
setne %bpl
cmpq %rcx, 0x18(%rdx)
setne %r13b
cmpq $0xffff, 0x20(%rdx)     # imm = 0xFFFF
setne %dl
cmpq %rcx, 0x18(%rax)
je 0xde85a
jmp 0xde8d8
movb $0x1, %dl
xorl %ebp, %ebp
movb $0x1, %r13b
cmpq $0x8, 0x10(%rbx)
jl 0xdea08
movl %r13d, %r12d
movl %edx, %r13d
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0xeef09
movq %rax, 0x8(%rsp)
addq $0x8, %r15
movq %r15, 0x10(%rsp)
leaq 0x65752(%rip), %rsi     # 0x143fde
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x28(%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x18(%rax)
jne 0xde8d2
leaq 0x8(%rsp), %rdi
callq 0xebad2
leaq 0x8(%rsp), %rax
movq (%rax), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x18(%rcx)
testb %bpl, %bpl
movl %r13d, %edx
movl %r12d, %r13d
je 0xde8e1
jmp 0xde9b4
movl %r13d, %edx
movl %r12d, %r13d
testb %bpl, %bpl
jne 0xde9b4
leaq 0x8(%r15), %r12
movq 0x10(%rbx), %rax
addq 0x8(%rbx), %rax
cmpq %rax, %r12
jg 0xdea08
movl %edx, %ebp
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0xeef09
movq %rax, 0x8(%rsp)
movq %r12, 0x10(%rsp)
leaq 0x656e4(%rip), %rsi     # 0x143ff9
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x28(%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x10(%rax)
jne 0xde9af
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xebad2
movq (%r15), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x10(%rcx)
testb %r13b, %r13b
movl %ebp, %edx
jne 0xde9bc
leaq 0x8(%r12), %r13
movq 0x10(%rbx), %rax
addq 0x8(%rbx), %rax
cmpq %rax, %r13
jg 0xdea08
movq 0x18(%r14), %rdi
movq %r12, %rsi
movl %edx, %ebp
callq 0xeef09
leaq 0x8(%rsp), %r15
movq %rax, (%r15)
movq %r13, 0x10(%rsp)
leaq 0x65685(%rip), %rsi     # 0x14400d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r15, %rdi
callq 0xebad2
movq (%r15), %rax
movq 0x20(%rbx), %rcx
movq %rax, 0x18(%rcx)
testb %bpl, %bpl
je 0xde9c3
jmp 0xdea08
movq %r12, %r15
movl %ebp, %edx
movq %r15, %r12
testb %r13b, %r13b
je 0xde950
movq %r12, %r13
testb %dl, %dl
jne 0xdea08
addq $0x4, %r13
movq 0x10(%rbx), %rax
addq 0x8(%rbx), %rax
cmpq %rax, %r13
jg 0xdea08
movq 0x18(%r14), %rdi
leaq 0x10(%rsp), %rsi
callq 0xeed83
movq %rax, 0x8(%rsp)
leaq 0x6563b(%rip), %rsi     # 0x144029
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x8(%rsp), %rax
movq 0x20(%rbx), %rcx
movq %rax, 0x20(%rcx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq