// File: 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
cmpl $0x2, 0x9629(%rip)      # 0xe2c4
jne 0x4caf
movl 0x9735(%rip), %edi      # 0xe3d8
movl $0x1, %esi
callq 0x4ba0
jmp 0x4ce5
movl $0x3, 0x960b(%rip)      # 0xe2c4
movb $0x1, %al
testb $0x1, %al
jne 0x4cc1
jmp 0x4cd3
movl 0x9711(%rip), %edi      # 0xe3d8
movl $0x1, %esi
callq 0x4c40
jmp 0x4ce3
movl 0x96ff(%rip), %edi      # 0xe3d8
movl $0x1, %esi
callq 0x4bf0
jmp 0x4ce5
movl $0x64, %edi
callq 0x9810
cmpl $0x2, 0x96da(%rip)      # 0xe3d0
jne 0x4d14
movl 0x96da(%rip), %edi      # 0xe3d8
movl $0x1, %esi
callq 0x4ba0
movl $0x1, %edi
callq 0x9810
jmp 0x4d39
cmpl $0x1, 0x96b5(%rip)      # 0xe3d0
jne 0x4d37
movl 0x96b5(%rip), %edi      # 0xe3d8
movl $0x1, %esi
callq 0x4bf0
movl $0x1, %edi
callq 0x9810
jmp 0x4d39
cmpl $0x2, 0x9584(%rip)      # 0xe2c4
jne 0x4d51
movl 0x9690(%rip), %edi      # 0xe3d8
xorl %esi, %esi
callq 0x4ba0
jmp 0x4d81
movl $0x3, 0x9569(%rip)      # 0xe2c4
movb $0x1, %al
testb $0x1, %al
jne 0x4d63
jmp 0x4d72
movl 0x966f(%rip), %edi      # 0xe3d8
xorl %esi, %esi
callq 0x4c40
jmp 0x4d7f
movl 0x9660(%rip), %edi      # 0xe3d8
xorl %esi, %esi
callq 0x4bf0
jmp 0x4d81
movl $0x1, %edi
callq 0x9810
cmpl $0x2, 0x963e(%rip)      # 0xe3d0
jne 0x4dad
movl 0x963e(%rip), %edi      # 0xe3d8
xorl %esi, %esi
callq 0x4ba0
movl $0x1, %edi
callq 0x9810
jmp 0x4dcf
cmpl $0x1, 0x961c(%rip)      # 0xe3d0
jne 0x4dcd
movl 0x961c(%rip), %edi      # 0xe3d8
xorl %esi, %esi
callq 0x4bf0
movl $0x1, %edi
callq 0x9810
jmp 0x4dcf
popq %rbp
retq
nopw %cs:(%rax,%rax)