LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioSetModem
void RadioSetModem( RadioModems_t modem )
{
    printf("RadioSetModem\r\n");
    switch( modem )
    {
    default:
    case MODEM_FSK:
        SX126xSetPacketType( PACKET_TYPE_GFSK );
        // When switching to GFSK mode the LoRa SyncWord register value is reset
        // Thus, we also reset the RadioPublicNetwork variable
        RadioPublicNetwork.Current = false;
        break;
    case MODEM_LORA:
        SX126xSetPacketType( PACKET_TYPE_LORA );
        // Public/Private network register is reset when switching modems
        if( RadioPublicNetwork.Current != RadioPublicNetwork.Previous )
        {
            RadioPublicNetwork.Current = RadioPublicNetwork.Previous;
            RadioSetPublicNetwork( RadioPublicNetwork.Current );
        }
        break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0x3a48(%rip), %rdi      # 0x654f
callq 0x2260
cmpl $0x1, %ebx
jne 0x2b3d
movl $0x1, %edi
callq 0x432a
movb 0x77d7(%rip), %al       # 0xa2f8
cmpb %al, 0x77d2(%rip)       # 0xa2f9
je 0x2b4b
movb %al, 0x77ca(%rip)       # 0xa2f9
movzbl %al, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x36a4
xorl %edi, %edi
callq 0x432a
movb $0x0, 0x77ae(%rip)      # 0xa2f9
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioIsChannelFree
bool RadioIsChannelFree( uint32_t freq, uint32_t rxBandwidth, int16_t rssiThresh, uint32_t maxCarrierSenseTime )
{
    printf("RadioIsChannelFree: freq=%d, rxBandwidth=%d\r\n", (int) freq, (int) rxBandwidth);
    bool     status           = true;
    int16_t  rssi             = 0;
    uint32_t carrierSenseTime = 0;

    RadioSetModem( MODEM_FSK );

    RadioSetChannel( freq );

    // Set Rx bandwidth. Other parameters are not used.
    RadioSetRxConfig( MODEM_FSK, rxBandwidth, 600, 0, rxBandwidth, 3, 0, false,
                      0, false, 0, 0, false, true );
    RadioRx( 0 );

    DelayMs( 1 );

    carrierSenseTime = TimerGetCurrentTime( );
    printf("RadioIsChannelFree: carrierSenseTime=%d, elapsed=%d, maxCarrierSenseTime=%d\r\n", (int) carrierSenseTime, (int) TimerGetElapsedTime( carrierSenseTime ), (int) maxCarrierSenseTime);

    // Perform carrier sense for maxCarrierSenseTime
    while( TimerGetElapsedTime( carrierSenseTime ) < maxCarrierSenseTime )
    {
        rssi = RadioRssi( MODEM_FSK );

        if( rssi > rssiThresh )
        {
            status = false;
            break;
        }
    }
    RadioSleep( );
    printf("RadioIsChannelFree done\r\n");
    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebx
movl %edx, %r14d
movl %esi, %r15d
movl %edi, %r12d
leaq 0x36ab(%rip), %rdi      # 0x6242
xorl %r13d, %r13d
movl %r12d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x2050
leaq 0x39a1(%rip), %rdi      # 0x654f
callq 0x2260
xorl %edi, %edi
callq 0x432a
movb $0x0, 0x7738(%rip)      # 0xa2f9
leaq 0x365f(%rip), %rdi      # 0x6227
movl %r12d, %esi
xorl %eax, %eax
callq 0x2050
movl %r12d, %edi
callq 0x42ae
xorl %edi, %edi
movl %r15d, %esi
movl $0x258, %edx            # imm = 0x258
xorl %ecx, %ecx
movl $0x3, %r9d
pushq $0x1
pushq %r13
pushq %r13
pushq %r13
pushq %r13
pushq %r13
pushq %r13
pushq %r13
callq 0x2ca0
addq $0x40, %rsp
xorl %edi, %edi
callq 0x357a
movl $0x1, %edi
callq 0x50d5
callq 0x50ec
movl %eax, %r15d
movl %eax, %edi
callq 0x510f
leaq 0x3644(%rip), %rdi      # 0x6270
movl %r15d, %esi
movl %eax, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2050
movl %r15d, %edi
callq 0x510f
movl %eax, %r12d
cmpl %ebx, %eax
jae 0x2c57
callq 0x4750
movsbl %al, %eax
cmpw %r14w, %ax
jle 0x2c3a
cmpl %ebx, %r12d
setae %bl
callq 0x353d
leaq 0x38f5(%rip), %rdi      # 0x655e
callq 0x2260
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioSend
void RadioSend( uint8_t *buffer, uint8_t size )
{
    printf("RadioSend: size=%d\r\n", (int) size);
    for (int i = 0; i < size; i++) {
        printf("%02x ", buffer[i]);
    }
    printf("\r\n");

    SX126xSetDioIrqParams( IRQ_TX_DONE | IRQ_RX_TX_TIMEOUT,
                           IRQ_TX_DONE | IRQ_RX_TX_TIMEOUT,
                           IRQ_RADIO_NONE,
                           IRQ_RADIO_NONE );

    if( SX126xGetPacketType( ) == PACKET_TYPE_LORA )
    {
        SX126x.PacketParams.Params.LoRa.PayloadLength = size;
    }
    else
    {
        SX126x.PacketParams.Params.Gfsk.PayloadLength = size;
    }

    //// TODO
    printf("RadioSend: PreambleLength=%d, HeaderType=%d, PayloadLength=%d, CrcMode=%d, InvertIQ=%d\r\n", (int) SX126x.PacketParams.Params.LoRa.PreambleLength, (int) SX126x.PacketParams.Params.LoRa.HeaderType, (int) SX126x.PacketParams.Params.LoRa.PayloadLength, (int) SX126x.PacketParams.Params.LoRa.CrcMode, (int) SX126x.PacketParams.Params.LoRa.InvertIQ); //// TODO

    SX126xSetPacketParams( &SX126x.PacketParams );

    SX126xSendPayload( buffer, size, 0 );
    TimerStart( &TxTimeoutTimer, TxTimeout );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %rbx
leaq 0x2fb5(%rip), %rdi      # 0x641b
xorl %eax, %eax
callq 0x2050
movzbl %r15b, %r14d
testl %r15d, %r15d
je 0x3497
leaq 0x2bff(%rip), %r12      # 0x607c
xorl %r13d, %r13d
movzbl (%rbx,%r13), %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x2050
incq %r13
cmpq %r13, %r14
jne 0x3480
leaq 0x2c1f(%rip), %rdi      # 0x60bd
callq 0x2260
movl $0x201, %edi            # imm = 0x201
movl $0x201, %esi            # imm = 0x201
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x41ec
callq 0x3d30
cmpl $0x1, %eax
jne 0x34c9
movb %r15b, 0x6e69(%rip)     # 0xa330
jmp 0x34d8
movb %r15b, 0x6e4c(%rip)     # 0xa31c
movzbl 0x6e58(%rip), %r15d     # 0xa330
movzwl 0x6e49(%rip), %esi      # 0xa328
movl 0x6e47(%rip), %edx      # 0xa32c
movl 0x6e48(%rip), %r8d      # 0xa334
movl 0x6e45(%rip), %r9d      # 0xa338
leaq 0x2f36(%rip), %rdi      # 0x6430
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2050
leaq 0x6df9(%rip), %rdi      # 0xa304
callq 0x4526
movq %rbx, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x3c8a
movl 0x6d0d(%rip), %esi      # 0xa230
leaq 0x6d5e(%rip), %rdi      # 0xa288
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5050
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioRx
void RadioRx( uint32_t timeout )
{
    printf("RadioRx\r\n");
    SX126xSetDioIrqParams( IRQ_RADIO_ALL, //IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT,
                           IRQ_RADIO_ALL, //IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT,
                           IRQ_RADIO_NONE,
                           IRQ_RADIO_NONE );

    if( timeout != 0 )
    {
        TimerStart( &RxTimeoutTimer, timeout );
    }

    if( RxContinuous == true )
    {
        SX126xSetRx( 0xFFFFFF ); // Rx Continuous
    }
    else
    {
        SX126xSetRx( RxTimeout << 6 );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0x3031(%rip), %rdi      # 0x65ba
callq 0x2260
movl $0xffff, %edi           # imm = 0xFFFF
movl $0xffff, %esi           # imm = 0xFFFF
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x41ec
testl %ebx, %ebx
je 0x35b3
leaq 0x6d14(%rip), %rdi      # 0xa2c0
movl %ebx, %esi
callq 0x5050
movl 0x6c7b(%rip), %eax      # 0xa234
shll $0x6, %eax
cmpb $0x0, 0x6c75(%rip)      # 0xa238
movl $0xffffff, %edi         # imm = 0xFFFFFF
cmovel %eax, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x3e7b
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioSetTxContinuousWave
void RadioSetTxContinuousWave( uint32_t freq, int8_t power, uint16_t time )
{
    uint32_t timeout = ( uint32_t )time * 1000;

    SX126xSetRfFrequency( freq );
    SX126xSetRfTxPower( power );
    SX126xSetTxContinuousWave( );

    TimerStart( &TxTimeoutTimer, timeout );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
imull $0x3e8, %edx, %r14d     # imm = 0x3E8
callq 0x42ae
movl %ebx, %edi
callq 0x4f1b
callq 0x3fd0
leaq 0x6c6d(%rip), %rdi      # 0xa288
movl %r14d, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x5050
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioSetPublicNetwork
void RadioSetPublicNetwork( bool enable )
{
    RadioPublicNetwork.Current = RadioPublicNetwork.Previous = enable;

    RadioSetModem( MODEM_LORA );
    if( enable == true )
    {
        printf("RadioSetPublicNetwork: public syncword=%x\r\n", LORA_MAC_PUBLIC_SYNCWORD); //// TODO
        // Change LoRa modem SyncWord
        SX126xWriteRegister( REG_LR_SYNCWORD, ( LORA_MAC_PUBLIC_SYNCWORD >> 8 ) & 0xFF );
        SX126xWriteRegister( REG_LR_SYNCWORD + 1, LORA_MAC_PUBLIC_SYNCWORD & 0xFF );
    }
    else
    {
        printf("RadioSetPublicNetwork: private syncword=%x\r\n", LORA_MAC_PRIVATE_SYNCWORD); //// TODO
        // Change LoRa modem SyncWord
        SX126xWriteRegister( REG_LR_SYNCWORD, ( LORA_MAC_PRIVATE_SYNCWORD >> 8 ) & 0xFF );
        SX126xWriteRegister( REG_LR_SYNCWORD + 1, LORA_MAC_PRIVATE_SYNCWORD & 0xFF );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movb %bl, 0x6c46(%rip)       # 0xa2f8
movb %bl, 0x6c41(%rip)       # 0xa2f9
movl $0x1, %edi
callq 0x2af8
testl %ebx, %ebx
je 0x36df
leaq 0x2dbc(%rip), %rdi      # 0x6489
movl $0x3444, %esi           # imm = 0x3444
xorl %eax, %eax
callq 0x2050
movb $0x44, %bl
movb $0x34, %al
jmp 0x36f6
leaq 0x2dcf(%rip), %rdi      # 0x64b5
movl $0x1424, %esi           # imm = 0x1424
xorl %eax, %eax
callq 0x2050
movb $0x24, %bl
movb $0x14, %al
movzbl %al, %esi
movl $0x740, %edi            # imm = 0x740
callq 0x4dd3
movzbl %bl, %esi
movl $0x741, %edi            # imm = 0x741
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4dd3
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioRxBoosted
void RadioRxBoosted( uint32_t timeout )
{
    SX126xSetDioIrqParams( IRQ_RADIO_ALL, //IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT,
                           IRQ_RADIO_ALL, //IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT,
                           IRQ_RADIO_NONE,
                           IRQ_RADIO_NONE );

    if( timeout != 0 )
    {
        TimerStart( &RxTimeoutTimer, timeout );
    }

    if( RxContinuous == true )
    {
        SX126xSetRxBoosted( 0xFFFFFF ); // Rx Continuous
    }
    else
    {
        SX126xSetRxBoosted( RxTimeout << 6 );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0xffff, %edi           # imm = 0xFFFF
movl $0xffff, %esi           # imm = 0xFFFF
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x41ec
testl %ebx, %ebx
je 0x39ab
leaq 0x691c(%rip), %rdi      # 0xa2c0
movl %ebx, %esi
callq 0x5050
movl 0x6883(%rip), %eax      # 0xa234
shll $0x6, %eax
cmpb $0x0, 0x687d(%rip)      # 0xa238
movl $0xffffff, %edi         # imm = 0xFFFFFF
cmovel %eax, %edi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x3f21
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioAddRegisterToRetentionList
void RadioAddRegisterToRetentionList( uint16_t registerAddress )
{
    uint8_t buffer[9];

    // Read the address and registers already added to the list
    SX126xReadRegisters( REG_RETENTION_LIST_BASE_ADDRESS, buffer, 9 );

    const uint8_t nbOfRegisters = buffer[0];
    uint8_t* registerList   = &buffer[1];

    // Check if the register given as parameter is already added to the list
    for( uint8_t i = 0; i < nbOfRegisters; i++ )
    {
        if( registerAddress == ( ( uint16_t ) registerList[2 * i] << 8 ) + registerList[2 * i + 1] )
        {
            return;
        }
    }

    if( nbOfRegisters < MAX_NB_REG_IN_RETENTION )
    {
        buffer[0] += 1;
        registerList[2 * nbOfRegisters]     = ( uint8_t )( registerAddress >> 8 );
        registerList[2 * nbOfRegisters + 1] = ( uint8_t )( registerAddress >> 0 );

        // Update radio with modified list
        SX126xWriteRegisters( REG_RETENTION_LIST_BASE_ADDRESS, buffer, 9 );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %r14d
leaq -0x19(%rbp), %rbx
movl $0x29f, %edi            # imm = 0x29F
movq %rbx, %rsi
movl $0x9, %edx
callq 0x4df5
movzbl (%rbx), %eax
movl %r14d, %ebx
testq %rax, %rax
je 0x3a45
movzwl %bx, %ecx
xorl %edx, %edx
movzwl -0x18(%rbp,%rdx,2), %esi
rolw $0x8, %si
movzwl %si, %esi
cmpl %ecx, %esi
je 0x3a6a
incq %rdx
cmpq %rdx, %rax
jne 0x3a29
cmpb $0x3, %al
ja 0x3a6a
leal 0x1(%rax), %ecx
leaq -0x19(%rbp), %rsi
movb %cl, (%rsi)
addl %eax, %eax
movb %bh, -0x18(%rbp,%rax)
movzbl %al, %eax
movb %bl, -0x17(%rbp,%rax)
movl $0x29f, %edi            # imm = 0x29F
movl $0x9, %edx
callq 0x4d7e
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xInit
void SX126xInit( DioIrqHandler dioIrq )
{
    SX126xReset( );

    SX126xIoIrqInit( dioIrq );

    SX126xWakeup( );
    SX126xSetStandby( STDBY_RC );

    // Initialize TCXO control
    SX126xIoTcxoInit( );

    // Initialize RF switch control
    SX126xIoRfSwitchInit( );

    // Force image calibration
    ImageCalibrated = false;

    SX126xSetOperatingMode( MODE_STDBY_RC );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x49eb
movq %rbx, %rdi
callq 0x4986
callq 0x4a17
leaq -0xc(%rbp), %rbx
movl $0x0, (%rbx)
movl $0x80, %edi
movq %rbx, %rsi
movl $0x1, %edx
callq 0x4b5f
cmpl $0x1, (%rbx)
movl $0x2, %edi
sbbl $0x0, %edi
callq 0x49df
callq 0x49b3
callq 0x49c4
movb $0x0, 0x692c(%rip)      # 0xa498
movl $0x1, %edi
callq 0x49df
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xCheckDeviceReady
void SX126xCheckDeviceReady( void )
{
    if( ( SX126xGetOperatingMode( ) == MODE_SLEEP ) || ( SX126xGetOperatingMode( ) == MODE_RX_DC ) )
    {
        SX126xWakeup( );
        // Switch is turned off when device is in sleep mode and turned on is all other modes
        SX126xAntSwOn( );
    }
    SX126xWaitOnBusy( );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
callq 0x49d3
testl %eax, %eax
je 0x3bc9
callq 0x49d3
cmpl $0x6, %eax
jne 0x3bd3
callq 0x4a17
callq 0x4f55
popq %rbp
jmp 0x49fc
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetPayload
uint8_t SX126xGetPayload( uint8_t *buffer, uint8_t *size,  uint8_t maxSize )
{
    uint8_t offset = 0;

    SX126xGetRxBufferStatus( size, &offset );
    if( *size > maxSize )
    {
        return 1;
    }
    SX126xReadBuffer( offset, buffer, *size );
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
leaq -0x19(%rbp), %rsi
movb $0x0, (%rsi)
movq %r15, %rdi
callq 0x3c32
movb (%r15), %cl
movb $0x1, %al
cmpb %r14b, %cl
ja 0x3c27
movzbl -0x19(%rbp), %edi
movzbl %cl, %edx
movq %rbx, %rsi
callq 0x4ec3
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetRxBufferStatus
void SX126xGetRxBufferStatus( uint8_t *payloadLength, uint8_t *rxStartBufferPointer )
{
    uint8_t status[2];

    SX126xReadCommand( RADIO_GET_RXBUFFERSTATUS, status, 2 );

    // In case of LORA fixed header, the payloadLength is obtained by reading
    // the register REG_LR_PAYLOADLENGTH
    if( ( SX126xGetPacketType( ) == PACKET_TYPE_LORA ) && ( LoRaHeaderType == LORA_PACKET_FIXED_LENGTH ) )
    {
        *payloadLength = SX126xReadRegister( REG_LR_PAYLOADLENGTH );
    }
    else
    {
        *payloadLength = status[0];
    }
    *rxStartBufferPointer = status[1];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x12(%rbp), %rsi
movl $0x13, %edi
movl $0x2, %edx
callq 0x4bc0
cmpl $0x1, 0x683f(%rip)      # 0xa49c
jne 0x3c76
movl 0x683b(%rip), %eax      # 0xa4a0
cmpl $0x1, %eax
jne 0x3c76
movl $0x702, %edi            # imm = 0x702
callq 0x4e50
jmp 0x3c79
movb -0x12(%rbp), %al
movb %al, (%r14)
movb -0x11(%rbp), %al
movb %al, (%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetTx
void SX126xSetTx( uint32_t timeout )
{
    uint8_t buf[3];

    SX126xSetOperatingMode( MODE_TX );

    buf[0] = ( uint8_t )( ( timeout >> 16 ) & 0xFF );
    buf[1] = ( uint8_t )( ( timeout >> 8 ) & 0xFF );
    buf[2] = ( uint8_t )( timeout & 0xFF );
    SX126xWriteCommand( RADIO_SET_TX, buf, 3 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x4, %edi
callq 0x49df
movl %ebx, %eax
shrl $0x10, %eax
leaq -0xb(%rbp), %rsi
movb %al, (%rsi)
movb %bh, -0xa(%rbp)
movb %bl, 0x2(%rsi)
movl $0x83, %edi
movl $0x3, %edx
callq 0x4b5f
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetWhiteningSeed
void SX126xSetWhiteningSeed( uint16_t seed )
{
    uint8_t regValue = 0;
    
    switch( SX126xGetPacketType( ) )
    {
        case PACKET_TYPE_GFSK:
            regValue = SX126xReadRegister( REG_LR_WHITSEEDBASEADDR_MSB ) & 0xFE;
            regValue = ( ( seed >> 8 ) & 0x01 ) | regValue;
            SX126xWriteRegister( REG_LR_WHITSEEDBASEADDR_MSB, regValue ); // only 1 bit.
            SX126xWriteRegister( REG_LR_WHITSEEDBASEADDR_LSB, ( uint8_t )seed );
            break;

        default:
            break;
    }
}

// Assembly:
cmpl $0x0, 0x6727(%rip)      # 0xa49c
je 0x3d78
retq
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x6b8, %edi            # imm = 0x6B8
callq 0x4e50
andb $-0x2, %al
movl %ebx, %ecx
shrl $0x8, %ecx
andb $0x1, %cl
orb %al, %cl
movzbl %cl, %esi
movl $0x6b8, %edi            # imm = 0x6B8
callq 0x4dd3
movzbl %bl, %esi
movl $0x6b9, %edi            # imm = 0x6B9
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4dd3
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetRandom
uint32_t SX126xGetRandom( void )
{
    uint32_t number = 0;
    uint8_t regAnaLna = 0;
    uint8_t regAnaMixer = 0;

    regAnaLna = SX126xReadRegister( REG_ANA_LNA );
    SX126xWriteRegister( REG_ANA_LNA, regAnaLna & ~( 1 << 0 ) );

    regAnaMixer = SX126xReadRegister( REG_ANA_MIXER );
    SX126xWriteRegister( REG_ANA_MIXER, regAnaMixer & ~( 1 << 7 ) );

    // Set radio in continuous reception
    SX126xSetRx( 0xFFFFFF ); // Rx Continuous

    SX126xReadRegisters( RANDOM_NUMBER_GENERATORBASEADDR, ( uint8_t* )&number, 4 );

    SX126xSetStandby( STDBY_RC );

    SX126xWriteRegister( REG_ANA_LNA, regAnaLna );
    SX126xWriteRegister( REG_ANA_MIXER, regAnaMixer );

    return number;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %r13d, %r13d
leaq -0x2c(%rbp), %rbx
movl %r13d, (%rbx)
movl $0x8e2, %edi            # imm = 0x8E2
callq 0x4e50
movl %eax, %r14d
andb $-0x2, %al
movzbl %al, %esi
movl $0x8e2, %edi            # imm = 0x8E2
callq 0x4dd3
movl $0x8e5, %edi            # imm = 0x8E5
callq 0x4e50
movl %eax, %r15d
andb $0x7f, %al
movzbl %al, %esi
movl $0x8e5, %edi            # imm = 0x8E5
callq 0x4dd3
movl $0xffffff, %edi         # imm = 0xFFFFFF
callq 0x3e7b
movl $0x819, %edi            # imm = 0x819
movq %rbx, %rsi
movl $0x4, %edx
callq 0x4df5
leaq -0x30(%rbp), %r12
movl %r13d, (%r12)
movl $0x80, %edi
movq %r12, %rsi
movl $0x1, %edx
callq 0x4b5f
cmpl $0x1, (%r12)
movl $0x2, %edi
sbbl %r13d, %edi
callq 0x49df
movzbl %r14b, %esi
movl $0x8e2, %edi            # imm = 0x8E2
callq 0x4dd3
movzbl %r15b, %esi
movl $0x8e5, %edi            # imm = 0x8E5
callq 0x4dd3
movl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetRx
void SX126xSetRx( uint32_t timeout )
{
    uint8_t buf[3];

    SX126xSetOperatingMode( MODE_RX );

    SX126xWriteRegister( REG_RX_GAIN, 0x94 ); // default gain

    buf[0] = ( uint8_t )( ( timeout >> 16 ) & 0xFF );
    buf[1] = ( uint8_t )( ( timeout >> 8 ) & 0xFF );
    buf[2] = ( uint8_t )( timeout & 0xFF );
    SX126xWriteCommand( RADIO_SET_RX, buf, 3 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x5, %edi
callq 0x49df
movl $0x8ac, %edi            # imm = 0x8AC
movl $0x94, %esi
callq 0x4dd3
movl %ebx, %eax
shrl $0x10, %eax
leaq -0xb(%rbp), %rsi
movb %al, (%rsi)
movb %bh, -0xa(%rbp)
movb %bl, 0x2(%rsi)
movl $0x82, %edi
movl $0x3, %edx
callq 0x4b5f
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetSleep
void SX126xSetSleep( SleepParams_t sleepConfig )
{
    SX126xAntSwOff( );

    uint8_t value = ( ( ( uint8_t )sleepConfig.Fields.WarmStart << 2 ) |
                      ( ( uint8_t )sleepConfig.Fields.Reset << 1 ) |
                      ( ( uint8_t )sleepConfig.Fields.WakeUpRTC ) );

    if( sleepConfig.Fields.WarmStart == 0 )
    {
        // Force image calibration
        ImageCalibrated = false;
    }
    SX126xWriteCommand( RADIO_SET_SLEEP, &value, 1 );
    SX126xSetOperatingMode( MODE_SLEEP );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
callq 0x4f5b
movl %ebx, %eax
andb $0x7, %al
movb %al, -0x9(%rbp)
testb $0x4, %bl
jne 0x3ee3
movb $0x0, 0x65b5(%rip)      # 0xa498
leaq -0x9(%rbp), %rsi
movl $0x84, %edi
movl $0x1, %edx
callq 0x4b5f
xorl %edi, %edi
callq 0x49df
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetRxBoosted
void SX126xSetRxBoosted( uint32_t timeout )
{
    uint8_t buf[3];

    SX126xSetOperatingMode( MODE_RX );

    SX126xWriteRegister( REG_RX_GAIN, 0x96 ); // max LNA gain, increase current by ~2mA for around ~3dB in sensitivity

    buf[0] = ( uint8_t )( ( timeout >> 16 ) & 0xFF );
    buf[1] = ( uint8_t )( ( timeout >> 8 ) & 0xFF );
    buf[2] = ( uint8_t )( timeout & 0xFF );
    SX126xWriteCommand( RADIO_SET_RX, buf, 3 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x5, %edi
callq 0x49df
movl $0x8ac, %edi            # imm = 0x8AC
movl $0x96, %esi
callq 0x4dd3
movl %ebx, %eax
shrl $0x10, %eax
leaq -0xb(%rbp), %rsi
movb %al, (%rsi)
movb %bh, -0xa(%rbp)
movb %bl, 0x2(%rsi)
movl $0x82, %edi
movl $0x3, %edx
callq 0x4b5f
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetRxDutyCycle
void SX126xSetRxDutyCycle( uint32_t rxTime, uint32_t sleepTime )
{
    uint8_t buf[6];

    buf[0] = ( uint8_t )( ( rxTime >> 16 ) & 0xFF );
    buf[1] = ( uint8_t )( ( rxTime >> 8 ) & 0xFF );
    buf[2] = ( uint8_t )( rxTime & 0xFF );
    buf[3] = ( uint8_t )( ( sleepTime >> 16 ) & 0xFF );
    buf[4] = ( uint8_t )( ( sleepTime >> 8 ) & 0xFF );
    buf[5] = ( uint8_t )( sleepTime & 0xFF );
    SX126xWriteCommand( RADIO_SET_RXDUTYCYCLE, buf, 6 );
    SX126xSetOperatingMode( MODE_RX_DC );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %esi, %eax
movl %edi, %ecx
movl %edi, %edx
shrl $0x10, %edx
leaq -0x6(%rbp), %rsi
movb %dl, (%rsi)
movb %ch, -0x5(%rbp)
movb %cl, 0x2(%rsi)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x3(%rsi)
movb %ah, -0x2(%rbp)
movb %al, 0x5(%rsi)
movl $0x94, %edi
movl $0x6, %edx
callq 0x4b5f
movl $0x6, %edi
callq 0x49df
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetLoRaSymbNumTimeout
void SX126xSetLoRaSymbNumTimeout( uint8_t symbNum )
{
    uint8_t mant = ( ( ( symbNum > SX126X_MAX_LORA_SYMB_NUM_TIMEOUT ) ?
                       SX126X_MAX_LORA_SYMB_NUM_TIMEOUT : 
                       symbNum ) + 1 ) >> 1;
    uint8_t exp  = 0;
    uint8_t reg  = 0;

    while( mant > 31 )
    {
        mant = ( mant + 3 ) >> 2;
        exp++;
    }

    reg = mant << ( 2 * exp + 1 );
    SX126xWriteCommand( RADIO_SET_LORASYMBTIMEOUT, &reg, 1 );

    if( symbNum != 0 )
    {
        reg = exp + ( mant << 3 );
        SX126xWriteRegister( REG_LR_SYNCH_TIMEOUT, reg );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
cmpb $-0x8, %bl
movl $0xf8, %eax
cmovbl %edi, %eax
incb %al
shrb %al
movzbl %al, %eax
leal 0x3(%rax), %r14d
shrl $0x2, %r14d
cmpb $0x3f, %bl
cmovbl %eax, %r14d
setae %cl
addb %cl, %cl
incb %cl
movl %r14d, %eax
shll %cl, %eax
leaq -0x11(%rbp), %rsi
movb %al, (%rsi)
movl $0xa0, %edi
movl $0x1, %edx
callq 0x4b5f
testl %ebx, %ebx
je 0x40a0
cmpb $0x3f, %bl
setae %al
shlb $0x3, %r14b
orb %al, %r14b
movb %r14b, -0x11(%rbp)
movzbl %r14b, %esi
movl $0x706, %edi            # imm = 0x706
callq 0x4dd3
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xCalibrateImage
void SX126xCalibrateImage( uint32_t freq )
{
    uint8_t calFreq[2];

    if( freq > 900000000 )
    {
        calFreq[0] = 0xE1;
        calFreq[1] = 0xE9;
    }
    else if( freq > 850000000 )
    {
        calFreq[0] = 0xD7;
        calFreq[1] = 0xDB;
    }
    else if( freq > 770000000 )
    {
        calFreq[0] = 0xC1;
        calFreq[1] = 0xC5;
    }
    else if( freq > 460000000 )
    {
        calFreq[0] = 0x75;
        calFreq[1] = 0x81;
    }
    else if( freq > 425000000 )
    {
        calFreq[0] = 0x6B;
        calFreq[1] = 0x6F;
    }
    SX126xWriteCommand( RADIO_CALIBRATEIMAGE, calFreq, 2 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
cmpl $0x35a4e901, %edi       # imm = 0x35A4E901
jb 0x410c
movb $-0x1f, -0x2(%rbp)
movb $-0x17, %al
jmp 0x414a
cmpl $0x32a9f881, %edi       # imm = 0x32A9F881
jb 0x411c
movb $-0x29, -0x2(%rbp)
movb $-0x25, %al
jmp 0x414a
cmpl $0x2de54481, %edi       # imm = 0x2DE54481
jb 0x412c
movb $-0x3f, -0x2(%rbp)
movb $-0x3b, %al
jmp 0x414a
cmpl $0x1b6b0b01, %edi       # imm = 0x1B6B0B01
jb 0x413c
movb $0x75, -0x2(%rbp)
movb $-0x7f, %al
jmp 0x414a
cmpl $0x1954fc41, %edi       # imm = 0x1954FC41
jb 0x414d
movb $0x6b, -0x2(%rbp)
movb $0x6f, %al
movb %al, -0x1(%rbp)
leaq -0x2(%rbp), %rsi
movl $0x98, %edi
movl $0x2, %edx
callq 0x4b5f
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetPaConfig
void SX126xSetPaConfig( uint8_t paDutyCycle, uint8_t hpMax, uint8_t deviceSel, uint8_t paLut )
{
	printf("SX126xSetPaConfig: paDutyCycle=%d, hpMax=%d, deviceSel=%d, paLut=%d \r\n", (int) paDutyCycle, (int) hpMax, (int) deviceSel, (int) paLut);
    uint8_t buf[4];

    buf[0] = paDutyCycle;
    buf[1] = hpMax;
    buf[2] = deviceSel;
    buf[3] = paLut;
    SX126xWriteCommand( RADIO_SET_PACONFIG, buf, 4 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %ecx, %ebx
movl %edx, %r14d
movl %esi, %r15d
movl %edi, %r12d
leaq 0x2521(%rip), %rdi      # 0x66a8
movl %r12d, %esi
movl %r15d, %edx
movl %r14d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x2050
leaq -0x24(%rbp), %rsi
movb %r12b, (%rsi)
movb %r15b, 0x1(%rsi)
movb %r14b, 0x2(%rsi)
movb %bl, 0x3(%rsi)
movl $0x95, %edi
movl $0x4, %edx
callq 0x4b5f
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetDio3AsTcxoCtrl
void SX126xSetDio3AsTcxoCtrl( RadioTcxoCtrlVoltage_t tcxoVoltage, uint32_t timeout )
{
    uint8_t buf[4];

    buf[0] = tcxoVoltage & 0x07;
    buf[1] = ( uint8_t )( ( timeout >> 16 ) & 0xFF );
    buf[2] = ( uint8_t )( ( timeout >> 8 ) & 0xFF );
    buf[3] = ( uint8_t )( timeout & 0xFF );

    SX126xWriteCommand( RADIO_SET_TCXOMODE, buf, 4 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movl %esi, %eax
andb $0x7, %dil
leaq -0x4(%rbp), %rsi
movb %dil, (%rsi)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rsi)
movb %ah, -0x2(%rbp)
movb %al, 0x3(%rsi)
movl $0x97, %edi
movl $0x4, %edx
callq 0x4b5f
addq $0x10, %rsp
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetRfFrequency
void SX126xSetRfFrequency( uint32_t frequency )
{
    uint8_t buf[4];

    if( ImageCalibrated == false )
    {
        SX126xCalibrateImage( frequency );
        ImageCalibrated = true;
    }

    uint32_t freqInPllSteps = SX126xConvertFreqInHzToPllStep( frequency );

    buf[0] = ( uint8_t )( ( freqInPllSteps >> 24 ) & 0xFF );
    buf[1] = ( uint8_t )( ( freqInPllSteps >> 16 ) & 0xFF );
    buf[2] = ( uint8_t )( ( freqInPllSteps >> 8 ) & 0xFF );
    buf[3] = ( uint8_t )( freqInPllSteps & 0xFF );
    SX126xWriteCommand( RADIO_SET_RFFREQUENCY, buf, 4 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
cmpb $0x0, 0x61db(%rip)      # 0xa498
jne 0x42cd
movl %ebx, %edi
callq 0x40f4
movb $0x1, 0x61cb(%rip)      # 0xa498
movl %ebx, %eax
imulq $0x431bde83, %rax, %rax # imm = 0x431BDE83
shrq $0x2c, %rax
imull $0x3c2f7, %eax, %ecx    # imm = 0x3C2F7
addl %ebx, %ecx
shll $0xe, %eax
shll $0xe, %ecx
orl $0x1e84, %ecx           # imm = 0x1E84
imulq $0x431bde83, %rcx, %rcx # imm = 0x431BDE83
shrq $0x2c, %rcx
addl %ecx, %eax
movl %eax, %edx
shrl $0x18, %edx
leaq -0xc(%rbp), %rsi
movb %dl, (%rsi)
movl %eax, %edx
shrl $0x10, %edx
movb %dl, 0x1(%rsi)
movb %ah, -0xa(%rbp)
movb %cl, 0x3(%rsi)
movl $0x86, %edi
movl $0x4, %edx
callq 0x4b5f
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetTxParams
void SX126xSetTxParams( int8_t power, RadioRampTimes_t rampTime )
{
    printf("SX126xSetTxParams: power=%d, rampTime=%d\r\n", (int) power, (int) rampTime);
    uint8_t buf[2];

    if( SX126xGetDeviceId( ) == SX1261 )
    {
        if( power == 15 )
        {
            SX126xSetPaConfig( 0x06, 0x00, 0x01, 0x01 );
        }
        else
        {
            SX126xSetPaConfig( 0x04, 0x00, 0x01, 0x01 );
        }
        if( power >= 14 )
        {
            power = 14;
        }
        else if( power < -17 )
        {
            power = -17;
        }
        ////  TODO: Set the current max value in the over current protection. From SX126x-Arduino/src/radio/sx126x/sx126x.cpp
		SX126xWriteRegister(REG_OCP, 0x18); // current max is 80 mA for the whole device
    }
    else // sx1262
    {
        // WORKAROUND - Better Resistance of the SX1262 Tx to Antenna Mismatch, see DS_SX1261-2_V1.2 datasheet chapter 15.2
        SX126xWriteRegister( REG_TX_CLAMP_CFG, SX126xReadRegister( REG_TX_CLAMP_CFG ) | ( 0x0F << 1 ) );
        // WORKAROUND END

        SX126xSetPaConfig( 0x04, 0x07, 0x00, 0x01 );
        if( power > 22 )
        {
            power = 22;
        }
        else if( power < -9 )
        {
            power = -9;
        }

        ////  TODO: Set the current max value in the over current protection. From SX126x-Arduino/src/radio/sx126x/sx126x.cpp
        SX126xWriteRegister(REG_OCP, 0x38); // current max 160mA for the whole device
    }
    buf[0] = power;
    buf[1] = ( uint8_t )rampTime;
    SX126xWriteCommand( RADIO_SET_TXPARAMS, buf, 2 );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movl %edi, %r14d
leaq 0x2385(%rip), %rdi      # 0x66ef
movl %r14d, %esi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2050
callq 0x4f41
cmpb $0x1, %al
jne 0x43c1
xorl %eax, %eax
cmpb $0xf, %r14b
sete %al
leal 0x4(,%rax,2), %edi
xorl %esi, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x4166
movzbl %r14b, %eax
cmpb $-0x10, %r14b
movl $0xef, %ecx
cmovgel %eax, %ecx
cmpb $0xe, %cl
movl $0xe, %r14d
cmovll %ecx, %r14d
movb $0x18, %al
jmp 0x440d
movl $0x8d8, %edi            # imm = 0x8D8
callq 0x4e50
orb $0x1e, %al
movzbl %al, %esi
movl $0x8d8, %edi            # imm = 0x8D8
callq 0x4dd3
movl $0x4, %edi
movl $0x7, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x4166
movzbl %r14b, %eax
cmpb $-0x8, %al
movl $0xf7, %ecx
cmovgel %eax, %ecx
cmpb $0x16, %cl
movl $0x16, %r14d
cmovll %ecx, %r14d
movb $0x38, %al
movzbl %al, %esi
movl $0x8e7, %edi            # imm = 0x8E7
callq 0x4dd3
leaq -0x12(%rbp), %rsi
movb %r14b, (%rsi)
movb %bl, 0x1(%rsi)
movl $0x8e, %edi
movl $0x2, %edx
callq 0x4b5f
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetModulationParams
void SX126xSetModulationParams( ModulationParams_t *modulationParams )
{
    uint8_t n;
    uint32_t tempVal = 0;
    uint8_t buf[8] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

    // Check if required configuration corresponds to the stored packet type
    // If not, silently update radio packet type
    if( PacketType != modulationParams->PacketType )
    {
        SX126xSetPacketType( modulationParams->PacketType );
    }

    switch( modulationParams->PacketType )
    {
    case PACKET_TYPE_GFSK:
        n = 8;
        tempVal = ( uint32_t )( 32 * SX126X_XTAL_FREQ / modulationParams->Params.Gfsk.BitRate );
        buf[0] = ( tempVal >> 16 ) & 0xFF;
        buf[1] = ( tempVal >> 8 ) & 0xFF;
        buf[2] = tempVal & 0xFF;
        buf[3] = modulationParams->Params.Gfsk.ModulationShaping;
        buf[4] = modulationParams->Params.Gfsk.Bandwidth;
        tempVal = SX126xConvertFreqInHzToPllStep( modulationParams->Params.Gfsk.Fdev );
        buf[5] = ( tempVal >> 16 ) & 0xFF;
        buf[6] = ( tempVal >> 8 ) & 0xFF;
        buf[7] = ( tempVal& 0xFF );
        SX126xWriteCommand( RADIO_SET_MODULATIONPARAMS, buf, n );
        break;
    case PACKET_TYPE_LORA:
        n = 4;
        buf[0] = modulationParams->Params.LoRa.SpreadingFactor;
        buf[1] = modulationParams->Params.LoRa.Bandwidth;
        buf[2] = modulationParams->Params.LoRa.CodingRate;
        buf[3] = modulationParams->Params.LoRa.LowDatarateOptimize;

        SX126xWriteCommand( RADIO_SET_MODULATIONPARAMS, buf, n );

        break;
    default:
    case PACKET_TYPE_NONE:
        return;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq $0x0, -0x10(%rbp)
movl 0x6046(%rip), %eax      # 0xa49c
movl (%rdi), %ecx
cmpl %ecx, %eax
je 0x4479
leaq -0x14(%rbp), %rsi
movl %ecx, (%rsi)
movl %ecx, 0x6034(%rip)      # 0xa49c
movl $0x8a, %edi
movl $0x1, %edx
callq 0x4b5f
movl (%rbx), %eax
cmpl $0x1, %eax
je 0x44ef
testl %eax, %eax
jne 0x451f
leaq -0x9(%rbp), %rcx
movl $0x3d090000, %eax       # imm = 0x3D090000
xorl %edx, %edx
divl 0x4(%rbx)
movl %eax, %edx
shrl $0x10, %edx
movb %dl, -0x7(%rcx)
movb %ah, -0xf(%rbp)
movb %al, -0x5(%rcx)
movb 0xc(%rbx), %al
movb %al, -0x4(%rcx)
movb 0x10(%rbx), %al
movb %al, -0x3(%rcx)
movl 0x8(%rbx), %eax
imulq $0x431bde83, %rax, %rdx # imm = 0x431BDE83
shrq $0x2c, %rdx
imull $0x3c2f7, %edx, %esi    # imm = 0x3C2F7
addl %eax, %esi
shll $0xe, %edx
shll $0xe, %esi
orl $0x1e84, %esi           # imm = 0x1E84
imulq $0x431bde83, %rsi, %rax # imm = 0x431BDE83
shrq $0x2c, %rax
addl %eax, %edx
movl %edx, %esi
shrl $0x10, %esi
movb %sil, -0x2(%rcx)
movb %dh, -0xa(%rbp)
movw $0x8, %dx
jmp 0x450c
leaq -0xd(%rbp), %rcx
movb 0x14(%rbx), %al
movb %al, -0x3(%rcx)
movb 0x18(%rbx), %al
movb %al, -0x2(%rcx)
movb 0x1c(%rbx), %al
movb %al, -0x1(%rcx)
movb 0x20(%rbx), %al
movw $0x4, %dx
movb %al, (%rcx)
movzwl %dx, %edx
leaq -0x10(%rbp), %rsi
movl $0x8b, %edi
callq 0x4b5f
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xSetCadParams
void SX126xSetCadParams( RadioLoRaCadSymbols_t cadSymbolNum, uint8_t cadDetPeak, uint8_t cadDetMin, RadioCadExitModes_t cadExitMode, uint32_t cadTimeout )
{
    uint8_t buf[7];

    buf[0] = ( uint8_t )cadSymbolNum;
    buf[1] = cadDetPeak;
    buf[2] = cadDetMin;
    buf[3] = ( uint8_t )cadExitMode;
    buf[4] = ( uint8_t )( ( cadTimeout >> 16 ) & 0xFF );
    buf[5] = ( uint8_t )( ( cadTimeout >> 8 ) & 0xFF );
    buf[6] = ( uint8_t )( cadTimeout & 0xFF );
    SX126xWriteCommand( RADIO_SET_CADPARAMS, buf, 7 );
    SX126xSetOperatingMode( MODE_CAD );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movl %r8d, %ebx
leaq -0xf(%rbp), %rax
movb %dil, (%rax)
movb %sil, 0x1(%rax)
movb %dl, 0x2(%rax)
movb %cl, 0x3(%rax)
movl %r8d, %ecx
shrl $0x10, %ecx
movb %cl, 0x4(%rax)
movb %bh, -0xa(%rbp)
movb %bl, 0x6(%rax)
movl $0x88, %edi
movq %rax, %rsi
movl $0x7, %edx
callq 0x4b5f
movl $0x7, %edi
callq 0x49df
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetPacketStatus
void SX126xGetPacketStatus( PacketStatus_t *pktStatus )
{
    uint8_t status[3];

    SX126xReadCommand( RADIO_GET_PACKETSTATUS, status, 3 );

    pktStatus->packetType = SX126xGetPacketType( );
    switch( pktStatus->packetType )
    {
        case PACKET_TYPE_GFSK:
            pktStatus->Params.Gfsk.RxStatus = status[0];
            pktStatus->Params.Gfsk.RssiSync = -status[1] >> 1;
            pktStatus->Params.Gfsk.RssiAvg = -status[2] >> 1;
            pktStatus->Params.Gfsk.FreqError = 0;
            break;

        case PACKET_TYPE_LORA:
            pktStatus->Params.LoRa.RssiPkt = -status[0] >> 1;
            // Returns SNR value [dB] rounded to the nearest integer value
            pktStatus->Params.LoRa.SnrPkt = ( ( ( int8_t )status[1] ) + 2 ) >> 2;
            pktStatus->Params.LoRa.SignalRssiPkt = -status[2] >> 1;
            pktStatus->Params.LoRa.FreqError = FrequencyError;
            break;

        default:
        case PACKET_TYPE_NONE:
            // In that specific case, we set everything in the pktStatus to zeros
            // and reset the packet type accordingly
            memset( pktStatus, 0, sizeof( PacketStatus_t ) );
            pktStatus->packetType = PACKET_TYPE_NONE;
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq -0xb(%rbp), %rsi
movl $0x14, %edi
movl $0x3, %edx
callq 0x4bc0
movl 0x5d00(%rip), %eax      # 0xa49c
movl %eax, (%rbx)
cmpl $0x1, %eax
je 0x47cc
testl %eax, %eax
jne 0x47fa
movb -0xb(%rbp), %al
movb %al, 0x4(%rbx)
movzbl -0xa(%rbp), %eax
negl %eax
shrl %eax
movb %al, 0x6(%rbx)
movzbl -0x9(%rbp), %eax
negl %eax
shrl %eax
movb %al, 0x5(%rbx)
movl $0x0, 0x8(%rbx)
jmp 0x4807
movzbl -0xb(%rbp), %eax
negl %eax
shrl %eax
movb %al, 0xc(%rbx)
movsbl -0xa(%rbp), %eax
addl $0x2, %eax
shrl $0x2, %eax
movb %al, 0xd(%rbx)
movzbl -0x9(%rbp), %eax
negl %eax
shrl %eax
movb %al, 0xe(%rbx)
movl 0x5c9f(%rip), %eax      # 0xa494
movl %eax, 0x10(%rbx)
jmp 0x4807
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rbx)
movl $0xf, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x.c
// Function: SX126xGetDeviceErrors
RadioError_t SX126xGetDeviceErrors( void )
{
    uint8_t err[] = { 0, 0 };
    RadioError_t error = { .Value = 0 };

    SX126xReadCommand( RADIO_GET_ERROR, ( uint8_t* )err, 2 );
    error.Fields.PaRamp     = ( err[0] & ( 1 << 0 ) ) >> 0;
    error.Fields.PllLock    = ( err[1] & ( 1 << 6 ) ) >> 6;
    error.Fields.XoscStart  = ( err[1] & ( 1 << 5 ) ) >> 5;
    error.Fields.ImgCalib   = ( err[1] & ( 1 << 4 ) ) >> 4;
    error.Fields.AdcCalib   = ( err[1] & ( 1 << 3 ) ) >> 3;
    error.Fields.PllCalib   = ( err[1] & ( 1 << 2 ) ) >> 2;
    error.Fields.Rc13mCalib = ( err[1] & ( 1 << 1 ) ) >> 1;
    error.Fields.Rc64kCalib = ( err[1] & ( 1 << 0 ) ) >> 0;
    return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq -0xa(%rbp), %rbx
movw $0x0, (%rbx)
movl $0x17, %edi
movq %rbx, %rsi
movl $0x2, %edx
callq 0x4bc0
movzbl (%rbx), %ecx
andl $0x1, %ecx
shll $0x8, %ecx
movzbl 0x1(%rbx), %eax
movl %eax, %edx
andl $0x40, %edx
orl %ecx, %edx
movl %eax, %ecx
andl $0x20, %ecx
orl %edx, %ecx
movl %eax, %edx
andl $0x10, %edx
orl %ecx, %edx
movl %eax, %ecx
andl $0x8, %ecx
orl %edx, %ecx
movl %eax, %edx
andl $0x4, %edx
orl %ecx, %edx
andl $0x3, %eax
orl %edx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xIoInit
void SX126xIoInit( void )
{
    printf("SX126xIoInit\r\n");

    //  Init SPI Bus
    int rc = init_spi();
    assert(rc == 0);

    //  TODO: Init GPIO Pins
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x21cb(%rip), %rdi      # 0x6a96
callq 0x2260
leaq 0x219d(%rip), %rdi      # 0x6a74
movl $0x2, %esi
xorl %eax, %eax
callq 0x2100
movl %eax, 0x63d7(%rip)      # 0xacc0
testl %eax, %eax
jle 0x4929
leaq -0x2(%rbp), %rdx
movb $0x0, (%rdx)
movl $0x40016b01, %esi       # imm = 0x40016B01
movl %eax, %edi
xorl %eax, %eax
callq 0x21e0
testl %eax, %eax
jne 0x4948
leaq -0x1(%rbp), %rdx
movb $0x0, (%rdx)
movl 0x63ad(%rip), %edi      # 0xacc0
movl $0x40016b02, %esi       # imm = 0x40016B02
xorl %eax, %eax
callq 0x21e0
testl %eax, %eax
jne 0x4967
addq $0x10, %rsp
popq %rbp
retq
leaq 0x2031(%rip), %rdi      # 0x6961
leaq 0x1deb(%rip), %rsi      # 0x6722
leaq 0x2145(%rip), %rcx      # 0x6a83
movl $0x28f, %edx            # imm = 0x28F
callq 0x20f0
leaq 0x1dcb(%rip), %rdi      # 0x671a
leaq 0x1dcc(%rip), %rsi      # 0x6722
leaq 0x2126(%rip), %rcx      # 0x6a83
movl $0x294, %edx            # imm = 0x294
callq 0x20f0
leaq 0x1dac(%rip), %rdi      # 0x671a
leaq 0x1dad(%rip), %rsi      # 0x6722
leaq 0x2107(%rip), %rcx      # 0x6a83
movl $0x299, %edx            # imm = 0x299
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xWakeup
void SX126xWakeup( void )
{
    printf("SX126xWakeup\r\n");
    CRITICAL_SECTION_BEGIN( );

    // Write RADIO_GET_STATUS command followed by 0
    uint8_t commands[1] = { RADIO_GET_STATUS };
    uint8_t buffer[1]   = { 0 };
    int rc = sx126x_hal_write(NULL, commands, sizeof(commands), buffer, sizeof(buffer));
    assert(rc == 0);

    // Wait for chip to be ready.
    SX126xWaitOnBusy( );

    // Update operating mode context variable
    SX126xSetOperatingMode( MODE_STDBY_RC );

    CRITICAL_SECTION_END( );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x20da(%rip), %rdi      # 0x6afc
callq 0x2260
leaq 0x1e7a(%rip), %rdi      # 0x68a8
movl $0x1, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x2050
movw $0xc0, 0x5a78(%rip)     # 0xa4c0
movw $0x0, 0x5e6f(%rip)      # 0xa8c0
movl $0x2, %edi
callq 0x5132
leaq 0x2082(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
callq 0x21f0
movl $0x1, 0x5a35(%rip)      # 0xa4b0
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: sx126x_hal_write
static int sx126x_hal_write( 
    const void* context, const uint8_t* command, const uint16_t command_length,
    const uint8_t* data, const uint16_t data_length ) {
    printf("sx126x_hal_write: command_length=%d, data_length=%d\n", command_length, data_length);

    //  Total length is command + data length
    uint16_t len = command_length + data_length;
    assert(len > 0);
    assert(len <= SPI_BUFFER_SIZE);

    //  Clear the SPI Transmit and Receive buffers
    memset(&spi_tx_buf, 0, len);
    memset(&spi_rx_buf, 0, len);

    //  Copy command bytes to SPI Transmit Buffer
    memcpy(&spi_tx_buf, command, command_length);

    //  Copy data bytes to SPI Transmit Buffer
    memcpy(&spi_tx_buf[command_length], data, data_length);

    //  Transmit and receive the SPI buffers
    int rc = transfer_spi(spi_tx_buf, spi_rx_buf, len);
    assert(rc == 0);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r14d
movq %rdx, %r15
movl %esi, %r12d
movq %rdi, %rbx
leaq 0x1e0a(%rip), %rdi      # 0x68a8
movl %ecx, %edx
xorl %eax, %eax
callq 0x2050
movl %r14d, %eax
addw %r12w, %ax
je 0x4b21
movq %rbx, -0x30(%rbp)
movzwl %ax, %r13d
cmpl $0x401, %r13d           # imm = 0x401
jae 0x4b40
leaq 0x59f8(%rip), %rbx      # 0xa4c0
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x20d0
leaq 0x5de4(%rip), %rdi      # 0xa8c0
xorl %esi, %esi
movq %r13, %rdx
callq 0x20d0
movzwl %r12w, %r12d
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
movq %r12, %rdx
callq 0x2130
addq %r12, %rbx
movzwl %r14w, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2130
movl %r13d, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5132
leaq 0x1db5(%rip), %rdi      # 0x68dd
leaq 0x1bf3(%rip), %rsi      # 0x6722
leaq 0x1daf(%rip), %rcx      # 0x68e5
movl $0x228, %edx            # imm = 0x228
callq 0x20f0
leaq 0x1e03(%rip), %rdi      # 0x694a
leaq 0x1bd4(%rip), %rsi      # 0x6722
leaq 0x1d90(%rip), %rcx      # 0x68e5
movl $0x229, %edx            # imm = 0x229
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xWriteCommand
void SX126xWriteCommand( RadioCommands_t command, uint8_t *buffer, uint16_t size )
{
    SX126xCheckDeviceReady( );

    //  Write the command followed by buffer
    uint8_t commands[1] = { (uint8_t) command };
    int rc = sx126x_hal_write(NULL, commands, sizeof(commands), buffer, size);
    assert(rc == 0);

    if( command != RADIO_SET_SLEEP )
    {
        SX126xWaitOnBusy( );
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movl %edi, %r15d
callq 0x3bb2
leaq -0x19(%rbp), %rdi
movb %r15b, (%rdi)
movl $0x1, %esi
movq %r14, %rdx
movl %ebx, %ecx
callq 0x4a7d
cmpl $0x84, %r15d
jne 0x4ba0
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f3d(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x21f0
// File: /workspace/github_c_makefile_star2_O3/lupyuen[P]lora-sx1262/src/sx126x-linux.c
// Function: SX126xReadCommand
uint8_t SX126xReadCommand( RadioCommands_t command, uint8_t *buffer, uint16_t size )
{
    printf("SX126xReadCommand: command=0x%02x, size=%d\r\n", command, size);
    uint8_t status = 0;

    SX126xCheckDeviceReady( );

    //  Write the command, read the status and read the buffer
    uint8_t commandStatus[2] = { 
        (uint8_t) command,  //  Command
        0                   //  Status
    };
    int rc = sx126x_hal_read(NULL, commandStatus, sizeof(commandStatus), buffer, size, &status);
    assert(rc == 0);
    printf("status=0x%02x\n", status);

#ifdef NOTUSED  //  Previously...
    bl_gpio_output_set( SX126X_SPI_CS_PIN, 0 );
    if (SX126X_DEBUG_CS_PIN >= 0) { bl_gpio_output_set( SX126X_DEBUG_CS_PIN, 0 ); }

    SpiInOut( SX126X_SPI_IDX, ( uint8_t )command );
    status = SpiInOut( SX126X_SPI_IDX, 0x00 );
    for( uint16_t i = 0; i < size; i++ )
    {
        buffer[i] = SpiInOut( SX126X_SPI_IDX, 0 );
    }

    bl_gpio_output_set( SX126X_SPI_CS_PIN, 1 );
    if (SX126X_DEBUG_CS_PIN >= 0) { bl_gpio_output_set( SX126X_DEBUG_CS_PIN, 1 ); }
#endif  //  NOTUSED

    SX126xWaitOnBusy( );

    return status;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movl %edi, %r12d
leaq 0x1b57(%rip), %rdi      # 0x6735
xorl %r13d, %r13d
movl %r12d, %esi
xorl %eax, %eax
callq 0x2050
leaq -0x29(%rbp), %rbx
movb %r13b, (%rbx)
callq 0x3bb2
leaq -0x2b(%rbp), %rdi
movb %r12b, (%rdi)
movb %r13b, 0x1(%rdi)
movl $0x2, %esi
movq %r15, %rdx
movl %r14d, %ecx
movq %rbx, %r8
callq 0x4c4d
movzbl (%rbx), %esi
leaq 0x1b43(%rip), %rdi      # 0x6762
xorl %eax, %eax
callq 0x2050
leaq 0x1eb7(%rip), %rdi      # 0x6ae4
callq 0x2260
movl $0x2710, %edi           # imm = 0x2710
callq 0x21f0
movb (%rbx), %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq