// File: /workspace/github_c_makefile_star2_O2/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 0xd514b
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 0xd5152
jmp 0xd51d0
movb $0x1, %dl
xorl %ebp, %ebp
movb $0x1, %r13b
cmpq $0x8, 0x10(%rbx)
jl 0xd5300
movl %r13d, %r12d
movl %edx, %r13d
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0xe418b
movq %rax, 0x8(%rsp)
addq $0x8, %r15
movq %r15, 0x10(%rsp)
leaq 0x61a0a(%rip), %rsi     # 0x136b8e
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x28(%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x18(%rax)
jne 0xd51ca
leaq 0x8(%rsp), %rdi
callq 0xe10b1
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 0xd51d9
jmp 0xd52ac
movl %r13d, %edx
movl %r12d, %r13d
testb %bpl, %bpl
jne 0xd52ac
leaq 0x8(%r15), %r12
movq 0x10(%rbx), %rax
addq 0x8(%rbx), %rax
cmpq %rax, %r12
jg 0xd5300
movl %edx, %ebp
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0xe418b
movq %rax, 0x8(%rsp)
movq %r12, 0x10(%rsp)
leaq 0x6199c(%rip), %rsi     # 0x136ba9
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x28(%rbx), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, 0x10(%rax)
jne 0xd52a7
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xe10b1
movq (%r15), %rax
movq 0x28(%rbx), %rcx
movq %rax, 0x10(%rcx)
testb %r13b, %r13b
movl %ebp, %edx
jne 0xd52b4
leaq 0x8(%r12), %r13
movq 0x10(%rbx), %rax
addq 0x8(%rbx), %rax
cmpq %rax, %r13
jg 0xd5300
movq 0x18(%r14), %rdi
movq %r12, %rsi
movl %edx, %ebp
callq 0xe418b
leaq 0x8(%rsp), %r15
movq %rax, (%r15)
movq %r13, 0x10(%rsp)
leaq 0x6193d(%rip), %rsi     # 0x136bbd
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
callq 0xe10b1
movq (%r15), %rax
movq 0x20(%rbx), %rcx
movq %rax, 0x18(%rcx)
testb %bpl, %bpl
je 0xd52bb
jmp 0xd5300
movq %r12, %r15
movl %ebp, %edx
movq %r15, %r12
testb %r13b, %r13b
je 0xd5248
movq %r12, %r13
testb %dl, %dl
jne 0xd5300
addq $0x4, %r13
movq 0x10(%rbx), %rax
addq 0x8(%rbx), %rax
cmpq %rax, %r13
jg 0xd5300
movq 0x18(%r14), %rdi
leaq 0x10(%rsp), %rsi
callq 0xe40bf
movq %rax, 0x8(%rsp)
leaq 0x618f3(%rip), %rsi     # 0x136bd9
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
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