// File: /workspace/github_cpp_makefile_star2_O3/gulamf[P]NRF24LE1Flash/main.cpp
// Function: CheckUC()
bool CheckUC()
{
    string s = port;
    BLCommandReturnType blCommandReturnVal;


    if (resetpin == blenabled)
    {
        cout << "Reset and bootloader enable pins cannot be the same!\n";
        return false;
    }

    //begin start bootloader
    blCommandReturnVal = ExecuteCommandStartBootloader();

    if (blCommandReturnVal == BLCommandReturnType_SerialPortFailure)
    {
        cout << "Error: Could not open COM port!\n";
        return false;
    }
    else if (blCommandReturnVal != BLCommandReturnType_OK)
    {
        cout << "Error: Device not connected!\n";
        return false;
    }
    //end start	bootloader

    //begin device id check
    uint16_t devId = 0;

    blCommandReturnVal = ExecuteCommandGetDevID(&devId);

    if (blCommandReturnVal != BLCommandReturnType_OK)
    {
        cout << "Lost communications with device!\n";
        return false;
    }
    //end device id check

    //begin bootloader version check
    unsigned char blVersion = 0;

    blCommandReturnVal = ExecuteCommandGetBLVersion(&blVersion);

    if (blCommandReturnVal != BLCommandReturnType_OK)
    {
        cout << "Lost communications with device!\n";
        return false;
    }
    //end device id check

    //begin exit bootloader only
    blCommandReturnVal = ExecuteCommandExitBootloader();

    if (blCommandReturnVal != BLCommandReturnType_OK)
    {
        cout<< "Lost communications with device!\n";
        return false;
    }
    //end exit bootloader

    //If we have made it this far, then everything went to plan, so update the microcontroller type and bootloader version textboxes
    cout << ConvertBLDevIDToString(devId);
    cout << "Device found!\n";

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
leaq -0x48(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x65ba(%rip), %rsi      # 0xa2f0
movq 0x65bb(%rip), %rdx      # 0xa2f8
addq %rsi, %rdx
leaq -0x58(%rbp), %rdi
callq 0x5d6c
movl 0x64ad(%rip), %eax      # 0xa1fc
cmpl 0x65bb(%rip), %eax      # 0xa310
jne 0x3d65
movl $0x35, %edx
leaq 0x3760(%rip), %rsi      # 0x74c3
jmp 0x3db9
callq 0x39b6
testl %eax, %eax
je 0x3d81
cmpl $0x3, %eax
jne 0x3dad
movl $0x20, %edx
leaq 0x377a(%rip), %rsi      # 0x74f9
jmp 0x3db9
leaq -0x12(%rbp), %rdi
movw $0x0, (%rdi)
callq 0x3a0b
testl %eax, %eax
je 0x3de7
movq 0x623e(%rip), %rdi      # 0x9fd8
leaq 0x3797(%rip), %rsi      # 0x7538
movl $0x21, %edx
callq 0x2270
jmp 0x3dc5
movl $0x1d, %edx
leaq 0x3761(%rip), %rsi      # 0x751a
movq 0x6218(%rip), %rdi      # 0x9fd8
callq 0x2270
xorl %ebx, %ebx
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x3ddc
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2220
movl %ebx, %eax
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq -0x13(%rbp), %rdi
movb $0x0, (%rdi)
callq 0x3a8c
testl %eax, %eax
jne 0x3e00
callq 0x3ae2
testl %eax, %eax
je 0x3e1a
movq 0x61d1(%rip), %rdi      # 0x9fd8
leaq 0x372a(%rip), %rsi      # 0x7538
movl $0x21, %edx
callq 0x2270
jmp 0x3dc5
movzwl -0x12(%rbp), %esi
leaq -0x38(%rbp), %rdi
callq 0x3b22
movq -0x38(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq 0x61a2(%rip), %rdi      # 0x9fd8
callq 0x2270
leaq -0x28(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3e54
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x2220
movb $0x1, %bl
movq 0x617b(%rip), %rdi      # 0x9fd8
leaq 0x36f6(%rip), %rsi      # 0x755a
movl $0xe, %edx
callq 0x2270
jmp 0x3dc7
movq %rax, %rbx
leaq -0x28(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3e9a
movq -0x28(%rbp), %rsi
incq %rsi
callq 0x2220
jmp 0x3e9a
jmp 0x3e97
jmp 0x3e97
jmp 0x3e97
movq %rax, %rbx
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x3eaf
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2220
movq %rbx, %rdi
callq 0x2380