// File: /workspace/github_c_makefile_star2_O1/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, %r15d
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %rbx
movl $0x38, %esi
callq 0xe969b
movq %r13, 0x30(%rsp)
movq %r13, (%rax)
movb %bpl, 0x27(%rax)
movq %r12, %rbp
movq %r14, %r12
movq %rax, 0x18(%rsp)
movb 0x90(%rsp), %cl
movb %cl, 0x28(%rax)
leaq 0x7(%r14), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x50(%rbp)
jne 0x8d7f6
movq %rbx, %rdi
movl $0x10, %esi
callq 0xeba56
movq %rax, 0x50(%rbp)
movq 0x50(%rbp), %rdi
callq 0xebdc3
movq 0x18(%rbp), %rcx
movq 0x50(%rbp), %rdi
movq 0x18(%rbx), %rsi
movq %r12, %rdx
callq 0xebf09
movq 0x50(%rbp), %rdi
callq 0xebe2a
movq 0x40(%rbp), %rsi
movl %eax, %edx
xorl %r13d, %r13d
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0xeb96a
xorl %ecx, %ecx
testl %r15d, %r15d
sete %cl
movq 0x20(%rbp,%rcx,8), %rdx
leaq 0x1(%rdx), %rsi
movq %rsi, 0x20(%rbp,%rcx,8)
testq %rdx, %rdx
movq %r12, 0x20(%rsp)
je 0x8d885
testl %eax, %eax
jne 0x8d885
leaq 0xa0289(%rip), %rsi     # 0x12dae3
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0x9(%rbp)
je 0x8df7e
movq 0x30(%rsp), %rax
cmpq %rax, 0x10(%rbp)
movq 0x20(%rsp), %r12
jne 0x8df7b
movq 0x18(%rsp), %rax
cmpb $0x1, 0x28(%rax)
movl $0x0, %ecx
adcl $0x10, %ecx
movl %ecx, 0x28(%rsp)
movl %r13d, 0x20(%rax)
testl %r15d, %r15d
je 0x8d8b2
incq 0x10(%rsp)
movq 0x18(%rsp), %r14
jmp 0x8d99e
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
callq 0xef0d5
movzbl %al, %edx
leaq 0xa0251(%rip), %rsi     # 0x12db1b
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
incq 0x10(%rsp)
addq $0x58, %r12
leaq 0xa04e3(%rip), %rsi     # 0x12ddc7
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rsi
movl $0x0, (%rsp)
movl $0x20, %ecx
movl $0x20, %r8d
movq %rbx, %rdi
movq %r12, %rdx
xorl %r9d, %r9d
callq 0xe975a
movq 0x18(%rbx), %rdi
leaq 0x40(%rsp), %r13
movl $0x8, %ecx
movq %r13, %rsi
movq %r12, %rdx
callq 0xeeee8
cmpb $0x25, (%r13)
movq 0x18(%rsp), %r14
jne 0x8d976
cmpb $0x2f, 0x41(%rsp)
jne 0x8d976
cmpb $0x4c, 0x43(%rsp)
je 0x8d969
movzbl 0x42(%rsp), %eax
addl $-0x40, %eax
cmpl $0xb, %eax
ja 0x8d976
movl $0xc29, %ecx            # imm = 0xC29
btl %eax, %ecx
jae 0x8d976
movb $0x1, 0x25(%r14)
movl $0x4, 0x20(%r14)
movzbl 0x25(%r14), %edx
leaq 0xa0457(%rip), %rsi     # 0x12ddd9
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq 0x20(%rsp), %r12
movl %r15d, 0x2c(%rsp)
cmpb $0x0, 0x28(%r14)
je 0x8d9b4
leaq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movq %r12, %r15
movq %rbx, %rdi
callq 0xf6870
movq %rax, %r12
leaq 0xa0167(%rip), %rdx     # 0x12db30
leaq 0x10(%rsp), %r13
movl $0x20, %r8d
movq %rbx, %rdi
movq 0x18(%rsp), %r14
movq %r14, %rsi
movq %r13, %rcx
movq %rax, %r9
callq 0x8dfe7
leaq 0xa0149(%rip), %rdx     # 0x12db3a
movl $0x20, %r8d
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rcx
movq %r12, 0x38(%rsp)
movq %r12, %r9
callq 0x8dfe7
movq (%r13), %rsi
leaq 0x8(%rsi), %rax
movq %rax, (%r13)
movq 0x18(%rbx), %rdi
addq $0xc, %rsi
callq 0xef32a
addq $0x8, (%r13)
leaq 0xa0112(%rip), %rsi     # 0x12db44
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq (%r13), %rsi
leaq 0x20(%rsi), %rax
movq %rax, (%r13)
movq 0x18(%rbx), %rdi
addq $0x22, %rsi
callq 0xef169
addq $0x4, (%r13)
leaq 0xa00fe(%rip), %rsi     # 0x12db62
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq (%r13), %rsi
addq $0x2, %rsi
callq 0xef169
addq $0x4, (%r13)
leaq 0xa00e9(%rip), %rsi     # 0x12db76
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq (%r13), %rsi
addq $0x2, %rsi
callq 0xef169
addq $0x4, (%r13)
movq %rax, 0x18(%r14)
leaq 0xa00d7(%rip), %rsi     # 0x12db91
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
cmpq $0x0, 0x18(%r14)
jne 0x8daf5
cmpb $0x0, 0xa(%rbp)
jne 0x8dae8
leaq 0xa00cc(%rip), %rsi     # 0x12dba6
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9b27
movb $0x1, 0xa(%rbp)
movq 0x18(%rsp), %r14
movq $0x800, 0x18(%r14)      # imm = 0x800
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
addq $0x4, %rsi
callq 0xef32a
addq $0x8, 0x10(%rsp)
leaq 0xa00b5(%rip), %rsi     # 0x12dbc9
xorl %r13d, %r13d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
cmpb $0x0, 0x28(%r14)
jne 0x8dbb9
movq 0x18(%rbx), %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0xef3a0
leaq 0xa009d(%rip), %rsi     # 0x12dbe4
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef3a0
leaq 0xa00a3(%rip), %rsi     # 0x12dc09
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef34e
movq %rax, %r13
leaq 0xa00af(%rip), %rsi     # 0x12dc37
movq %rbx, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r12, %rsi
movq 0x20(%rsp), %r15
callq 0xef34e
leaq 0xa00af(%rip), %rsi     # 0x12dc5c
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rsp), %rax
cmpb $0x0, 0x28(%rax)
je 0x8dbd0
leaq 0xb4(%r15), %rax
movq %rax, 0x10(%rsp)
leaq 0xa00b3(%rip), %rsi     # 0x12dc8a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
addq $0x6, %rsi
callq 0xef32a
movq 0x18(%rsp), %r12
movq %rax, 0x8(%r12)
leaq 0xa0091(%rip), %rsi     # 0x12dca2
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq 0x10(%rsp), %rsi
addq $0xe, %rsi
callq 0xef32a
movq %rax, 0x10(%r12)
leaq 0xa0081(%rip), %rsi     # 0x12dcbc
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
addq $0x22, 0x10(%rsp)
testq %r13, %r13
je 0x8dd00
cmpb $0x0, 0x27(%r12)
je 0x8dd00
imulq 0x18(%rbp), %r13
leaq 0xa016c(%rip), %rsi     # 0x12dde7
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
addq $0x2, %r13
movq %r13, %rsi
callq 0xef32a
movq %rax, 0x8(%r12)
leaq 0xa0148(%rip), %rsi     # 0x12ddf9
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbp), %rsi
imulq 0x8(%r12), %rsi
movq 0x18(%rbx), %rdi
addq $0xe, %rsi
callq 0xef32a
movq $0xd88, 0x10(%r12)      # imm = 0xD88
leaq 0xa012d(%rip), %rsi     # 0x12de11
movq %rbx, %rdi
movl $0xd88, %edx            # imm = 0xD88
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %rbp, 0x50(%rsp)
leaq 0x9ffc0(%rip), %rdx     # 0x12dccc
leaq 0x10(%rsp), %r13
movl $0x80, %r8d
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
movq 0x38(%rsp), %r14
movq %r14, %r9
callq 0x8dfe7
leaq 0x9ffa6(%rip), %rdx     # 0x12dcda
movl $0x80, %r8d
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
movq %r14, %r9
callq 0x8dfe7
leaq 0x9ff95(%rip), %rdx     # 0x12dce7
movl $0x80, %r8d
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
movq %r14, %r9
callq 0x8dfe7
leaq 0x9ff88(%rip), %rdx     # 0x12dcf8
movl $0x80, %r8d
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
movq %r14, %r9
callq 0x8dfe7
xorl %eax, %eax
cmpb $0x0, 0x28(%r12)
sete %al
leaq 0x20(%rax,%rax,4), %r8
leaq 0x9ff69(%rip), %rdx     # 0x12dd07
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
movq %r14, %r9
callq 0x8dfe7
xorl %eax, %eax
cmpb $0x0, 0x28(%r12)
sete %al
leaq 0x20(%rax,%rax,4), %r8
leaq 0x9ff53(%rip), %rdx     # 0x12dd19
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rcx
movq %r14, %r9
callq 0x8dfe7
cmpb $0x0, 0x28(%r12)
jne 0x8ddff
leaq 0x9ff44(%rip), %rdx     # 0x12dd2a
leaq 0x10(%rsp), %rcx
movl $0x25, %r8d
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %r9
callq 0x8dfe7
leaq 0x10(%rsp), %r15
movq (%r15), %rsi
movq %r12, %r14
leaq 0x40(%rsp), %r12
movq %rbx, %rdi
movl 0x28(%rsp), %r13d
movl %r13d, %edx
movq %r12, %rcx
callq 0x8e08b
leaq 0x9ff17(%rip), %rdx     # 0x12dd40
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8e262
movl %r13d, %ebp
movq (%r15), %rsi
addq %rbp, %rsi
movq %rsi, (%r15)
movq %rbx, %rdi
movl %r13d, %edx
movq %r12, %rcx
callq 0x8e08b
leaq 0x9ff00(%rip), %rdx     # 0x12dd55
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8e262
movq (%r15), %rsi
addq %rbp, %rsi
movq %rsi, (%r15)
movq %rbx, %rdi
movl %r13d, %edx
movq %r12, %rcx
callq 0x8e08b
leaq 0x9fee7(%rip), %rdx     # 0x12dd65
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8e262
movq (%r15), %rsi
addq %rbp, %rsi
movq %rsi, (%r15)
movq %rbx, %rdi
movl %r13d, %edx
movq %r12, %rcx
callq 0x8e08b
leaq 0x9fed5(%rip), %rdx     # 0x12dd7c
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8e262
addq %rbp, (%r15)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
movq 0x38(%rsp), %r15
callq 0xef14d
movb %al, 0x24(%r14)
movzbl %al, %edx
leaq 0x9febe(%rip), %rsi     # 0x12dd92
xorl %r12d, %r12d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq 0x20(%rsp), %rsi
addq $0x400, %rsi            # imm = 0x400
leaq 0x9feb5(%rip), %rdx     # 0x12ddad
movl $0x8, %ecx
callq 0xf025e
xorl %edx, %edx
testl %eax, %eax
sete %dl
sete 0x26(%r14)
leaq 0x9fea1(%rip), %rsi     # 0x12ddb6
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
cmpq $0x800, 0x18(%r14)      # imm = 0x800
movl $0x51, %eax
movl $0x1, %ecx
cmovel %eax, %ecx
cmpb $0x0, 0x25(%r14)
movl $0x28, %eax
cmovel %r12d, %eax
movb 0x24(%r14), %dl
cmpb $0x2, %dl
movl $0xa, %esi
movl $0x0, %edi
cmovbl %esi, %edi
cmpb $0x1, %dl
cmovel %esi, %r12d
xorl %edx, %edx
cmpl $0x0, 0x2c(%rsp)
setne %dl
leal (%rdx,%rdx,4), %edx
addb %cl, %dl
orb %al, %dl
addb %dil, %r12b
addb %dl, %r12b
movq 0x50(%rsp), %rbp
jmp 0x8df86
xorl %r12d, %r12d
xorl %r15d, %r15d
movq 0x18(%rsp), %r14
movb %r12b, 0x29(%r14)
movq %r15, %rdi
callq 0xf6bb0
movb 0x29(%r14), %al
testb %al, %al
je 0x8dfc8
cmpb $0x0, 0x9(%rbp)
je 0x8dfab
movq 0x30(%rsp), %rcx
cmpq %rcx, 0x10(%rbp)
jne 0x8dfc8
movq 0x48(%rbp), %rsi
testq %rsi, %rsi
je 0x8dfc1
cmpb 0x29(%rsi), %al
jbe 0x8dfc8
movq %rbx, %rdi
callq 0xe9752
movq %r14, 0x48(%rbp)
xorl %r14d, %r14d
testq %r14, %r14
je 0x8dfd8
movq %rbx, %rdi
movq %r14, %rsi
callq 0xe9752
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq