// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movl %r9d, %ebp
movl %r8d, %ebx
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %r14
movl $0x38, %esi
callq 0xe8b2b
movq %r13, 0x38(%rsp)
movq %r13, (%rax)
movb %bpl, 0x27(%rax)
movq %rax, 0x18(%rsp)
movb 0x90(%rsp), %cl
movb %cl, 0x28(%rax)
movq %r12, %rbp
leaq 0x7(%r15), %r13
movq %r13, 0x10(%rsp)
movq 0x50(%r12), %rdi
testq %rdi, %rdi
jne 0x8cf28
movq %r14, %rdi
movl $0x10, %esi
callq 0xeb499
movq %rax, %rdi
movq %rax, 0x50(%rbp)
callq 0xeb7fe
movq 0x18(%rbp), %rcx
movq 0x50(%rbp), %rdi
movq 0x18(%r14), %rsi
movq %r15, %rdx
callq 0xeb944
movq 0x50(%rbp), %rdi
callq 0xeb865
movq 0x40(%rbp), %rsi
movl %eax, %edx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0xeb3ad
testl %ebx, %ebx
movq %r15, 0x28(%rsp)
je 0x8cf8c
movq 0x20(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x20(%rbp)
testq %rcx, %rcx
jne 0x8cf9d
movq 0x18(%rsp), %rcx
movb 0x28(%rcx), %al
xorl %edx, %edx
cmpb $0x1, %al
movl %edx, 0x20(%rcx)
adcl $0x10, %edx
movl %edx, 0x24(%rsp)
jmp 0x8cfc0
movq 0x28(%rbp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x28(%rbp)
testq %rcx, %rcx
je 0x8d008
testl %eax, %eax
je 0x8cfce
movq 0x18(%rsp), %rdx
movb 0x28(%rdx), %al
xorl %ecx, %ecx
cmpb $0x1, %al
movl $0x0, %esi
adcl $0x10, %esi
movl %esi, 0x24(%rsp)
movl %ecx, 0x20(%rdx)
testl %ebx, %ebx
je 0x8d01d
leaq 0x8(%r15), %rcx
movq %rcx, 0x10(%rsp)
jmp 0x8d114
leaq 0xa0e06(%rip), %rsi     # 0x12dddb
xorl %r12d, %r12d
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0x9(%rbp)
je 0x8cffb
movq 0x38(%rsp), %rax
cmpq %rax, 0x10(%rbp)
movq 0x28(%rsp), %r15
je 0x8cfa1
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x18(%rsp), %rbx
jmp 0x8d696
xorl %ecx, %ecx
movq 0x18(%rsp), %rax
cmpb $0x1, 0x28(%rax)
movl %ecx, 0x20(%rax)
adcl $0x10, %ecx
movl %ecx, 0x24(%rsp)
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xeead3
movzbl %al, %edx
leaq 0xa0de0(%rip), %rsi     # 0x12de13
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
leaq 0x8(%r15), %rax
movq %rax, 0x10(%rsp)
leaq 0x58(%r15), %r12
leaq 0xa106e(%rip), %rsi     # 0x12e0bf
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r14), %rsi
movl $0x0, (%rsp)
movl $0x20, %ecx
movl $0x20, %r8d
movq %r14, %rdi
movq %r12, %rdx
xorl %r9d, %r9d
callq 0xe8bea
movq 0x18(%r14), %rdi
leaq 0x40(%rsp), %r13
movl $0x8, %ecx
movq %r13, %rsi
movq %r12, %rdx
callq 0xee8d4
cmpb $0x25, (%r13)
jne 0x8d0e1
cmpb $0x2f, 0x41(%rsp)
jne 0x8d0e1
cmpb $0x4c, 0x43(%rsp)
je 0x8d0d1
movzbl 0x42(%rsp), %eax
addl $-0x40, %eax
cmpl $0xb, %eax
ja 0x8d0e1
movl $0xc29, %ecx            # imm = 0xC29
btl %eax, %ecx
jae 0x8d0e1
movq 0x18(%rsp), %rax
movb $0x1, 0x25(%rax)
movl $0x4, 0x20(%rax)
movq 0x18(%rsp), %r12
movzbl 0x25(%r12), %edx
leaq 0xa0fde(%rip), %rsi     # 0x12e0d1
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movb 0x28(%r12), %al
movq 0x28(%rsp), %r15
movl %ebx, 0x34(%rsp)
testb %al, %al
je 0x8d125
leaq 0x10(%r15), %rax
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0xf6410
movq %rax, %r13
leaq 0xa0cf1(%rip), %rdx     # 0x12de28
leaq 0x10(%rsp), %r12
movl $0x20, %r8d
movq %r14, %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
movq %r12, %rcx
movq %rax, %r9
callq 0x8d6f0
leaq 0xa0cd3(%rip), %rdx     # 0x12de32
movl $0x20, %r8d
movq %r14, %rdi
movq %rbx, %rsi
movq %r12, %rcx
movq %r13, %r15
movq %r13, %r9
callq 0x8d6f0
movq (%r12), %r12
movq 0x18(%r14), %rdi
leaq 0xc(%r12), %rsi
callq 0xeed0d
leaq 0xa0caa(%rip), %rsi     # 0x12de3c
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
leaq 0x32(%r12), %rsi
callq 0xeeb67
leaq 0xa0ca6(%rip), %rsi     # 0x12de5a
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
leaq 0x36(%r12), %rsi
callq 0xeeb67
leaq 0xa0c99(%rip), %rsi     # 0x12de6e
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
leaq 0x3a(%r12), %rsi
callq 0xeeb67
movq %rax, 0x18(%rbx)
leaq 0xa0c8f(%rip), %rsi     # 0x12de89
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
cmpq $0x0, 0x18(%rbx)
jne 0x8d230
cmpb $0x0, 0xa(%rbp)
jne 0x8d228
leaq 0xa0c84(%rip), %rsi     # 0x12de9e
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8faa
movb $0x1, 0xa(%rbp)
movq $0x800, 0x18(%rbx)      # imm = 0x800
movq 0x18(%r14), %rdi
leaq 0x40(%r12), %rsi
callq 0xeed0d
addq $0x44, %r12
movq %r12, 0x10(%rsp)
leaq 0xa0c73(%rip), %rsi     # 0x12dec1
xorl %r13d, %r13d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0x28(%rbx)
je 0x8d26e
movq 0x28(%rsp), %rax
jmp 0x8d2fe
movq 0x18(%r14), %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0xeed83
leaq 0xa0c56(%rip), %rsi     # 0x12dedc
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xeed83
leaq 0xa0c5c(%rip), %rsi     # 0x12df01
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xeed31
movq %rax, %r13
leaq 0xa0c68(%rip), %rsi     # 0x12df2f
movq %r14, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movq %r12, %rsi
callq 0xeed31
leaq 0xa0c6d(%rip), %rsi     # 0x12df54
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
cmpb $0x0, 0x28(%rbx)
movq 0x28(%rsp), %rax
je 0x8d309
addq $0xb4, %rax
movq %rax, 0x10(%rsp)
leaq 0xa0c72(%rip), %rsi     # 0x12df82
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r14), %rdi
movq 0x10(%rsp), %rsi
addq $0x6, %rsi
callq 0xeed0d
movq %rax, 0x8(%rbx)
leaq 0xa0c56(%rip), %rsi     # 0x12df9a
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movq 0x10(%rsp), %rsi
addq $0xe, %rsi
callq 0xeed0d
movq %rax, 0x10(%rbx)
leaq 0xa0c47(%rip), %rsi     # 0x12dfb4
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
addq $0x22, 0x10(%rsp)
testq %r13, %r13
je 0x8d42d
cmpb $0x0, 0x27(%rbx)
je 0x8d42d
imulq 0x18(%rbp), %r13
leaq 0xa0d34(%rip), %rsi     # 0x12e0df
movq %r14, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%r14), %rdi
addq $0x2, %r13
movq %r13, %rsi
callq 0xeed0d
movq %rax, 0x8(%rbx)
leaq 0xa0d11(%rip), %rsi     # 0x12e0f1
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbp), %rsi
imulq 0x8(%rbx), %rsi
movq 0x18(%r14), %rdi
addq $0xe, %rsi
callq 0xeed0d
movq $0xd88, 0x10(%rbx)      # imm = 0xD88
leaq 0xa0cf8(%rip), %rsi     # 0x12e109
movq %r14, %rdi
movl $0xd88, %edx            # imm = 0xD88
xorl %eax, %eax
callq 0xe8617
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq %rbp, 0x50(%rsp)
leaq 0xa0b8b(%rip), %rdx     # 0x12dfc4
leaq 0x10(%rsp), %r13
movl $0x80, %r8d
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rcx
movq %r15, %r9
callq 0x8d6f0
leaq 0xa0b76(%rip), %rdx     # 0x12dfd2
movl $0x80, %r8d
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rcx
movq %r15, %r9
callq 0x8d6f0
leaq 0xa0b65(%rip), %rdx     # 0x12dfdf
movl $0x80, %r8d
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rcx
movq %r15, %r9
callq 0x8d6f0
leaq 0xa0b58(%rip), %rdx     # 0x12dff0
movl $0x80, %r8d
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rcx
movq %r15, %r9
callq 0x8d6f0
xorl %eax, %eax
cmpb $0x0, 0x28(%rbx)
sete %al
leaq 0x20(%rax,%rax,4), %r8
leaq 0xa0b3b(%rip), %rdx     # 0x12dfff
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rcx
movq %r15, %r9
callq 0x8d6f0
xorl %eax, %eax
cmpb $0x0, 0x28(%rbx)
sete %al
leaq 0x20(%rax,%rax,4), %r8
leaq 0xa0b27(%rip), %rdx     # 0x12e011
movq %r14, %rdi
movq %rbx, %rsi
movq %r13, %rcx
movq %r15, %r9
callq 0x8d6f0
cmpb $0x0, 0x28(%rbx)
jne 0x8d521
leaq 0xa0b1a(%rip), %rdx     # 0x12e022
leaq 0x10(%rsp), %rcx
movl $0x25, %r8d
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %r9
callq 0x8d6f0
leaq 0x10(%rsp), %r13
movq (%r13), %rsi
leaq 0x40(%rsp), %r12
movq %r14, %rdi
movl 0x24(%rsp), %ebp
movl %ebp, %edx
movq %r12, %rcx
callq 0x8d794
leaq 0xa0af1(%rip), %rdx     # 0x12e038
movq %r14, %rdi
movq %r12, %rsi
callq 0x8d96b
movl %ebp, %ebx
movq (%r13), %rsi
addq %rbx, %rsi
movq %rsi, (%r13)
movq %r14, %rdi
movl %ebp, %edx
movq %r12, %rcx
callq 0x8d794
leaq 0xa0ada(%rip), %rdx     # 0x12e04d
movq %r14, %rdi
movq %r12, %rsi
callq 0x8d96b
movq (%r13), %rsi
addq %rbx, %rsi
movq %rsi, (%r13)
movq %r14, %rdi
movl %ebp, %edx
movq %r12, %rcx
callq 0x8d794
leaq 0xa0ac0(%rip), %rdx     # 0x12e05d
movq %r14, %rdi
movq %r12, %rsi
callq 0x8d96b
movq (%r13), %rsi
addq %rbx, %rsi
movq %rsi, (%r13)
movq %r14, %rdi
movl %ebp, %edx
movq %r12, %rcx
callq 0x8d794
leaq 0xa0aad(%rip), %rdx     # 0x12e074
movq %r14, %rdi
movq %r12, %rsi
callq 0x8d96b
addq %rbx, (%r13)
movq 0x18(%rsp), %rbx
movq 0x18(%r14), %rdi
movq %r13, %rsi
callq 0xeeb4b
movb %al, 0x24(%rbx)
movzbl %al, %edx
leaq 0xa0a96(%rip), %rsi     # 0x12e08a
xorl %r12d, %r12d
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r14), %rdi
movq 0x28(%rsp), %rsi
addq $0x400, %rsi            # imm = 0x400
leaq 0xa0a8d(%rip), %rdx     # 0x12e0a5
movl $0x8, %ecx
callq 0xefc85
xorl %edx, %edx
testl %eax, %eax
sete %dl
sete 0x26(%rbx)
leaq 0xa0a7a(%rip), %rsi     # 0x12e0ae
movq %r14, %rdi
xorl %eax, %eax
callq 0xe8617
cmpq $0x800, 0x18(%rbx)      # imm = 0x800
movl $0x51, %eax
movl $0x1, %ecx
cmovel %eax, %ecx
cmpb $0x0, 0x25(%rbx)
movl $0x28, %eax
cmovel %r12d, %eax
movb 0x24(%rbx), %dl
cmpb $0x2, %dl
movl $0xa, %esi
movl $0x0, %edi
cmovbl %esi, %edi
cmpb $0x1, %dl
cmovel %esi, %r12d
xorl %edx, %edx
cmpl $0x0, 0x34(%rsp)
setne %dl
leal (%rdx,%rdx,4), %edx
addb %cl, %dl
orb %al, %dl
addb %dil, %r12b
addb %dl, %r12b
movq 0x50(%rsp), %rbp
movb %r12b, 0x29(%rbx)
movq %r15, %rdi
callq 0xf6753
movb 0x29(%rbx), %al
testb %al, %al
je 0x8d6d6
cmpb $0x0, 0x9(%rbp)
je 0x8d6ba
movq 0x38(%rsp), %rcx
cmpq %rcx, 0x10(%rbp)
jne 0x8d6d6
movq 0x48(%rbp), %rsi
testq %rsi, %rsi
je 0x8d6d0
cmpb 0x29(%rsi), %al
jbe 0x8d6d6
movq %r14, %rdi
callq 0xe8be2
movq %rbx, 0x48(%rbp)
jmp 0x8d6e1
movq %r14, %rdi
movq %rbx, %rsi
callq 0xe8be2
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq