// File: /workspace/github_cpp_makefile_star2_O1/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, 0x7b1d(%rip)      # 0xb1fc
jne 0x36f3
movl 0x7c31(%rip), %edi      # 0xb318
leaq -0x4(%rbp), %rdx
movl $0x4, (%rdx)
jmp 0x370d
movl $0x3, 0x7aff(%rip)      # 0xb1fc
movl 0x7c15(%rip), %edi      # 0xb318
leaq -0x4(%rbp), %rdx
movl $0x20, (%rdx)
movl $0x5416, %esi           # imm = 0x5416
xorl %eax, %eax
callq 0x22c0
movl $0x64, %edi
callq 0x700a
movl 0x7be7(%rip), %eax      # 0xb310
cmpl $0x1, %eax
je 0x3745
cmpl $0x2, %eax
jne 0x376b
movl 0x7bdf(%rip), %edi      # 0xb318
leaq -0x4(%rbp), %rdx
movl $0x4, (%rdx)
jmp 0x3755
movl 0x7bcd(%rip), %edi      # 0xb318
leaq -0x4(%rbp), %rdx
movl $0x2, (%rdx)
movl $0x5416, %esi           # imm = 0x5416
xorl %eax, %eax
callq 0x22c0
movl $0x1, %edi
callq 0x700a
cmpl $0x2, 0x7a8a(%rip)      # 0xb1fc
jne 0x3786
movl 0x7b9e(%rip), %edi      # 0xb318
leaq -0x4(%rbp), %rdx
movl $0x4, (%rdx)
jmp 0x37a0
movl $0x3, 0x7a6c(%rip)      # 0xb1fc
movl 0x7b82(%rip), %edi      # 0xb318
leaq -0x4(%rbp), %rdx
movl $0x20, (%rdx)
movl $0x5417, %esi           # imm = 0x5417
xorl %eax, %eax
callq 0x22c0
movl $0x1, %edi
callq 0x700a
movl 0x7b54(%rip), %eax      # 0xb310
cmpl $0x1, %eax
je 0x37d8
cmpl $0x2, %eax
jne 0x37fe
movl 0x7b4c(%rip), %edi      # 0xb318
leaq -0x4(%rbp), %rdx
movl $0x4, (%rdx)
jmp 0x37e8
movl 0x7b3a(%rip), %edi      # 0xb318
leaq -0x4(%rbp), %rdx
movl $0x2, (%rdx)
movl $0x5417, %esi           # imm = 0x5417
xorl %eax, %eax
callq 0x22c0
movl $0x1, %edi
callq 0x700a
addq $0x10, %rsp
popq %rbp
retq