// File: /workspace/github_cpp_makefile_star2_O3/AsherGlick[P]CommentHeader/source/./pipein.h
// Function: copyFromClipboard[abi:cxx11]()
std::string copyFromClipboard() {

    std::ifstream xclipBinary("/usr/bin/xclip");
    if (!xclipBinary.good()){
        std::cout << "Error: Cannot Find XClip binary" << std::endl;
        return "";
    }

    int fd2[2];
    pid_t pid;
    // Create a pipe
    if ( (pipe(fd2) < 0) ) return "PIPE ERROR (PARENT)"; // Pipe Error (parent)
    // fork into a new process
    if ( (pid = fork()) < 0 ) return "FORK ERROR (PARENT)"; // Fork Error (parent)

    // Child process
    else  if (pid == 0) {

        close(fd2[0]);
        
        if (fd2[1] != STDOUT_FILENO) {
            if (dup2(fd2[1], STDOUT_FILENO) != STDOUT_FILENO) {
                std::cerr << "CHILD: dup2 error to stdout" << std::endl;
            }
            close(fd2[1]);
        }
        
        char *args[] = { (char*)"xclip" , (char*)"-out", (char*)0};
        if ( execv("/usr/bin/xclip", args) < 0) {
            std::cerr << "CHILD: system error" << std::endl;
            return "SYSTEM ERROR (CHILD)";
        }
        return "";
    }

    // PARENT process
    else {
        close(fd2[1]);

        #define LINEBUFFERSIZE 100
        char lineBuffer[LINEBUFFERSIZE];
        std::string output;
        int rv;

        while(true) {
            if ((rv = read(fd2[0], lineBuffer, LINEBUFFERSIZE)) < 0 ) {
                std::cerr << "READ ERROR FROM PIPE" << std::endl;
            }
            // Pipe Closed
            else if (rv == 0) {
                break;
            }

            std::string trimmedString(lineBuffer, rv);
            output += trimmedString;
        }

        close(fd2[0]);
        return output;
    }

    return ""; // Error.
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rdi, %rbx
leaq 0x66c8(%rip), %rsi      # 0xf219
leaq -0x2c8(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x33b0
movq (%r14), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x2a8(%rbp,%rax)
je 0x8bfa
movq 0xb437(%rip), %r14      # 0x13fb8
leaq 0x66a0(%rip), %rsi      # 0xf228
movl $0x1f, %edx
movq %r14, %rdi
callq 0x32c0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x3270
movsbl %al, %esi
movq 0xb405(%rip), %rdi      # 0x13fb8
callq 0x3030
movq %rax, %rdi
callq 0x31a0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x700b(%rip), %rdx      # 0xfbd9
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x750c
leaq -0x2c8(%rbp), %rdi
callq 0x3090
movq %rbx, %rax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x3300
testl %eax, %eax
js 0x8cee
callq 0x30a0
testl %eax, %eax
js 0x8d1d
je 0x8d3f
movl -0x2c(%rbp), %edi
callq 0x33f0
leaq 0x10(%rbx), %rax
movq %rax, -0x38(%rbp)
movq %rax, (%rbx)
movq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
leaq -0x48(%rbp), %r13
leaq -0xc0(%rbp), %r14
movq 0xb399(%rip), %r15      # 0x13fe8
movl -0x30(%rbp), %edi
movl $0x64, %edx
movq %r14, %rsi
callq 0x3310
movq %rax, %r12
testl %r12d, %r12d
js 0x8c6e
jne 0x8ca9
jmp 0x8d10
movl $0x14, %edx
movq %r15, %rdi
leaq 0x6642(%rip), %rsi      # 0xf2bf
callq 0x32c0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x3270
movsbl %al, %esi
movq %r15, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31a0
movslq %r12d, %rax
movq %r13, -0x58(%rbp)
leaq (%rax,%rbp), %rdx
addq $-0xc0, %rdx
leaq -0x58(%rbp), %rdi
movq %r14, %rsi
callq 0x750c
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %rbx, %rdi
callq 0x30d0
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x8c4f
callq 0x3260
jmp 0x8c4f
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x6551(%rip), %rsi      # 0xf24d
leaq 0x655d(%rip), %rdx      # 0xf260
movq %rbx, %rdi
callq 0x750c
jmp 0x8bd9
movl -0x30(%rbp), %edi
callq 0x33f0
jmp 0x8bd9
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x6536(%rip), %rsi      # 0xf261
leaq 0x6542(%rip), %rdx      # 0xf274
movq %rbx, %rdi
callq 0x750c
jmp 0x8bd9
movl -0x30(%rbp), %edi
callq 0x33f0
movl -0x2c(%rbp), %edi
cmpl $0x1, %edi
je 0x8d8a
movl $0x1, %esi
callq 0x3250
cmpl $0x1, %eax
je 0x8d82
movq 0xb283(%rip), %rdi      # 0x13fe8
leaq 0x6509(%rip), %rsi      # 0xf275
movl $0x1b, %edx
callq 0x32c0
movq 0xb26b(%rip), %rdi      # 0x13fe8
callq 0x3140
movl -0x2c(%rbp), %edi
callq 0x33f0
movq 0xafef(%rip), %rax      # 0x13d80
leaq -0xc0(%rbp), %rsi
movq %rax, 0x10(%rsi)
movaps 0xafcd(%rip), %xmm0     # 0x13d70
movaps %xmm0, (%rsi)
leaq 0x646c(%rip), %rdi      # 0xf219
callq 0x3230
testl %eax, %eax
js 0x8dd4
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x6e15(%rip), %rdx      # 0xfbd9
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x750c
jmp 0x8bd9
movq 0xb20d(%rip), %r14      # 0x13fe8
leaq 0x64b4(%rip), %rsi      # 0xf296
movl $0x13, %edx
movq %r14, %rdi
callq 0x32c0
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x3270
movsbl %al, %esi
movq 0xb1db(%rip), %rdi      # 0x13fe8
callq 0x3030
movq %rax, %rdi
callq 0x31a0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x6482(%rip), %rsi      # 0xf2aa
leaq 0x648f(%rip), %rdx      # 0xf2be
movq %rbx, %rdi
callq 0x750c
jmp 0x8bd9
jmp 0x8e4c
jmp 0x8e4c
jmp 0x8e4c
jmp 0x8e4c
jmp 0x8e66
jmp 0x8e4c
jmp 0x8e4c
jmp 0x8e4c
movq %rax, %r14
jmp 0x8e77
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x8e69
callq 0x3260
jmp 0x8e69
jmp 0x8e66
movq %rax, %r14
movq (%rbx), %rdi
cmpq -0x38(%rbp), %rdi
je 0x8e77
callq 0x3260
leaq -0x2c8(%rbp), %rdi
callq 0x3090
movq %r14, %rdi
callq 0x3390