// File: /workspace/github_c_makefile_star2_O0/excess-c64[P]lib1541img/src/lib/1541img/cbmdosfs.c
// Function: nextTrack
static uint8_t nextTrack(const CbmdosFsOptions *opts, uint8_t trackno)
{
    if (opts->flags & CFF_TALLOC_TRACKLOAD)
    {
	if (trackno >= 40 && !(opts->flags & CFF_42TRACK))
	{
	    return 0;
	}
	if (trackno >= 35 &&
		!(opts->flags & (CFF_40TRACK | CFF_42TRACK)))
	{
	    return 0;
	}
	if (trackno == 42) return 0;
	if (trackno == 17)
	{
	    if ((opts->flags & CFF_FILESONDIRTRACK) &&
		    !(opts->flags & CFF_TALLOC_PREFDIRTRACK))
	    {
		return 18;
	    }
	    return 19;
	}
	if (trackno == 18
		&& (opts->flags & CFF_FILESONDIRTRACK)
		&& (opts->flags & CFF_TALLOC_PREFDIRTRACK))
	{
	    return 1;
	}
	return trackno + 1;
    }
    else if (opts->flags & CFF_TALLOC_SIMPLE)
    {
	if (trackno == 42)
	{
	    if ((opts->flags & CFF_FILESONDIRTRACK) &&
		    !(opts->flags & CFF_TALLOC_PREFDIRTRACK))
	    {
		return 18;
	    }
	    return 0;
	}
	if (trackno == 40 || (trackno == 35 && !(opts->flags &
			(CFF_40TRACK | CFF_42TRACK))))
	{
	    return 1;
	}
	if (trackno == 17)
	{
	    if (opts->flags & CFF_42TRACK)
	    {
		return 41;
	    }
	    if ((opts->flags & CFF_FILESONDIRTRACK) &&
		    !(opts->flags & CFF_TALLOC_PREFDIRTRACK))
	    {
		return 18;
	    }
	    return 0;
	}
	if (trackno == 18)
	{
	    if ((opts->flags & CFF_FILESONDIRTRACK)
		    && (opts->flags & CFF_TALLOC_PREFDIRTRACK))
	    {
		return 19;
	    }
	    return 0;
	}
	return trackno + 1;
    }
    else
    {
	if (trackno >= 40 && !(opts->flags & CFF_42TRACK))
	{
	    return 0;
	}
	if (trackno >= 35 &&
		!(opts->flags & (CFF_40TRACK | CFF_42TRACK)))
	{
	    return 0;
	}
	if (trackno == 42) return 0;
	if (trackno == 1) return 0;
	if (trackno == 18)
	{
	    if ((opts->flags & CFF_FILESONDIRTRACK)
		    && (opts->flags & CFF_TALLOC_PREFDIRTRACK))
	    {
		return 17;
	    }
	    return 0;
	}
	if (trackno < 18) return trackno - 1;
	return trackno + 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0xedcc
movzbl -0x11(%rbp), %eax
cmpl $0x28, %eax
jl 0xed22
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0xed22
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x23, %eax
jl 0xed42
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0xc, %eax
cmpl $0x0, %eax
jne 0xed42
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x2a, %eax
jne 0xed54
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x11, %eax
jne 0xed8d
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xed84
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
jne 0xed84
movb $0x12, -0x1(%rbp)
jmp 0xef87
movb $0x13, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x12, %eax
jne 0xedbd
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xedbd
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xedbd
movb $0x1, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
addl $0x1, %eax
movb %al, -0x1(%rbp)
jmp 0xef87
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0xeeda
movzbl -0x11(%rbp), %eax
cmpl $0x2a, %eax
jne 0xee19
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xee10
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
jne 0xee10
movb $0x12, -0x1(%rbp)
jmp 0xef87
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x28, %eax
je 0xee39
movzbl -0x11(%rbp), %eax
cmpl $0x23, %eax
jne 0xee42
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0xc, %eax
cmpl $0x0, %eax
jne 0xee42
movb $0x1, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x11, %eax
jne 0xee92
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0xee62
movb $0x29, -0x1(%rbp)
jmp 0xef87
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xee89
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
jne 0xee89
movb $0x12, -0x1(%rbp)
jmp 0xef87
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x12, %eax
jne 0xeecb
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xeec2
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xeec2
movb $0x13, -0x1(%rbp)
jmp 0xef87
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
addl $0x1, %eax
movb %al, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x28, %eax
jl 0xeefa
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
jne 0xeefa
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x23, %eax
jl 0xef17
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0xc, %eax
cmpl $0x0, %eax
jne 0xef17
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x2a, %eax
jne 0xef26
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x1, %eax
jne 0xef35
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x12, %eax
jne 0xef68
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0xef62
movq -0x10(%rbp), %rax
movl (%rax), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xef62
movb $0x11, -0x1(%rbp)
jmp 0xef87
movb $0x0, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
cmpl $0x12, %eax
jge 0xef7d
movzbl -0x11(%rbp), %eax
subl $0x1, %eax
movb %al, -0x1(%rbp)
jmp 0xef87
movzbl -0x11(%rbp), %eax
addl $0x1, %eax
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
popq %rbp
retq
nopl (%rax)