// File: /workspace/github_c_makefile_star2_O0/lupyuen[P]lora-sx1262/src/radio.c
// Function: RadioIrqProcess
void RadioIrqProcess( void )
{
    printf("RadioIrqProcess\r\n");
    CRITICAL_SECTION_BEGIN( );
    // Clear IRQ flag
    const bool isIrqFired = IrqFired;
    IrqFired = false;
    CRITICAL_SECTION_END( );

    if( isIrqFired == true )
    {
        uint16_t irqRegs = SX126xGetIrqStatus( );
        SX126xClearIrqStatus( irqRegs );

        // Check if DIO1 pin is High. If it is the case revert IrqFired to true
        CRITICAL_SECTION_BEGIN( );
        if( SX126xGetDio1PinState( ) == 1 )
        {
            IrqFired = true;
        }
        CRITICAL_SECTION_END( );

        if( ( irqRegs & IRQ_TX_DONE ) == IRQ_TX_DONE )
        {
            printf("IRQ_TX_DONE\r\n");
            TimerStop( &TxTimeoutTimer );
            //!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
            SX126xSetOperatingMode( MODE_STDBY_RC );
            if( ( RadioEvents.TxDone != NULL ) )
            {
                RadioEvents.TxDone( );
            }
        }

        if( ( irqRegs & IRQ_RX_DONE ) == IRQ_RX_DONE )
        {
            printf("IRQ_RX_DONE\r\n");
            TimerStop( &RxTimeoutTimer );

            if( ( irqRegs & IRQ_CRC_ERROR ) == IRQ_CRC_ERROR )
            {
                if( RxContinuous == false )
                {
                    //!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
                    SX126xSetOperatingMode( MODE_STDBY_RC );
                }
                if( ( RadioEvents.RxError ) )
                {
                    RadioEvents.RxError( );
                }
            }
            else
            {
                uint8_t size;

                if( RxContinuous == false )
                {
                    //!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
                    SX126xSetOperatingMode( MODE_STDBY_RC );

                    // WORKAROUND - Implicit Header Mode Timeout Behavior, see DS_SX1261-2_V1.2 datasheet chapter 15.3
                    SX126xWriteRegister( REG_RTC_CTRL, 0x00 );
                    SX126xWriteRegister( REG_EVT_CLR, SX126xReadRegister( REG_EVT_CLR ) | ( 1 << 1 ) );
                    // WORKAROUND END
                }
                SX126xGetPayload( RadioRxPayload, &size , 255 );
                SX126xGetPacketStatus( &RadioPktStatus );
                if( ( RadioEvents.RxDone != NULL ) )
                {
                    RadioEvents.RxDone( RadioRxPayload, size, RadioPktStatus.Params.LoRa.RssiPkt, RadioPktStatus.Params.LoRa.SnrPkt );
                }
            }
        }

        if( ( irqRegs & IRQ_CAD_DONE ) == IRQ_CAD_DONE )
        {
            printf("IRQ_CAD_DONE\r\n");
            //!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
            SX126xSetOperatingMode( MODE_STDBY_RC );
            if( ( RadioEvents.CadDone != NULL ) )
            {
                RadioEvents.CadDone( ( ( irqRegs & IRQ_CAD_ACTIVITY_DETECTED ) == IRQ_CAD_ACTIVITY_DETECTED ) );
            }
        }

        if( ( irqRegs & IRQ_RX_TX_TIMEOUT ) == IRQ_RX_TX_TIMEOUT )
        {
            printf("IRQ_RX_TX_TIMEOUT\r\n");
            if( SX126xGetOperatingMode( ) == MODE_TX )
            {
                TimerStop( &TxTimeoutTimer );
                //!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
                SX126xSetOperatingMode( MODE_STDBY_RC );
                if( ( RadioEvents.TxTimeout != NULL ) )
                {
                    RadioEvents.TxTimeout( );
                }
            }
            else if( SX126xGetOperatingMode( ) == MODE_RX )
            {
                TimerStop( &RxTimeoutTimer );
                //!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
                SX126xSetOperatingMode( MODE_STDBY_RC );
                if( ( RadioEvents.RxTimeout != NULL ) )
                {
                    RadioEvents.RxTimeout( );
                }
            }
        }

        if( ( irqRegs & IRQ_PREAMBLE_DETECTED ) == IRQ_PREAMBLE_DETECTED )
        {
            printf("IRQ_PREAMBLE_DETECTED\r\n");
            //__NOP( );
        }

        if( ( irqRegs & IRQ_SYNCWORD_VALID ) == IRQ_SYNCWORD_VALID )
        {
            printf("IRQ_SYNCWORD_VALID\r\n");
            //__NOP( );
        }

        if( ( irqRegs & IRQ_HEADER_VALID ) == IRQ_HEADER_VALID )
        {
            printf("IRQ_HEADER_VALID\r\n");
            //__NOP( );
        }

        if( ( irqRegs & IRQ_HEADER_ERROR ) == IRQ_HEADER_ERROR )
        {
            printf("IRQ_HEADER_ERROR\r\n");
            TimerStop( &RxTimeoutTimer );
            if( RxContinuous == false )
            {
                //!< Update operating mode state to a value lower than \ref MODE_STDBY_XOSC
                SX126xSetOperatingMode( MODE_STDBY_RC );
            }
            if( ( RadioEvents.RxTimeout != NULL ) )
            {
                RadioEvents.RxTimeout( );
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq 0x496a(%rip), %rdi      # 0x9599
movb $0x0, %al
callq 0x2050
movb 0x962d(%rip), %al       # 0xe269
andb $0x1, %al
movb %al, -0x1(%rbp)
movb $0x0, 0x9621(%rip)      # 0xe269
movb -0x1(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x4f3e
callq 0x5ef0
movw %ax, -0x4(%rbp)
movzwl -0x4(%rbp), %edi
callq 0x6920
callq 0x7470
cmpl $0x1, %eax
jne 0x4c7c
movb $0x1, 0x95ed(%rip)      # 0xe269
movzwl -0x4(%rbp), %eax
andl $0x1, %eax
cmpl $0x1, %eax
jne 0x4cbe
leaq 0x491c(%rip), %rdi      # 0x95ab
movb $0x0, %al
callq 0x2050
leaq 0x961b(%rip), %rdi      # 0xe2b8
callq 0x7520
movl $0x1, %edi
callq 0x6b30
cmpq $0x0, 0x95bc(%rip)      # 0xe270
je 0x4cbc
callq *0x95b4(%rip)           # 0xe270
jmp 0x4cbe
movzwl -0x4(%rbp), %eax
andl $0x2, %eax
cmpl $0x2, %eax
jne 0x4dc0
leaq 0x48e4(%rip), %rdi      # 0x95b9
movb $0x0, %al
callq 0x2050
leaq 0x960d(%rip), %rdi      # 0xe2f0
callq 0x7520
movzwl -0x4(%rbp), %eax
andl $0x40, %eax
cmpl $0x40, %eax
jne 0x4d23
movb 0x956e(%rip), %al       # 0xe268
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4d0e
movl $0x1, %edi
callq 0x6b30
cmpq $0x0, 0x957a(%rip)      # 0xe290
je 0x4d1e
callq *0x9572(%rip)           # 0xe290
jmp 0x4dbe
movb 0x953f(%rip), %al       # 0xe268
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4d66
movl $0x1, %edi
callq 0x6b30
movl $0x902, %edi            # imm = 0x902
xorl %esi, %esi
callq 0x70f0
movl $0x944, %edi            # imm = 0x944
callq 0x7210
movzbl %al, %eax
orl $0x2, %eax
movl $0x944, %edi            # imm = 0x944
movzbl %al, %esi
callq 0x70f0
leaq 0x9643(%rip), %rdi      # 0xe3b0
leaq -0x5(%rbp), %rsi
movl $0xff, %edx
callq 0x55a0
leaq 0x972e(%rip), %rdi      # 0xe4b0
callq 0x6660
cmpq $0x0, 0x94f1(%rip)      # 0xe280
je 0x4dbc
movq 0x94e8(%rip), %rax      # 0xe280
movzbl -0x5(%rbp), %ecx
movw %cx, %dx
movsbl 0x9716(%rip), %ecx      # 0xe4bc
leaq 0x9603(%rip), %rdi      # 0xe3b0
movzwl %dx, %esi
movswl %cx, %edx
movsbl 0x9703(%rip), %ecx      # 0xe4bd
callq *%rax
jmp 0x4dbe
jmp 0x4dc0
movzwl -0x4(%rbp), %eax
andl $0x80, %eax
cmpl $0x80, %eax
jne 0x4e16
leaq 0x47f0(%rip), %rdi      # 0x95c7
movb $0x0, %al
callq 0x2050
movl $0x1, %edi
callq 0x6b30
cmpq $0x0, 0x94b0(%rip)      # 0xe2a0
je 0x4e14
movq 0x94a7(%rip), %rax      # 0xe2a0
movzwl -0x4(%rbp), %ecx
andl $0x100, %ecx            # imm = 0x100
cmpl $0x100, %ecx            # imm = 0x100
sete %cl
movzbl %cl, %edi
andl $0x1, %edi
callq *%rax
jmp 0x4e16
movzwl -0x4(%rbp), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x200, %eax            # imm = 0x200
jne 0x4e9c
leaq 0x47a9(%rip), %rdi      # 0x95d6
movb $0x0, %al
callq 0x2050
callq 0x6b20
cmpl $0x4, %eax
jne 0x4e66
leaq 0x9473(%rip), %rdi      # 0xe2b8
callq 0x7520
movl $0x1, %edi
callq 0x6b30
cmpq $0x0, 0x941c(%rip)      # 0xe278
je 0x4e64
callq *0x9414(%rip)           # 0xe278
jmp 0x4e9a
callq 0x6b20
cmpl $0x5, %eax
jne 0x4e98
leaq 0x9479(%rip), %rdi      # 0xe2f0
callq 0x7520
movl $0x1, %edi
callq 0x6b30
cmpq $0x0, 0x93fa(%rip)      # 0xe288
je 0x4e96
callq *0x93f2(%rip)           # 0xe288
jmp 0x4e98
jmp 0x4e9a
jmp 0x4e9c
movzwl -0x4(%rbp), %eax
andl $0x4, %eax
cmpl $0x4, %eax
jne 0x4eb6
leaq 0x473b(%rip), %rdi      # 0x95ea
movb $0x0, %al
callq 0x2050
movzwl -0x4(%rbp), %eax
andl $0x8, %eax
cmpl $0x8, %eax
jne 0x4ed0
leaq 0x4739(%rip), %rdi      # 0x9602
movb $0x0, %al
callq 0x2050
movzwl -0x4(%rbp), %eax
andl $0x10, %eax
cmpl $0x10, %eax
jne 0x4eea
leaq 0x4734(%rip), %rdi      # 0x9617
movb $0x0, %al
callq 0x2050
movzwl -0x4(%rbp), %eax
andl $0x20, %eax
cmpl $0x20, %eax
jne 0x4f3c
leaq 0x472d(%rip), %rdi      # 0x962a
movb $0x0, %al
callq 0x2050
leaq 0x93e5(%rip), %rdi      # 0xe2f0
callq 0x7520
movb 0x9352(%rip), %al       # 0xe268
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x4f2a
movl $0x1, %edi
callq 0x6b30
cmpq $0x0, 0x9356(%rip)      # 0xe288
je 0x4f3a
callq *0x934e(%rip)           # 0xe288
jmp 0x4f3c
jmp 0x4f3e
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)