// File: /workspace/github_cpp_makefile_star2_O3/gulamf[P]NRF24LE1Flash/main.cpp
// Function: OpenSerialPort(unsigned int)
bool OpenSerialPort(speed_t baudRate)
{
    string s = port;
    strreplace(s,"/dev/", "");
    string lockFileName = "/tmp/LCK.." + s;

    try
    {
        ifstream *lockFile = new ifstream(lockFileName.c_str());
    }
    catch (...)
    {
        cout << "Error: Lock file " + lockFileName + " exists!  It is likely that another serial terminal has this port open!\r\n";
        return false;
    }

    progSerPort = open(port.c_str(),O_RDWR | O_NOCTTY | O_SYNC );

    set_interface_attribs (progSerPort, B38400, 0);
    set_blocking (progSerPort, 0);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
leaq -0x78(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x6f04(%rip), %rsi      # 0xa2f0
movq 0x6f05(%rip), %rdx      # 0xa2f8
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x5d6c
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x4026(%rip), %rsi      # 0x7438
leaq 0x4024(%rip), %rdx      # 0x743d
leaq -0x68(%rbp), %rdi
callq 0x5e0a
leaq -0x38(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x4620(%rip), %rdx      # 0x7a51
leaq -0x48(%rbp), %rdi
movq %rdx, %rsi
callq 0x5e0a
leaq -0xc8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x6f1f
leaq -0xb8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3477
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x2220
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x348c
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2220
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x34a1
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2220
leaq 0x3f96(%rip), %rsi      # 0x743e
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x5b05
movl $0x208, %edi            # imm = 0x208
callq 0x2210
movq %rax, %rbx
movq -0x68(%rbp), %rsi
movq %rax, %rdi
movl $0x8, %edx
callq 0x23a0
movq 0x6e13(%rip), %rdi      # 0xa2f0
movl $0x101102, %esi         # imm = 0x101102
xorl %eax, %eax
callq 0x2190
movl %eax, 0x6e29(%rip)      # 0xa318
movl %eax, %edi
movl $0xf, %esi
xorl %edx, %edx
callq 0x3242
movb $0x1, %bl
movl 0x6e13(%rip), %edi      # 0xa318
xorl %esi, %esi
callq 0x3335
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x3521
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2220
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x3539
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x2220
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl $0x208, %esi            # imm = 0x208
movq %rbx, %rdi
callq 0x2220
jmp 0x3562
movq %rax, %r14
movq %r14, %rdi
callq 0x2100
leaq 0x3ed8(%rip), %rsi      # 0x7449
leaq -0xa8(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x5b05
leaq 0x3ed3(%rip), %rsi      # 0x745b
leaq -0xa8(%rbp), %rdi
callq 0x23b0
movq %r13, -0x48(%rbp)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x35b4
movq %rsi, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x35bf
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq %r13, %rsi
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x69fb(%rip), %rdi      # 0x9fd8
callq 0x2270
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x35f7
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2220
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3616
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x2220
callq 0x2340
xorl %ebx, %ebx
jmp 0x350c
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x363f
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2220
jmp 0x363f
movq %rax, %rbx
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3663
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x2220
jmp 0x3663
movq %rax, %rbx
callq 0x2340
jmp 0x3698
movq %rax, %rdi
callq 0x5b97
jmp 0x3690
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x3698
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2220
jmp 0x3698
jmp 0x3695
movq %rax, %rbx
jmp 0x36ad
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x36ad
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2220
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x36c5
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x2220
movq %rbx, %rdi
callq 0x2380