// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/iso9660.c
// Function: do_primary_or_suppl_volume_descr
static void do_primary_or_suppl_volume_descr(deark *c, lctx *d, i64 secnum,
	i64 pos1, int is_primary, u8 is_cdi, u8 is_hsf)
{
	struct vol_record *newvol;

	newvol = de_malloc(c, sizeof(struct vol_record));
	newvol->secnum = secnum;
	newvol->is_cdi = is_cdi;
	newvol->is_hsf = is_hsf;

	do_primary_or_suppl_volume_descr_internal(c, d, newvol, secnum, pos1, is_primary);

	if(newvol->quality==0) goto done; // not usable
	if(d->vol_desc_sector_forced && (secnum!=d->vol_desc_sector_to_use)) {
		// User told us not to use this volume descriptor.
		goto done;
	}

	if(d->vol) {
		// We already have a volume descriptor. Is the new one preferable?
		if(newvol->quality > d->vol->quality) {
			de_free(c, d->vol);
			d->vol = newvol;
			newvol = NULL;
		}
	}
	else {
		d->vol = newvol;
		newvol = NULL;
	}

done:
	if(newvol) de_free(c, newvol);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %r9d, %ebp
movl %r8d, %ebx
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r14
pushq $0x38
popq %rsi
callq 0xdecaf
movq %r13, 0x20(%rsp)
movq %r13, (%rax)
movq %r12, %r13
movb %bpl, 0x27(%rax)
movq %rax, %rbp
movb 0x80(%rsp), %al
movb %al, 0x28(%rbp)
addq $0x7, %r12
movq %r12, 0x8(%rsp)
movq 0x50(%r15), %rdi
testq %rdi, %rdi
jne 0x87d6f
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0xe0ae9
movq %rax, %rdi
movq %rax, 0x50(%r15)
callq 0xe0e44
movq 0x18(%r15), %rcx
movq 0x50(%r15), %rdi
movq 0x18(%r14), %rsi
movq %r13, %rdx
callq 0xe0f33
movq 0x50(%r15), %rdi
callq 0xe0e95
movq 0x40(%r15), %rsi
movl %eax, %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0xe0a0b
testl %ebx, %ebx
movq %r13, 0x10(%rsp)
je 0x87db8
movq 0x20(%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%r15)
jmp 0x87dc4
movq 0x28(%r15), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x28(%r15)
testq %rcx, %rcx
je 0x87e00
testl %eax, %eax
jne 0x87e00
leaq 0x98d97(%rip), %rsi     # 0x120b6b
xorl %r13d, %r13d
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
cmpb $0x0, 0x9(%r15)
je 0x88477
movq 0x20(%rsp), %rax
cmpq %rax, 0x10(%r15)
movq 0x10(%rsp), %r13
jne 0x88474
movb 0x28(%rbp), %al
xorl %ecx, %ecx
cmpb $0x1, %al
adcl $0x10, %ecx
movl %ecx, 0x18(%rsp)
andl $0x0, 0x20(%rbp)
testl %ebx, %ebx
movl %ebx, 0x1c(%rsp)
je 0x87e28
leaq 0x8(%r13), %rcx
movq %rcx, 0x8(%rsp)
jmp 0x87f03
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xe3eb4
movzbl %al, %edx
leaq 0x98d65(%rip), %rsi     # 0x120ba3
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
leaq 0x8(%r13), %rax
movq %rax, 0x8(%rsp)
leaq 0x58(%r13), %r12
leaq 0x98ff3(%rip), %rsi     # 0x120e4f
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
movq 0x18(%r14), %rsi
andl $0x0, (%rsp)
pushq $0x20
popq %rcx
movq %r14, %rdi
movq %r12, %rdx
movq %rcx, %r8
xorl %r9d, %r9d
callq 0xded3a
movq 0x18(%r14), %rdi
leaq 0x30(%rsp), %r13
pushq $0x8
popq %rcx
movq %r13, %rsi
movq %r12, %rdx
callq 0xe3cb7
cmpb $0x25, (%r13)
jne 0x87edb
cmpb $0x2f, 0x31(%rsp)
jne 0x87edb
cmpb $0x4c, 0x33(%rsp)
je 0x87ed0
movzbl 0x32(%rsp), %eax
addl $-0x40, %eax
cmpl $0xb, %eax
ja 0x87edb
movl $0xc29, %ecx            # imm = 0xC29
btl %eax, %ecx
jae 0x87edb
movb $0x1, 0x25(%rbp)
movl $0x4, 0x20(%rbp)
movzbl 0x25(%rbp), %edx
leaq 0x98f7b(%rip), %rsi     # 0x120e61
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
movb 0x28(%rbp), %al
movq 0x10(%rsp), %r13
movq %r15, %rbx
testb %al, %al
je 0x87f13
leaq 0x10(%r13), %rax
movq %rax, 0x8(%rsp)
movq %r14, %rdi
callq 0xeac74
movq %rax, %r15
leaq 0x98c93(%rip), %rdx     # 0x120bb8
leaq 0x8(%rsp), %r12
pushq $0x20
popq %r13
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rcx
movq %r13, %r8
movq %rax, %r9
callq 0x884dd
leaq 0x98c79(%rip), %rdx     # 0x120bc2
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rcx
movq %r13, %r8
movq %r15, 0x28(%rsp)
movq %r15, %r9
callq 0x884dd
addq $0x8, (%r12)
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0x8857f
leaq 0x98c52(%rip), %rsi     # 0x120bcc
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x20, (%r12)
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0x88591
leaq 0x98c4b(%rip), %rsi     # 0x120bea
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0x88591
leaq 0x98c40(%rip), %rsi     # 0x120bfe
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0x88591
movq %rax, 0x18(%rbp)
leaq 0x98c38(%rip), %rsi     # 0x120c19
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
cmpq $0x0, 0x18(%rbp)
jne 0x88017
cmpb $0x0, 0xa(%rbx)
jne 0x8800f
leaq 0x98c2d(%rip), %rsi     # 0x120c2e
movq %r14, %rdi
xorl %eax, %eax
callq 0xdf05a
movb $0x1, 0xa(%rbx)
movq $0x800, 0x18(%rbp)      # imm = 0x800
movq 0x18(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0x8857f
leaq 0x98c25(%rip), %rsi     # 0x120c51
xorl %r12d, %r12d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
cmpb $0x0, 0x28(%rbp)
je 0x8804c
movq 0x10(%rsp), %rax
jmp 0x880dc
movq 0x18(%r14), %rdi
leaq 0x8(%rsp), %r13
movq %r13, %rsi
callq 0xe40bf
leaq 0x98c08(%rip), %rsi     # 0x120c6c
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xe40bf
leaq 0x98c0e(%rip), %rsi     # 0x120c91
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xe4071
movq %rax, %r12
leaq 0x98c1a(%rip), %rsi     # 0x120cbf
movq %r14, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xe4071
leaq 0x98c1f(%rip), %rsi     # 0x120ce4
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
cmpb $0x0, 0x28(%rbp)
movq 0x10(%rsp), %rax
je 0x880e7
addq $0xb4, %rax
movq %rax, 0x8(%rsp)
leaq 0x98c24(%rip), %rsi     # 0x120d12
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
movq 0x18(%r14), %rdi
movq 0x8(%rsp), %rsi
addq $0x2, %rsi
callq 0x884d4
movq %rax, 0x8(%rbp)
leaq 0x98c0a(%rip), %rsi     # 0x120d2a
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq 0x8(%rsp), %rsi
addq $0xa, %rsi
callq 0x884d4
movq %rax, 0x10(%rbp)
leaq 0x98bfb(%rip), %rsi     # 0x120d44
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
addq $0x22, 0x8(%rsp)
testq %r12, %r12
je 0x88203
cmpb $0x0, 0x27(%rbp)
je 0x88203
imulq 0x18(%rbx), %r12
leaq 0x98cea(%rip), %rsi     # 0x120e6f
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
movq 0x18(%r14), %rdi
addq $0x2, %r12
movq %r12, %rsi
callq 0xe404f
movq %rax, 0x8(%rbp)
leaq 0x98cc9(%rip), %rsi     # 0x120e81
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rsi
imulq 0x8(%rbp), %rsi
movq 0x18(%r14), %rdi
addq $0xe, %rsi
callq 0xe404f
movq $0xd88, 0x10(%rbp)      # imm = 0xD88
leaq 0x98cb0(%rip), %rsi     # 0x120e99
movq %r14, %rdi
movl $0xd88, %edx            # imm = 0xD88
xorl %eax, %eax
callq 0xde896
pushq $-0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
movq %rbx, 0x40(%rsp)
leaq 0x98b45(%rip), %rdx     # 0x120d54
leaq 0x8(%rsp), %r12
movl $0x80, %r8d
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rcx
movq 0x28(%rsp), %rbx
movq %rbx, %r9
callq 0x884dd
leaq 0x98b2b(%rip), %rdx     # 0x120d62
movl $0x80, %r8d
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rcx
movq %rbx, %r9
callq 0x884dd
leaq 0x98b1a(%rip), %rdx     # 0x120d6f
movl $0x80, %r8d
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rcx
movq %rbx, %r9
callq 0x884dd
leaq 0x98b0d(%rip), %rdx     # 0x120d80
movl $0x80, %r8d
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rcx
movq %rbx, %r9
callq 0x884dd
xorl %eax, %eax
cmpb $0x0, 0x28(%rbp)
sete %al
leaq 0x20(%rax,%rax,4), %r8
leaq 0x98af0(%rip), %rdx     # 0x120d8f
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rcx
movq %rbx, %r9
callq 0x884dd
xorl %eax, %eax
cmpb $0x0, 0x28(%rbp)
sete %al
leaq 0x20(%rax,%rax,4), %r8
leaq 0x98adc(%rip), %rdx     # 0x120da1
movq %r14, %rdi
movq %rbp, %rsi
movq %r12, %rcx
movq %rbx, %r9
callq 0x884dd
cmpb $0x0, 0x28(%rbp)
jne 0x882fa
leaq 0x98acf(%rip), %rdx     # 0x120db2
leaq 0x8(%rsp), %rcx
pushq $0x25
popq %r8
movq %r14, %rdi
movq %rbp, %rsi
movq %rbx, %r9
callq 0x884dd
leaq 0x8(%rsp), %r12
movq (%r12), %rsi
leaq 0x30(%rsp), %r13
movq %r14, %rdi
movl 0x18(%rsp), %r15d
movl %r15d, %edx
movq %r13, %rcx
callq 0x885a7
leaq 0x98aa6(%rip), %rdx     # 0x120dc8
movq %r14, %rdi
movq %r13, %rsi
callq 0x886eb
movq %rbp, %rbx
movl %r15d, %ebp
movq (%r12), %rsi
addq %rbp, %rsi
movq %rsi, (%r12)
movq %r14, %rdi
movl %r15d, %edx
movq %r13, %rcx
callq 0x885a7
leaq 0x98a8a(%rip), %rdx     # 0x120ddd
movq %r14, %rdi
movq %r13, %rsi
callq 0x886eb
movq (%r12), %rsi
addq %rbp, %rsi
movq %rsi, (%r12)
movq %r14, %rdi
movl %r15d, %edx
movq %r13, %rcx
callq 0x885a7
leaq 0x98a6f(%rip), %rdx     # 0x120ded
movq %r14, %rdi
movq %r13, %rsi
callq 0x886eb
movq (%r12), %rsi
addq %rbp, %rsi
movq %rsi, (%r12)
movq %r14, %rdi
movl %r15d, %edx
movq %r13, %rcx
callq 0x885a7
leaq 0x98a5b(%rip), %rdx     # 0x120e04
movq %r14, %rdi
movq %r13, %rsi
callq 0x886eb
addq %rbp, (%r12)
movq %rbx, %rbp
movq 0x28(%rsp), %rbx
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xe3f2a
movb %al, 0x24(%rbp)
movzbl %al, %edx
leaq 0x98a41(%rip), %rsi     # 0x120e1a
xorl %r13d, %r13d
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq 0x10(%rsp), %rsi
addq $0x400, %rsi            # imm = 0x400
leaq 0x98a38(%rip), %rdx     # 0x120e35
pushq $0x8
popq %rcx
callq 0xe4d48
xorl %edx, %edx
testl %eax, %eax
sete %dl
sete 0x26(%rbp)
leaq 0x98a27(%rip), %rsi     # 0x120e3e
movq %r14, %rdi
xorl %eax, %eax
callq 0xde896
cmpq $0x800, 0x18(%rbp)      # imm = 0x800
pushq $0x51
popq %rax
pushq $0x1
popq %rdi
cmovel %eax, %edi
cmpb $0x0, 0x25(%rbp)
pushq $0x28
popq %rax
cmovel %r13d, %eax
movb 0x24(%rbp), %cl
cmpb $0x2, %cl
pushq $0xa
popq %rdx
movl $0x0, %esi
cmovbl %edx, %esi
cmpb $0x1, %cl
cmovel %edx, %r13d
xorl %ecx, %ecx
cmpl $0x0, 0x1c(%rsp)
setne %cl
leal (%rcx,%rcx,4), %ecx
addb %dil, %cl
orb %al, %cl
addb %sil, %r13b
addb %cl, %r13b
movq 0x40(%rsp), %r15
jmp 0x88479
xorl %r13d, %r13d
xorl %ebx, %ebx
movb %r13b, 0x29(%rbp)
movq %rbx, %rdi
callq 0xeaf3c
movb 0x29(%rbp), %al
testb %al, %al
je 0x884ba
cmpb $0x0, 0x9(%r15)
je 0x8849e
movq 0x20(%rsp), %rcx
cmpq %rcx, 0x10(%r15)
jne 0x884ba
movq 0x48(%r15), %rsi
testq %rsi, %rsi
je 0x884b4
cmpb 0x29(%rsi), %al
jbe 0x884ba
movq %r14, %rdi
callq 0xded32
movq %rbp, 0x48(%r15)
jmp 0x884c5
movq %r14, %rdi
movq %rbp, %rsi
callq 0xded32
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq