// File: /workspace/github_cpp_makefile_star2_O1/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 $0x68, %rsp
testq %rdi, %rdi
je 0x33d3
movq %rdi, %r12
leaq 0xfec(%rip), %rsi       # 0x4071
callq 0x2260
testl %eax, %eax
je 0x30c2
movq %r12, %rdi
callq 0x2100
movq %rax, %r13
testq %rax, %rax
je 0x30ed
movq %r12, %rdi
movl $0x2c, %esi
movq %r13, %rdx
callq 0x21c0
movq %rax, %rcx
subq %r12, %rcx
xorl %ebx, %ebx
cmpq $0x1, %rax
sbbq %rbx, %rbx
orq %rcx, %rbx
jmp 0x30f4
movl $0x48, %edi
callq 0x2190
movq %rax, %r14
movq $0x1, (%rax)
leaq 0x8(%rax), %rdi
movl $0x10000, %edx          # imm = 0x10000
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x393c
jmp 0x33d6
movq $-0x1, %rbx
cmpq %rbx, %r13
movq %rbx, %rdx
cmovbq %r13, %rdx
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
addq %r12, %rdx
leaq 0x48(%rsp), %rdi
movq %r12, %rsi
callq 0x2e6a
cmpq $-0x1, %rbx
je 0x3132
leaq 0x1(%rbx), %r15
cmpq %r13, %rbx
jae 0x340d
subq %r15, %r13
addq %r12, %r15
jmp 0x313c
leaq 0xfd7(%rip), %r15       # 0x4110
xorl %r13d, %r13d
movq 0x48(%rsp), %rdi
movl $0x101102, %esi         # imm = 0x101102
xorl %eax, %eax
callq 0x2130
movl %eax, %ebx
testl %eax, %eax
js 0x3355
leaq 0x1c(%rsp), %rdx
movl $0x802c542a, %esi       # imm = 0x802C542A
movl %ebx, %edi
xorl %eax, %eax
callq 0x2270
testl %eax, %eax
jne 0x33fc
movl %ebx, 0x8(%rsp)
movq %r12, 0x10(%rsp)
andl $0xfffffa14, 0x1c(%rsp) # imm = 0xFFFFFA14
andl $0xffff7fb4, 0x28(%rsp) # imm = 0xFFFF7FB4
andb $-0x2, 0x20(%rsp)
movw $0x101, 0x32(%rsp)      # imm = 0x101
movl $0x800018b0, %eax       # imm = 0x800018B0
orl 0x24(%rsp), %eax
andl $0xeff0feb0, %eax       # imm = 0xEFF0FEB0
orl $0x10000000, %eax       # imm = 0x10000000
movl %eax, 0x24(%rsp)
movabsq $0x1c2000001c200, %rax  # imm = 0x1C2000001C200
movq %rax, 0x40(%rsp)
testq %r13, %r13
je 0x3313
movq %r13, %r14
movq %r15, %rdi
movl $0x2c, %esi
movq %r13, %rdx
callq 0x21c0
movq %rax, %rcx
subq %r15, %rcx
cmpq $0x1, %rax
movl $0x0, %ebp
sbbq %rbp, %rbp
orq %rcx, %rbp
incq %rbp
cmoveq %r13, %rbp
subq %rbp, %r13
cmovaeq %rbp, %r14
movzbl (%r15), %eax
movl $0x80000000, %ebx       # imm = 0x80000000
cmpl $0x41, %eax
jg 0x321f
cmpl $0x2b, %eax
je 0x3288
cmpl $0x2d, %eax
jne 0x3283
decq %r14
leaq 0x1(%r15), %r12
xorl %ebx, %ebx
jmp 0x328f
cmpl $0x62, %eax
je 0x3229
cmpl $0x42, %eax
jne 0x3283
leaq 0x1(%r15), %rdi
addq %r15, %r14
movq %r14, %rsi
leaq 0xc(%rsp), %rdx
movl $0xa, %ecx
callq 0x3679
testl %edx, %edx
jne 0x327c
movl 0xc(%rsp), %r14d
testl %r14d, %r14d
js 0x32f3
movl 0x24(%rsp), %eax
movl $0x1000, %ecx           # imm = 0x1000
orl %ecx, %eax
movl %r14d, 0x44(%rsp)
andl $0xeff0fff0, %eax       # imm = 0xEFF0FFF0
orl $0x10000000, %eax       # imm = 0x10000000
movl %eax, 0x24(%rsp)
movl %r14d, 0x40(%rsp)
testl %r14d, %r14d
js 0x32ec
movl $0x2, %eax
jmp 0x32be
movq %r15, %r12
jmp 0x328f
decq %r14
leaq 0x1(%r15), %r12
cmpq $0x7, %r14
jne 0x32ce
movq %r12, %rdi
leaq 0x180b(%rip), %rsi      # 0x4aaa
movq %r14, %rdx
callq 0x21b0
testl %eax, %eax
jne 0x32ce
movl 0x24(%rsp), %eax
movl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl %ecx, %eax
orl %ebx, %eax
movl %eax, 0x24(%rsp)
xorl %eax, %eax
testb $0x1, %al
jne 0x33e8
addq %rbp, %r15
jmp 0x31bd
movq 0x3d03(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
leaq 0x17d3(%rip), %rsi      # 0x4ab2
movl %r14d, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x2280
movl $0x1, %eax
jmp 0x32be
movq 0x3cde(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
leaq 0x17de(%rip), %rsi      # 0x4ae2
movl %r14d, %edx
xorl %eax, %eax
callq 0x2280
jmp 0x3277
leaq 0x1c(%rsp), %rdx
movl $0x402c542b, %esi       # imm = 0x402C542B
movl 0x8(%rsp), %ebx
movl %ebx, %edi
xorl %eax, %eax
callq 0x2270
testl %eax, %eax
movq 0x10(%rsp), %r12
leaq 0x58(%rsp), %r14
je 0x335a
callq 0x2040
movl (%rax), %edi
callq 0x20b0
leaq 0x177c(%rip), %rdi      # 0x4ac7
movq %rax, %rsi
xorl %eax, %eax
callq 0x2050
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x3371
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21a0
testl %ebx, %ebx
js 0x339b
movl $0x48, %edi
callq 0x2190
movq %rax, %r14
movl %ebx, (%rax)
movl %ebx, 0x4(%rax)
leaq 0x8(%rax), %rdi
movl $0x10000, %edx          # imm = 0x10000
movl %ebx, %esi
xorl %ecx, %ecx
callq 0x393c
jmp 0x339b
testl %ebx, %ebx
jns 0x33d6
movq %r12, %rdi
callq 0x2eff
testl %eax, %eax
js 0x33d3
movl %eax, %ebx
movl $0x48, %edi
callq 0x2190
movq %rax, %r14
movl %ebx, (%rax)
movl %ebx, 0x4(%rax)
leaq 0x8(%rax), %rdi
movl $0x10000, %edx          # imm = 0x10000
movl %ebx, %esi
xorl %ecx, %ecx
callq 0x393c
jmp 0x33d6
xorl %r14d, %r14d
movq %r14, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq 0x10(%rsp), %r12
leaq 0x58(%rsp), %r14
jmp 0x335a
leaq 0x1680(%rip), %rdi      # 0x4a83
callq 0x2170
jmp 0x3355
leaq 0x163e(%rip), %rdi      # 0x4a52
leaq 0x161d(%rip), %rsi      # 0x4a38
movq %r15, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x22a0
jmp 0x342c
jmp 0x342c
movq %rax, %rbx
movl $0x48, %esi
movq %r14, %rdi
jmp 0x3457
jmp 0x343d
jmp 0x343d
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x345c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x22f0