// File: /workspace/github_cpp_makefile_star2_O3/gulamf[P]NRF24LE1Flash/main.cpp
// Function: ResetDevice()
void ResetDevice()
{
    //Enable the reset signal, which will put the chip in reset (the reset signal must be either RTS or DTR)
    if (resetpin == RTS)
    {

        RtsSet(progSerPort,true);
    }
    else if(resetpin = CTS)
    {
        CtsSet(progSerPort,true);
    }
    else
    {
        DtrSet(progSerPort,true);
    }

    //Wait 100 ms for the UART driver to have time to process any serial data the chip was sending prior to reset
    sleep_ms(100);

    //If the bootloader enable signal is enabled (set to RTS or DTR), then enable the signal here before we come out of reset
    if (blenabled == RTS)
    {
        RtsSet(progSerPort,true);
        sleep_ms(1);
    }
    else if (blenabled == DTR)
    {
        DtrSet(progSerPort,true);

        //Sleep for 1 ms to give the enable pin plenty of time to activate
        sleep_ms(1);
    }

    //Disable the reset signal, which returns the device to the normal state
    if (resetpin == RTS)
    {
        RtsSet(progSerPort,false);
    }
    else if(resetpin = CTS)
    {
        CtsSet(progSerPort,false);
    }
    else
    {
        DtrSet(progSerPort,false);
    }

    //Sleep for 1 ms to give the device time to power up
    sleep_ms(1);

    //If the bootloader enable signal is enabled (set to RTS or DTR), then disable the signal now that the device is powered up
    if (blenabled == RTS)
    {
        RtsSet(progSerPort,false);

        //Sleep for 1 ms to give the enable pin plenty of time to activate
        sleep_ms(1);
    }
    else if (blenabled == DTR)
    {
        DtrSet(progSerPort,false);

        //Sleep for 1 ms to give the enable pin plenty of time to activate
        sleep_ms(1);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
cmpl $0x2, 0x6aa8(%rip)      # 0xa1fc
jne 0x3768
movl 0x6bbc(%rip), %edi      # 0xa318
leaq -0x4(%rbp), %rdx
movl $0x4, (%rdx)
jmp 0x3782
movl $0x3, 0x6a8a(%rip)      # 0xa1fc
movl 0x6ba0(%rip), %edi      # 0xa318
leaq -0x4(%rbp), %rdx
movl $0x20, (%rdx)
movl $0x5416, %esi           # imm = 0x5416
xorl %eax, %eax
callq 0x22c0
movl $0x64, %edi
callq 0x6f82
movl 0x6b72(%rip), %eax      # 0xa310
cmpl $0x1, %eax
je 0x37ba
cmpl $0x2, %eax
jne 0x37e0
movl 0x6b6a(%rip), %edi      # 0xa318
leaq -0x4(%rbp), %rdx
movl $0x4, (%rdx)
jmp 0x37ca
movl 0x6b58(%rip), %edi      # 0xa318
leaq -0x4(%rbp), %rdx
movl $0x2, (%rdx)
movl $0x5416, %esi           # imm = 0x5416
xorl %eax, %eax
callq 0x22c0
movl $0x1, %edi
callq 0x6f82
cmpl $0x2, 0x6a15(%rip)      # 0xa1fc
jne 0x37fb
movl 0x6b29(%rip), %edi      # 0xa318
leaq -0x4(%rbp), %rdx
movl $0x4, (%rdx)
jmp 0x3815
movl $0x3, 0x69f7(%rip)      # 0xa1fc
movl 0x6b0d(%rip), %edi      # 0xa318
leaq -0x4(%rbp), %rdx
movl $0x20, (%rdx)
movl $0x5417, %esi           # imm = 0x5417
xorl %eax, %eax
callq 0x22c0
movl $0x1, %edi
callq 0x6f82
movl 0x6adf(%rip), %eax      # 0xa310
cmpl $0x1, %eax
je 0x384d
cmpl $0x2, %eax
jne 0x3873
movl 0x6ad7(%rip), %edi      # 0xa318
leaq -0x4(%rbp), %rdx
movl $0x4, (%rdx)
jmp 0x385d
movl 0x6ac5(%rip), %edi      # 0xa318
leaq -0x4(%rbp), %rdx
movl $0x2, (%rdx)
movl $0x5417, %esi           # imm = 0x5417
xorl %eax, %eax
callq 0x22c0
movl $0x1, %edi
callq 0x6f82
addq $0x10, %rsp
popq %rbp
retq