// File: /workspace/github_cpp_makefile_star2_O3/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 $0x58, %rsp
testq %rdi, %rdi
je 0x338d
movq %rdi, %rbx
cmpb $0x2d, (%rdi)
jne 0x3095
cmpb $0x0, 0x1(%rbx)
je 0x32e4
movq %rbx, %rdi
callq 0x2100
movq %rax, %rbp
testq %rax, %rax
je 0x30ca
movq %rbx, %rdi
movl $0x2c, %esi
movq %rbp, %rdx
callq 0x21b0
movq %rax, %rcx
subq %rbx, %rcx
xorl %r14d, %r14d
cmpq $0x1, %rax
sbbq %r14, %r14
orq %rcx, %r14
jmp 0x30d1
movq $-0x1, %r14
cmpq %r14, %rbp
movq %r14, %rdx
cmovbq %rbp, %rdx
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
addq %rbx, %rdx
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2e6e
cmpq $-0x1, %r14
je 0x3110
leaq 0x1(%r14), %r15
cmpq %rbp, %r14
jae 0x33ef
subq %r15, %rbp
addq %rbx, %r15
jmp 0x3119
leaq 0xff9(%rip), %r15       # 0x4110
xorl %ebp, %ebp
movq 0x8(%rsp), %rdi
movl $0x101102, %esi         # imm = 0x101102
xorl %eax, %eax
callq 0x2130
movl %eax, %r13d
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x3314
leaq 0x28(%rsp), %rdx
movl $0x802c542a, %esi       # imm = 0x802C542A
movl %r13d, %edi
xorl %eax, %eax
callq 0x2260
testl %eax, %eax
jne 0x33a1
movl %r13d, (%rsp)
andl $0xffff7fb4, 0x34(%rsp) # imm = 0xFFFF7FB4
movabsq $-0x1000005ec, %rax     # imm = 0xFFFFFFFEFFFFFA14
andq %rax, 0x28(%rsp)
movw $0x101, 0x3e(%rsp)      # imm = 0x101
movl $0x6ff0e600, %eax       # imm = 0x6FF0E600
andl 0x30(%rsp), %eax
orl $0x900018b0, %eax       # imm = 0x900018B0
movl %eax, 0x30(%rsp)
movabsq $0x1c2000001c200, %rax  # imm = 0x1C2000001C200
movq %rax, 0x4c(%rsp)
testq %rbp, %rbp
je 0x329e
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
movq %rbp, %r14
movq %r15, %rdi
movl $0x2c, %esi
movq %rbp, %rdx
callq 0x21b0
movq %rax, %rcx
subq %r15, %rcx
cmpq $0x1, %rax
movl $0x0, %r12d
sbbq %r12, %r12
orq %rcx, %r12
incq %r12
cmoveq %rbp, %r12
subq %r12, %rbp
cmovaeq %r12, %r14
movzbl (%r15), %ecx
movl $0x80000000, %eax       # imm = 0x80000000
cmpl $0x41, %ecx
jg 0x3203
cmpl $0x2b, %ecx
je 0x3259
cmpl $0x2d, %ecx
jne 0x3254
decq %r14
leaq 0x1(%r15), %rcx
xorl %eax, %eax
jmp 0x3260
cmpl $0x62, %ecx
je 0x320d
cmpl $0x42, %ecx
jne 0x3254
leaq 0x1(%r15), %rdi
addq %r15, %r14
movq %r14, %rsi
leaq 0x4(%rsp), %rdx
movl $0xa, %ecx
callq 0x363e
testl %edx, %edx
jne 0x3292
movl 0x4(%rsp), %edx
testl %edx, %edx
js 0x33d2
movl %edx, 0x50(%rsp)
movl 0x30(%rsp), %eax
movl $0xeff0eff0, %ecx       # imm = 0xEFF0EFF0
andl %ecx, %eax
orl $0x10001000, %eax       # imm = 0x10001000
movl %eax, 0x30(%rsp)
movl %edx, 0x4c(%rsp)
jmp 0x3292
movq %r15, %rcx
jmp 0x3260
decq %r14
leaq 0x1(%r15), %rcx
cmpq $0x7, %r14
jne 0x33b2
movl (%rcx), %edx
movl $0x73747263, %esi       # imm = 0x73747263
xorl %esi, %edx
movl 0x3(%rcx), %esi
movl $0x73746373, %edi       # imm = 0x73746373
xorl %edi, %esi
orl %edx, %esi
jne 0x33b2
movl 0x30(%rsp), %ecx
andl %r13d, %ecx
orl %eax, %ecx
movl %ecx, 0x30(%rsp)
addq %r12, %r15
testq %rbp, %rbp
jne 0x31a9
leaq 0x28(%rsp), %rdx
movl $0x402c542b, %esi       # imm = 0x402C542B
movl (%rsp), %r14d
movl %r14d, %edi
xorl %eax, %eax
callq 0x2260
testl %eax, %eax
je 0x330f
callq 0x2040
movl (%rax), %edi
callq 0x20b0
leaq 0x17fa(%rip), %rdi      # 0x4ac7
movq %rax, %rsi
xorl %eax, %eax
callq 0x2050
leaq 0x18(%rsp), %r12
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x3314
movl $0x48, %edi
callq 0x2190
movq %rax, %rbx
movq $0x1, (%rax)
leaq 0x8(%rax), %rdi
movl $0x10000, %edx          # imm = 0x10000
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x38cc
jmp 0x338f
leaq 0x18(%rsp), %r12
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x332b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21a0
testl %r14d, %r14d
js 0x3359
movl $0x48, %edi
callq 0x2190
movq %rax, %rbx
movl %r14d, (%rax)
movl %r14d, 0x4(%rax)
leaq 0x8(%rax), %rdi
movl $0x10000, %edx          # imm = 0x10000
movl %r14d, %esi
xorl %ecx, %ecx
callq 0x38cc
jmp 0x338f
movq %rbx, %rdi
callq 0x2f07
testl %eax, %eax
js 0x338d
movl %eax, %ebp
movl $0x48, %edi
callq 0x2190
movq %rax, %rbx
movl %ebp, (%rax)
movl %ebp, 0x4(%rax)
leaq 0x8(%rax), %rdi
movl $0x10000, %edx          # imm = 0x10000
movl %ebp, %esi
xorl %ecx, %ecx
callq 0x38cc
jmp 0x338f
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x16db(%rip), %rdi      # 0x4a83
callq 0x2170
jmp 0x3314
movq 0x3c1f(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
leaq 0x16ef(%rip), %rsi      # 0x4ab2
movl %r14d, %edx
xorl %eax, %eax
callq 0x2270
jmp 0x32d7
movq 0x3bff(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
leaq 0x16ff(%rip), %rsi      # 0x4ae2
xorl %eax, %eax
callq 0x2270
jmp 0x32d7
leaq 0x165c(%rip), %rdi      # 0x4a52
leaq 0x163b(%rip), %rsi      # 0x4a38
movq %r15, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0x2290
jmp 0x340e
jmp 0x340e
movq %rax, %r14
movl $0x48, %esi
movq %rbx, %rdi
jmp 0x3439
jmp 0x341f
jmp 0x341f
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x343e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %r14, %rdi
callq 0x22e0