// File: /workspace/github_cpp_makefile_star2_O1/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 0x7f7e(%rip), %rsi      # 0xb2f0
movq 0x7f7f(%rip), %rdx      # 0xb2f8
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x5dd2
leaq -0x58(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x50b5(%rip), %rsi      # 0x844d
leaq 0x50b3(%rip), %rdx      # 0x8452
leaq -0x68(%rbp), %rdi
callq 0x5e6c
leaq -0x38(%rbp), %r13
movq %r13, -0x10(%r13)
leaq 0x56af(%rip), %rdx      # 0x8a66
leaq -0x48(%rbp), %rdi
movq %rdx, %rsi
callq 0x5e6c
leaq -0xc8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x6fa7
leaq -0xb8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x33fd
movq -0xb8(%rbp), %rsi
incq %rsi
callq 0x2220
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x3412
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2220
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x3427
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2220
leaq 0x5025(%rip), %rsi      # 0x8453
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rdx
callq 0x5b6b
movl $0x208, %edi            # imm = 0x208
callq 0x2210
movq %rax, %rbx
movq -0x68(%rbp), %rsi
movq %rax, %rdi
movl $0x8, %edx
callq 0x23a0
movq 0x7e8d(%rip), %rdi      # 0xb2f0
movl $0x101102, %esi         # imm = 0x101102
xorl %eax, %eax
callq 0x2190
movl %eax, 0x7ea3(%rip)      # 0xb318
movl %eax, %edi
movl $0xf, %esi
xorl %edx, %edx
callq 0x31cb
movb $0x1, %bl
movl 0x7e8d(%rip), %edi      # 0xb318
xorl %esi, %esi
callq 0x32bb
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x34a7
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2220
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x34bf
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 0x34e8
movq %rax, %r14
movq %r14, %rdi
callq 0x2100
leaq 0x4f67(%rip), %rsi      # 0x845e
leaq -0xa8(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x5b6b
leaq 0x4f62(%rip), %rsi      # 0x8470
leaq -0xa8(%rbp), %rdi
callq 0x23b0
movq %r13, -0x48(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x353a
movq %rdx, -0x48(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x38(%rbp)
jmp 0x3542
movups (%rcx), %xmm0
movups %xmm0, (%r13)
movq 0x8(%rax), %rdx
movq %rdx, -0x40(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq 0x7a70(%rip), %rdi      # 0xafd8
callq 0x2270
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x3582
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2220
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x35a1
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x2220
callq 0x2340
xorl %ebx, %ebx
jmp 0x3492
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x35ca
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2220
jmp 0x35ca
movq %rax, %rbx
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x35ee
movq -0x98(%rbp), %rsi
incq %rsi
callq 0x2220
jmp 0x35ee
movq %rax, %rbx
callq 0x2340
jmp 0x3623
movq %rax, %rdi
callq 0x5bfd
jmp 0x361b
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r13, %rdi
je 0x3623
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2220
jmp 0x3623
jmp 0x3620
movq %rax, %rbx
jmp 0x3638
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r12, %rdi
je 0x3638
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x2220
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x3650
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x2220
movq %rbx, %rdi
callq 0x2380