#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup(int);
int /*<<< orphan*/ execlp(char *, char *, char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void runSource(int pipefd[], char *prog1) {
  switch (fork()) {
  case 0:
    close(STDOUT_FILENO);
    dup(pipefd[1]);
    close(pipefd[0]);
    execlp(prog1, prog1, (char *)NULL);
    break;
  default:
    break;
  case -1:
    fprintf(stderr, "Error in fork()\n");
    exit(EXIT_FAILURE);
    break;
  }
}


x86 assembly (clang, -O0):
<runSource>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
sub    $0xffffffff,%eax
je     11da <runSource+0x7a>
jmp    118a <runSource+0x2a>
mov    -0x14(%rbp),%eax
test   %eax,%eax
jne    11d5 <runSource+0x75>
jmp    119a <runSource+0x3a>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <dup@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <execlp@plt>
jmp    11fd <runSource+0x9d>
jmp    11fd <runSource+0x9d>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runSource>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
je     1182 <runSource+0x22>
cmp    $0xffffffff,%eax
je     11b3 <runSource+0x53>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
call   1040 <close@plt>
mov    0x4(%rbx),%edi
call   1030 <dup@plt>
mov    (%rbx),%edi
call   1040 <close@plt>
mov    %r14,%rdi
mov    %r14,%rsi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <execlp@plt>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe3d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str = [17 x i8] c"Error in fork()\0A\00"
@EXIT_FAILURE = global i32 0
define void @runSource(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = call i32 (...) @fork()
switch i32 %5, label %20 [
i32 0, label %6
i32 -1, label %21
]
6: ; preds = %2
%7 = load i32, i32* @STDOUT_FILENO
%8 = call i32 @close(i32 %7)
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = load i32, i32* %10
%12 = call i32 @dup(i32 %11)
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 0
%15 = load i32, i32* %14
%16 = call i32 @close(i32 %15)
%17 = load i8*, i8** %4
%18 = load i8*, i8** %4
%19 = call i32 @execlp(i8* %17, i8* %18, i8* null)
br label %26
20: ; preds = %2
br label %26
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %20, %6
ret void
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str = [17 x i8] c"Error in fork()\0A\00"
@EXIT_FAILURE = global i32 0
define void @runSource(i32* nocapture %0, i8* %1) {
%3 = tail call i32 (...) @fork()
switch i32 %3, label %18 [
i32 0, label %4
i32 -1, label %13
]
4: ; preds = %2
%5 = load i32, i32* @STDOUT_FILENO
%6 = tail call i32 @close(i32 %5)
%7 = getelementptr inbounds i32, i32* %0, i64 1
%8 = load i32, i32* %7
%9 = tail call i32 @dup(i32 %8)
%10 = load i32, i32* %0
%11 = tail call i32 @close(i32 %10)
%12 = tail call i32 @execlp(i8* %1, i8* %1, i8* null)
br label %18
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %2, %4
ret void
}