// File: /workspace/github_cpp_makefile_star2_O1/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 0x664c(%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 0x8c76
movq 0xb3bb(%rip), %r14      # 0x13fb8
leaq 0x6624(%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 0xb389(%rip), %rdi      # 0x13fb8
callq 0x3030
movq %rax, %rdi
callq 0x31a0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x6f8f(%rip), %rdx      # 0xfbd9
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x7590
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 0x8d6a
callq 0x30a0
testl %eax, %eax
js 0x8d99
je 0x8dbb
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 0xb31d(%rip), %r15      # 0x13fe8
movl -0x30(%rbp), %edi
movl $0x64, %edx
movq %r14, %rsi
callq 0x3310
movq %rax, %r12
testl %r12d, %r12d
js 0x8cea
jne 0x8d25
jmp 0x8d8c
movl $0x14, %edx
movq %r15, %rdi
leaq 0x65c6(%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 0x7590
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %rbx, %rdi
callq 0x30d0
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x8ccb
callq 0x3260
jmp 0x8ccb
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x64d5(%rip), %rsi      # 0xf24d
leaq 0x64e1(%rip), %rdx      # 0xf260
movq %rbx, %rdi
callq 0x7590
jmp 0x8c55
movl -0x30(%rbp), %edi
callq 0x33f0
jmp 0x8c55
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x64ba(%rip), %rsi      # 0xf261
leaq 0x64c6(%rip), %rdx      # 0xf274
movq %rbx, %rdi
callq 0x7590
jmp 0x8c55
movl -0x30(%rbp), %edi
callq 0x33f0
movl -0x2c(%rbp), %edi
cmpl $0x1, %edi
je 0x8e06
movl $0x1, %esi
callq 0x3250
cmpl $0x1, %eax
je 0x8dfe
movq 0xb207(%rip), %rdi      # 0x13fe8
leaq 0x648d(%rip), %rsi      # 0xf275
movl $0x1b, %edx
callq 0x32c0
movq 0xb1ef(%rip), %rdi      # 0x13fe8
callq 0x3140
movl -0x2c(%rbp), %edi
callq 0x33f0
movq 0xaf73(%rip), %rax      # 0x13d80
leaq -0xc0(%rbp), %rsi
movq %rax, 0x10(%rsi)
movaps 0xaf51(%rip), %xmm0     # 0x13d70
movaps %xmm0, (%rsi)
leaq 0x63f0(%rip), %rdi      # 0xf219
callq 0x3230
testl %eax, %eax
js 0x8e50
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x6d99(%rip), %rdx      # 0xfbd9
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x7590
jmp 0x8c55
movq 0xb191(%rip), %r14      # 0x13fe8
leaq 0x6438(%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 0xb15f(%rip), %rdi      # 0x13fe8
callq 0x3030
movq %rax, %rdi
callq 0x31a0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
leaq 0x6406(%rip), %rsi      # 0xf2aa
leaq 0x6413(%rip), %rdx      # 0xf2be
movq %rbx, %rdi
callq 0x7590
jmp 0x8c55
jmp 0x8ec8
jmp 0x8ec8
jmp 0x8ec8
jmp 0x8ec8
jmp 0x8ee2
jmp 0x8ec8
jmp 0x8ec8
jmp 0x8ec8
movq %rax, %r14
jmp 0x8ef3
movq %rax, %r14
movq -0x58(%rbp), %rdi
cmpq %r13, %rdi
je 0x8ee5
callq 0x3260
jmp 0x8ee5
jmp 0x8ee2
movq %rax, %r14
movq (%rbx), %rdi
cmpq -0x38(%rbp), %rdi
je 0x8ef3
callq 0x3260
leaq -0x2c8(%rbp), %rdi
callq 0x3090
movq %r14, %rdi
callq 0x3390