// File: /workspace/github_c_makefile_star2_O0/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioGetLoRaTimeOnAirNumerator
static uint32_t RadioGetLoRaTimeOnAirNumerator( uint32_t bandwidth,
                              uint32_t datarate, uint8_t coderate,
                              uint16_t preambleLen, bool fixLen, uint8_t payloadLen,
                              bool crcOn )
{
    int32_t crDenom           = coderate + 4;
    bool    lowDatareOptimize = false;

    // Ensure that the preamble length is at least 12 symbols when using SF5 or
    // SF6
    if( ( datarate == 5 ) || ( datarate == 6 ) )
    {
        if( preambleLen < 12 )
        {
            preambleLen = 12;
        }
    }

    if( ( ( bandwidth == 0 ) && ( ( datarate == 11 ) || ( datarate == 12 ) ) ) ||
        ( ( bandwidth == 1 ) && ( datarate == 12 ) ) )
    {
        lowDatareOptimize = true;
    }

    int32_t ceilDenominator;
    int32_t ceilNumerator = ( payloadLen << 3 ) +
                            ( crcOn ? 16 : 0 ) -
                            ( 4 * datarate ) +
                            ( fixLen ? 0 : 20 );

    if( datarate <= 6 )
    {
        ceilDenominator = 4 * datarate;
    }
    else
    {
        ceilNumerator += 8;

        if( lowDatareOptimize == true )
        {
            ceilDenominator = 4 * ( datarate - 2 );
        }
        else
        {
            ceilDenominator = 4 * datarate;
        }
    }

    if( ceilNumerator < 0 )
    {
        ceilNumerator = 0;
    }

    // Perform integral ceil()
    int32_t intermediate =
        ( ( ceilNumerator + ceilDenominator - 1 ) / ceilDenominator ) * crDenom + preambleLen + 12;

    if( datarate <= 6 )
    {
        intermediate += 2;
    }

    return ( uint32_t )( ( 4 * intermediate + 1 ) * ( 1 << ( datarate - 2 ) ) );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %r9d, -0x30(%rbp)
movl %r8d, -0x2c(%rbp)
movl %ecx, %eax
movl -0x30(%rbp), %ecx
movl %eax, -0x28(%rbp)
movl %edx, %eax
movl -0x2c(%rbp), %edx
movl %esi, %r8d
movl -0x28(%rbp), %esi
movl %edi, %r9d
movb %al, %dil
movb 0x10(%rbp), %al
movl %r9d, -0x4(%rbp)
movl %r8d, -0x8(%rbp)
movb %dil, -0x9(%rbp)
movw %si, -0xc(%rbp)
andb $0x1, %dl
movb %dl, -0xd(%rbp)
movb %cl, -0xe(%rbp)
andb $0x1, %al
movb %al, -0xf(%rbp)
movzbl -0x9(%rbp), %eax
addl $0x4, %eax
movl %eax, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
cmpl $0x5, -0x8(%rbp)
je 0x5310
cmpl $0x6, -0x8(%rbp)
jne 0x5321
movzwl -0xc(%rbp), %eax
cmpl $0xc, %eax
jge 0x531f
movw $0xc, -0xc(%rbp)
jmp 0x5321
cmpl $0x0, -0x4(%rbp)
jne 0x5333
cmpl $0xb, -0x8(%rbp)
je 0x533f
cmpl $0xc, -0x8(%rbp)
je 0x533f
cmpl $0x1, -0x4(%rbp)
jne 0x5343
cmpl $0xc, -0x8(%rbp)
jne 0x5343
movb $0x1, -0x15(%rbp)
movzbl -0xe(%rbp), %eax
shll $0x3, %eax
movb -0xf(%rbp), %sil
xorl %ecx, %ecx
movl $0x10, %edx
testb $0x1, %sil
cmovnel %edx, %ecx
addl %ecx, %eax
movl -0x8(%rbp), %ecx
shll $0x2, %ecx
subl %ecx, %eax
movb -0xd(%rbp), %sil
movl $0x14, %ecx
xorl %edx, %edx
testb $0x1, %sil
cmovnel %edx, %ecx
addl %ecx, %eax
movl %eax, -0x20(%rbp)
cmpl $0x6, -0x8(%rbp)
ja 0x538e
movl -0x8(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x1c(%rbp)
jmp 0x53bd
movl -0x20(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x20(%rbp)
movb -0x15(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x53b2
movl -0x8(%rbp), %eax
subl $0x2, %eax
shll $0x2, %eax
movl %eax, -0x1c(%rbp)
jmp 0x53bb
movl -0x8(%rbp), %eax
shll $0x2, %eax
movl %eax, -0x1c(%rbp)
jmp 0x53bd
cmpl $0x0, -0x20(%rbp)
jge 0x53ca
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
addl -0x1c(%rbp), %eax
subl $0x1, %eax
cltd
idivl -0x1c(%rbp)
imull -0x14(%rbp), %eax
movzwl -0xc(%rbp), %ecx
addl %ecx, %eax
addl $0xc, %eax
movl %eax, -0x24(%rbp)
cmpl $0x6, -0x8(%rbp)
ja 0x53f6
movl -0x24(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
shll $0x2, %eax
addl $0x1, %eax
movl -0x8(%rbp), %ecx
subl $0x2, %ecx
movl $0x1, %edx
shll %cl, %edx
movl %edx, %ecx
imull %ecx, %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)