// File: /workspace/github_cpp_makefile_star2_O2/hzeller[P]gcode-cli/machine-connection.cc
// Function: MachineConnection::Open(char const*)
MachineConnection *MachineConnection::Open(const char *descriptor) {
    if (descriptor == nullptr) return nullptr;
    if (strcmp(descriptor, "-") == 0) {
        return new MachineConnection(STDOUT_FILENO, STDIN_FILENO);
    }
    if (const int fd = OpenTTY(descriptor); fd >= 0) {
        return new MachineConnection(fd, fd);
    }
    if (const int fd = OpenTCPSocket(descriptor); fd >= 0) {
        return new MachineConnection(fd, fd);
    }
    return nullptr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
testq %rdi, %rdi
je 0x3235
movq %rdi, %r12
cmpb $0x2d, (%rdi)
jne 0x2f4e
cmpb $0x0, 0x1(%r12)
je 0x31c8
movq %r12, %rdi
callq 0x2100
leaq 0x88(%rsp), %r15
movq %rax, (%r15)
movq %r12, 0x8(%r15)
xorl %r14d, %r14d
pushq $0x2c
popq %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x3468
movq %rax, %rbx
movq %r15, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0x34be
leaq 0x38(%rsp), %rsi
movq %rax, (%rsi)
movq %rdx, 0x8(%rsi)
leaq 0x68(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x34f4
cmpq $-0x1, %rbx
je 0x2fc4
incq %rbx
leaq 0x88(%rsp), %rdi
pushq $-0x1
popq %rdx
movq %rbx, %rsi
callq 0x34be
movq %rax, %r14
movq %rdx, %rbx
jmp 0x2fcb
leaq 0x1145(%rip), %rbx      # 0x4110
movq 0x68(%rsp), %rdi
movl $0x101102, %esi         # imm = 0x101102
xorl %eax, %eax
callq 0x2150
movl %eax, %r15d
pushq $-0x1
popq %rbp
testl %eax, %eax
js 0x31e7
movq %r14, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
leaq 0x38(%rsp), %rdx
movl $0x802c542a, %esi       # imm = 0x802C542A
movl %r15d, %edi
xorl %eax, %eax
callq 0x2280
testl %eax, %eax
jne 0x324c
movl %r15d, 0x30(%rsp)
movq %r12, 0x8(%rsp)
andl $0xffff7fb4, 0x44(%rsp) # imm = 0xFFFF7FB4
movabsq $-0x1000005ec, %rax     # imm = 0xFFFFFFFEFFFFFA14
andq %rax, 0x38(%rsp)
movw $0x101, 0x4e(%rsp)      # imm = 0x101
movl $0x6ff0e600, %eax       # imm = 0x6FF0E600
andl 0x40(%rsp), %eax
orl $0x900018b0, %eax       # imm = 0x900018B0
movl %eax, 0x40(%rsp)
movabsq $0x1c2000001c200, %rax  # imm = 0x1C2000001C200
movq %rax, 0x5c(%rsp)
leaq 0x20(%rsp), %r15
pushq $0x2c
popq %r12
leaq 0x1a41(%rip), %r13      # 0x4aaa
pushq $0x7
popq %rbp
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
testq %r14, %r14
je 0x3186
movq %r15, %rdi
movl %r12d, %esi
xorl %edx, %edx
callq 0x3468
movq %rax, %r14
incq %r14
jne 0x3094
movq 0x20(%rsp), %r14
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0x34be
addq %r14, 0x28(%rsp)
subq %r14, 0x20(%rsp)
movq %rax, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
movzbl (%rdx), %ecx
cmpl $0x2b, %ecx
je 0x312e
cmpl $0x2d, %ecx
je 0x3119
cmpl $0x62, %ecx
je 0x30d0
cmpl $0x42, %ecx
jne 0x3150
leaq 0x1(%rdx), %rdi
addq %rdx, %rax
movq %rax, %rsi
leaq 0x34(%rsp), %rdx
pushq $0xa
popq %rcx
callq 0x3545
testl %edx, %edx
jne 0x317c
movl 0x34(%rsp), %edx
testl %edx, %edx
js 0x3280
movl %edx, 0x60(%rsp)
movl 0x40(%rsp), %eax
movl $0xeff0eff0, %ecx       # imm = 0xEFF0EFF0
andl %ecx, %eax
orl $0x10001000, %eax       # imm = 0x10001000
movl %eax, 0x40(%rsp)
movl %edx, 0x5c(%rsp)
jmp 0x317c
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
pushq $-0x1
popq %rdx
callq 0x34be
xorl %r14d, %r14d
jmp 0x3144
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
pushq $-0x1
popq %rdx
callq 0x34be
movl $0x80000000, %r14d      # imm = 0x80000000
movq %rax, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
jmp 0x3156
movl $0x80000000, %r14d      # imm = 0x80000000
movq %rax, %rdi
movq %rdx, %rsi
movq %rbp, %rdx
movq %r13, %rcx
callq 0x3620
testb %al, %al
je 0x325a
movl 0x40(%rsp), %eax
andl %ebx, %eax
orl %r14d, %eax
movl %eax, 0x40(%rsp)
movq 0x20(%rsp), %r14
jmp 0x3071
leaq 0x38(%rsp), %rdx
movl $0x402c542b, %esi       # imm = 0x402C542B
movl 0x30(%rsp), %ebp
movl %ebp, %edi
xorl %eax, %eax
callq 0x2280
testl %eax, %eax
je 0x31e2
callq 0x2040
movl (%rax), %edi
callq 0x20b0
leaq 0x1913(%rip), %rdi      # 0x4ac7
movq %rax, %rsi
xorl %eax, %eax
callq 0x2050
movq 0x8(%rsp), %r12
pushq $-0x1
popq %rbp
jmp 0x31e7
pushq $0x48
popq %rdi
callq 0x21b0
movq %rax, %rbx
pushq $0x1
popq %rsi
movq %rax, %rdi
xorl %edx, %edx
callq 0x2ee6
jmp 0x3237
movq 0x8(%rsp), %r12
leaq 0x68(%rsp), %rdi
callq 0x2120
testl %ebp, %ebp
js 0x320e
pushq $0x48
popq %rdi
callq 0x21b0
movq %rax, %rbx
movq %rax, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x2ee6
jmp 0x3237
movq %r12, %rdi
callq 0x2dc3
testl %eax, %eax
js 0x3235
movl %eax, %ebp
pushq $0x48
popq %rdi
callq 0x21b0
movq %rax, %rbx
movq %rax, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x2ee6
jmp 0x3237
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1830(%rip), %rdi      # 0x4a83
callq 0x2190
jmp 0x31e7
movq 0x3d77(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movl 0x10(%rsp), %edx
movq 0x18(%rsp), %rcx
leaq 0x183e(%rip), %rsi      # 0x4ab2
xorl %eax, %eax
callq 0x2290
jmp 0x31be
movq 0x3d51(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
leaq 0x1851(%rip), %rsi      # 0x4ae2
xorl %eax, %eax
callq 0x2290
jmp 0x31be
jmp 0x32a1
jmp 0x32a1
movq %rax, %r14
pushq $0x48
popq %rsi
movq %rbx, %rdi
callq 0x21c0
jmp 0x32c2
jmp 0x32b5
jmp 0x32b5
movq %rax, %r14
leaq 0x68(%rsp), %rdi
callq 0x2120
movq %r14, %rdi
callq 0x2300