// File: /workspace/github_c_makefile_star2_O0/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: updateBam
static void updateBam(CbmdosFs *self)
{
    uint8_t *bam = Sector_content(D64_sector(self->d64, 18, 0));
    memset(bam, 0, 256);
    bam[0] = 18;
    bam[1] = 1;
    bam[2] = CbmdosVfs_dosver(self->vfs);
    for (uint8_t trackno = 1; trackno <= D64_tracks(self->d64); ++trackno)
    {
        if (trackno < 36)
        {
            createTrackBam(self, bam + 4*trackno, trackno);
        }
        else if (trackno < 41)
        {
            if (self->options.flags & CFF_DOLPHINDOSBAM)
            {
                createTrackBam(self, bam + 0x1c + 4*trackno, trackno);
            }
            if (self->options.flags & CFF_SPEEDDOSBAM)
            {
                createTrackBam(self, bam + 0x30 + 4*trackno, trackno);
            }
            if (self->options.flags & CFF_PROLOGICDOSBAM)
            {
                createTrackBam(self, bam + 4*trackno, trackno);
            }
        }
    }
    uint8_t nameoffset = 0;
    if (self->options.flags & CFF_PROLOGICDOSBAM) nameoffset = 0x14;
    memset(bam+0x90+nameoffset, 0xa0, 0x1b);
    bam[0xa5+nameoffset] = 0x32;
    bam[0xa6+nameoffset] = CbmdosVfs_dosver(self->vfs);
    uint8_t length;
    const char *name = CbmdosVfs_name(self->vfs, &length);
    memcpy(bam+0x90+nameoffset, name, length);
    const char *id = CbmdosVfs_id(self->vfs, &length);
    memcpy(bam+0xa2+nameoffset, id, length);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl $0x12, %esi
xorl %edx, %edx
callq 0x5030
movq %rax, %rdi
callq 0x56f0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x5340
movq -0x10(%rbp), %rax
movb $0x12, (%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x1(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x55a0
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x2(%rax)
movb $0x1, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x5630
movb %al, %cl
movl -0x2c(%rbp), %eax
movzbl %cl, %ecx
cmpl %ecx, %eax
jg 0xd33e
movzbl -0x11(%rbp), %eax
cmpl $0x24, %eax
jge 0xd292
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movzbl -0x11(%rbp), %eax
shll $0x2, %eax
cltq
addq %rax, %rsi
movzbl -0x11(%rbp), %edx
callq 0xef90
jmp 0xd32f
movzbl -0x11(%rbp), %eax
cmpl $0x29, %eax
jge 0xd32d
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0xd2cf
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x1c, %rsi
movzbl -0x11(%rbp), %eax
shll $0x2, %eax
cltq
addq %rax, %rsi
movzbl -0x11(%rbp), %edx
callq 0xef90
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0xd2ff
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x30, %rsi
movzbl -0x11(%rbp), %eax
shll $0x2, %eax
cltq
addq %rax, %rsi
movzbl -0x11(%rbp), %edx
callq 0xef90
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xd32b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movzbl -0x11(%rbp), %eax
shll $0x2, %eax
cltq
addq %rax, %rsi
movzbl -0x11(%rbp), %edx
callq 0xef90
jmp 0xd32d
jmp 0xd32f
jmp 0xd331
movb -0x11(%rbp), %al
addb $0x1, %al
movb %al, -0x11(%rbp)
jmp 0xd244
movb $0x0, -0x12(%rbp)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0xd355
movb $0x14, -0x12(%rbp)
movq -0x10(%rbp), %rdi
addq $0x90, %rdi
movzbl -0x12(%rbp), %eax
cltq
addq %rax, %rdi
movl $0xa0, %esi
movl $0x1b, %edx
callq 0x5340
movq -0x10(%rbp), %rax
movzbl -0x12(%rbp), %ecx
addl $0xa5, %ecx
movslq %ecx, %rcx
movb $0x32, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x55a0
movb %al, %dl
movq -0x10(%rbp), %rax
movzbl -0x12(%rbp), %ecx
addl $0xa6, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x13(%rbp), %rsi
callq 0x51a0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
addq $0x90, %rdi
movzbl -0x12(%rbp), %eax
cltq
addq %rax, %rdi
movq -0x20(%rbp), %rsi
movzbl -0x13(%rbp), %eax
movl %eax, %edx
callq 0x54c0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x13(%rbp), %rsi
callq 0x5420
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
addq $0xa2, %rdi
movzbl -0x12(%rbp), %eax
cltq
addq %rax, %rdi
movq -0x28(%rbp), %rsi
movzbl -0x13(%rbp), %eax
movl %eax, %edx
callq 0x54c0
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)