// File: /workspace/github_c_makefile_star2_O0/robertdavidgraham[P]wc2/wcdiff.c
// Function: my_spawn
struct handles
my_spawn(const char *progname, const char *parms)
{
    int pid;
    int pipe_stdout[2];
    int pipe_stderr[2];
    int pipe_stdin[2];
    struct handles handles = {0,0,0};
    int err;
    char **new_argv;


    err = pipe(pipe_stdout);
    if (err < 0) {
        fprintf(stderr, "[-] pipe(): %s\n", strerror(errno));
        return handles;
    }
    err = pipe(pipe_stderr);
    if (err < 0) {
        fprintf(stderr, "[-] pipe(): %s\n", strerror(errno));
        return handles;
    }
    err = pipe(pipe_stdin);
    if (err < 0) {
        fprintf(stderr, "[-] pipe(): %s\n", strerror(errno));
        return handles;
    }



    /* Configure the parent end of the pipes be be non-inheritable.
     * In other words, none of the children can read from these
     * pipes, nor will they exist in child process space */
    /*fcntl(pipe_stdout[0], F_SETFD, FD_CLOEXEC);
    fcntl(pipe_stderr[0], F_SETFD, FD_CLOEXEC);
    fcntl(pipe_stdin[0], F_SETFD, FD_CLOEXEC);*/

    pid = fork();
    if (pid == -1) {
        fprintf(stderr, "[-] fork(): %s\n", strerror(errno));
        return handles;
    }

    /* Setup child parameters */
    new_argv = malloc(10 * sizeof(char*));
    new_argv[0] = (char *)progname;
    new_argv[1] = (char *)parms;
    new_argv[2] = NULL;
    new_argv[3] = NULL;

    if (pid == 0) {
        int err;

        close(pipe_stdin[1]);
        close(pipe_stdout[0]);
        close(pipe_stderr[0]);

        dup2(pipe_stdin[0], 0);
        dup2(pipe_stdout[1], 1);
        dup2(pipe_stderr[1], 2);

        /* Now execute our child with new program */
        err = execvp(progname, new_argv);
        if (err) {
            fprintf(stderr, "[+] execvp(%s) failed: %s\n", progname, strerror(errno));
            return handles;
        }

    } else {
        handles.child_stdin = pipe_stdin[1];
        handles.child_stdout = pipe_stdout[0];
        handles.child_stderr = pipe_stderr[0];

        close(pipe_stdout[1]);
        close(pipe_stderr[1]);
        close(pipe_stdin[0]);

        /* we are the parent */
        return handles;
    }
    return handles;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
leaq -0xc(%rbp), %rdi
xorl %esi, %esi
movl $0xc, %edx
callq 0x1090
leaq -0x2c(%rbp), %rdi
callq 0x10b0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jge 0x1449
movq 0x2bdc(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x68(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1160
movq -0x68(%rbp), %rdi
movq %rax, %rdx
leaq 0xbeb(%rip), %rsi       # 0x2028
movb $0x0, %al
callq 0x10e0
jmp 0x1629
leaq -0x34(%rbp), %rdi
callq 0x10b0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jge 0x148f
movq 0x2b96(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x70(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1160
movq -0x70(%rbp), %rdi
movq %rax, %rdx
leaq 0xba5(%rip), %rsi       # 0x2028
movb $0x0, %al
callq 0x10e0
jmp 0x1629
leaq -0x3c(%rbp), %rdi
callq 0x10b0
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jge 0x14d5
movq 0x2b50(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x78(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1160
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0xb5f(%rip), %rsi       # 0x2028
movb $0x0, %al
callq 0x10e0
jmp 0x1629
callq 0x1170
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x1517
movq 0x2b0e(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x80(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1160
movq -0x80(%rbp), %rdi
movq %rax, %rdx
leaq 0xb2d(%rip), %rsi       # 0x2038
movb $0x0, %al
callq 0x10e0
jmp 0x1629
movl $0x50, %edi
callq 0x1100
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x10(%rax)
movq -0x48(%rbp), %rax
movq $0x0, 0x18(%rax)
cmpl $0x0, -0x24(%rbp)
jne 0x15fb
movl -0x38(%rbp), %edi
callq 0x10a0
movl -0x2c(%rbp), %edi
callq 0x10a0
movl -0x34(%rbp), %edi
callq 0x10a0
movl -0x3c(%rbp), %edi
xorl %esi, %esi
callq 0x1070
movl -0x28(%rbp), %edi
movl $0x1, %esi
callq 0x1070
movl -0x30(%rbp), %edi
movl $0x2, %esi
callq 0x1070
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x1130
movl %eax, -0x4c(%rbp)
cmpl $0x0, -0x4c(%rbp)
je 0x15f9
movq 0x2a41(%rip), %rax      # 0x3ff8
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
callq 0x1030
movl (%rax), %edi
callq 0x1160
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rdx
movq %rax, %rcx
leaq 0xa58(%rip), %rsi       # 0x2048
movb $0x0, %al
callq 0x10e0
jmp 0x1629
jmp 0x1627
movl -0x38(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x28(%rbp), %edi
callq 0x10a0
movl -0x30(%rbp), %edi
callq 0x10a0
movl -0x3c(%rbp), %edi
callq 0x10a0
jmp 0x1629
jmp 0x1629
movl -0x4(%rbp), %eax
movl %eax, -0x58(%rbp)
movq -0xc(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl -0x58(%rbp), %edx
addq $0x90, %rsp
popq %rbp
retq
nopw (%rax,%rax)