#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int STDIN_FILENO;
int STDOUT_FILENO;
int /*<<< orphan*/ close(int);
scalar_t__ dup2(int, int);
scalar_t__ execl(char *, char *, char *, char *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int read(int, char *, int);
int strlen(char *);
int /*<<< orphan*/ usage();
scalar_t__ write(int, char *, int);
int main(int argc, char *argv[]) {
  pid_t pid;
  int outfd[2];
  int infd[2];
  char input[100];
  if (argc != 2) {
    usage();
    return -1;
  }
  if (pipe(infd) < 0) {
    perror("pipe: infd");
    exit(-2);
  }
  if (pipe(outfd) < 0) {
    perror("pipe: outfd");
    close(infd[0]);
    close(infd[1]);
    exit(-3);
  }
  if ((pid = fork()) < 0) {
    perror("fork");
    close(infd[0]);
    close(infd[1]);
    close(outfd[0]);
    close(outfd[1]);
    exit(-4);
  } else if (pid == 0) {
    if (dup2(infd[0], STDIN_FILENO) < 0) {
      perror("dup2: infd");
      close(infd[0]);
      close(infd[1]);
      close(outfd[0]);
      close(outfd[1]);
      exit(-5);
    }
    if (dup2(outfd[1], STDOUT_FILENO) < 0) {
      perror("dup2: outfd");
      close(infd[0]);
      close(infd[1]);
      close(outfd[0]);
      close(outfd[1]);
      exit(-6);
    }
    close(infd[0]);
    close(infd[1]);
    close(outfd[0]);
    close(outfd[1]);
    if (execl("/usr/bin/gdb", "gdb", argv[1], (char *)0) < 0) {
      perror("execl");
      exit(-7);
    }
  }
  char c;
  close(infd[0]);
  close(outfd[1]);
  char command[10] = "b main\n";
  if (write(infd[1], command, strlen(command)) < 0) {
    perror("write");
    close(infd[1]);
    close(outfd[0]);
    exit(-8);
  }
  while (read(outfd[0], &c, 1) == 1) {
    if (write(STDOUT_FILENO, &c, 1) < 0) {
      perror("write 2");
      close(infd[1]);
      close(outfd[0]);
      exit(-9);
    }
  }
  close(infd[1]);
  close(outfd[0]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11e6 <main+0x36>
mov    $0x0,%al
call   1090 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14c4 <main+0x314>
lea    -0x28(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    120f <main+0x5f>
lea    0xe00(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xfffffffe,%edi
call   10b0 <exit@plt>
lea    -0x20(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    1248 <main+0x98>
lea    0xde2(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    $0xfffffffd,%edi
call   10b0 <exit@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jge    1293 <main+0xe3>
lea    0xdb3(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0xfffffffc,%edi
call   10b0 <exit@plt>
cmpq   $0x0,-0x18(%rbp)
jne    13a4 <main+0x1f4>
mov    -0x28(%rbp),%edi
mov    0x2d30(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
cmp    $0x0,%rax
jge    12ef <main+0x13f>
lea    0xd5c(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0xfffffffb,%edi
call   10b0 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    0x2cf7(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
cmp    $0x0,%rax
jge    1340 <main+0x190>
lea    0xd16(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    $0xfffffffa,%edi
call   10b0 <exit@plt>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcc4(%rip),%rdi
lea    0xcc6(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
call   10c0 <execl@plt>
cmp    $0x0,%rax
jge    139f <main+0x1ef>
lea    0xcb0(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xfffffff9,%edi
call   10b0 <exit@plt>
jmp    13a4 <main+0x1f4>
jmp    13a9 <main+0x1f9>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    0xc94(%rip),%rax
mov    %rax,-0x9b(%rbp)
mov    0xc8e(%rip),%ax
mov    %ax,-0x93(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0xac(%rbp)
lea    -0x9b(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    -0x9b(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    143c <main+0x28c>
lea    0xc29(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
mov    $0xfffffff8,%edi
call   10b0 <exit@plt>
jmp    1441 <main+0x291>
mov    -0x20(%rbp),%edi
lea    -0x91(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
cmp    $0x1,%eax
jne    14ad <main+0x2fd>
mov    0x2b8b(%rip),%rax
mov    (%rax),%edi
lea    -0x91(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    14a8 <main+0x2f8>
lea    0xbc3(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
mov    $0xfffffff7,%edi
call   10b0 <exit@plt>
jmp    1441 <main+0x291>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x2,%edi
jne    1333 <main+0x183>
mov    %rsi,%rbx
lea    0x4(%rsp),%rdi
call   1070 <pipe@plt>
test   %rax,%rax
js     135d <main+0x1ad>
lea    0xc(%rsp),%rdi
call   1070 <pipe@plt>
test   %rax,%rax
js     1373 <main+0x1c3>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %rax,%rax
js     139b <main+0x1eb>
jne    1277 <main+0xc7>
mov    0x4(%rsp),%edi
mov    0x2dd2(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
test   %rax,%rax
js     13fd <main+0x24d>
mov    0x10(%rsp),%edi
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
test   %rax,%rax
js     1437 <main+0x287>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    0x10(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rbx),%rdx
lea    0xdd3(%rip),%rdi
lea    0xdd5(%rip),%rsi
xor    %ecx,%ecx
call   10c0 <execl@plt>
test   %rax,%rax
js     1471 <main+0x2c1>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
mov    0x10(%rsp),%edi
call   1060 <close@plt>
movabs $0xa6e69616d2062,%rax
mov    %rax,0x18(%rsp)
movw   $0x0,0x20(%rsp)
mov    0x8(%rsp),%ebx
lea    0x18(%rsp),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %rax,%rax
js     13d5 <main+0x225>
lea    0x17(%rsp),%rbx
mov    0x2d1f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1080 <read@plt>
cmp    $0x1,%eax
jne    1341 <main+0x191>
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
test   %rax,%rax
jns    12e0 <main+0x130>
lea    0xd3a(%rip),%rdi
call   10a0 <perror@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    $0xfffffff7,%edi
call   10b0 <exit@plt>
xor    %eax,%eax
call   1090 <usage@plt>
mov    $0xffffffff,%eax
jmp    1355 <main+0x1a5>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret
lea    0xc9c(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xfffffffe,%edi
call   10b0 <exit@plt>
lea    0xc91(%rip),%rdi
call   10a0 <perror@plt>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    $0xfffffffd,%edi
call   10b0 <exit@plt>
lea    0xc75(%rip),%rdi
call   10a0 <perror@plt>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    0x10(%rsp),%edi
call   1060 <close@plt>
mov    $0xfffffffc,%edi
call   10b0 <exit@plt>
lea    0xc6a(%rip),%rdi
call   10a0 <perror@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    $0xfffffff8,%edi
call   10b0 <exit@plt>
lea    0xc18(%rip),%rdi
call   10a0 <perror@plt>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    0x10(%rsp),%edi
call   1060 <close@plt>
mov    $0xfffffffb,%edi
call   10b0 <exit@plt>
lea    0xbe9(%rip),%rdi
call   10a0 <perror@plt>
mov    0x4(%rsp),%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
mov    0x10(%rsp),%edi
call   1060 <close@plt>
mov    $0xfffffffa,%edi
call   10b0 <exit@plt>
lea    0xbc8(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xfffffff9,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"pipe: infd\00"
@.str.1 = [12 x i8] c"pipe: outfd\00"
@.str.2 = [5 x i8] c"fork\00"
@STDIN_FILENO = global i32 0
@.str.3 = [11 x i8] c"dup2: infd\00"
@STDOUT_FILENO = global i32 0
@.str.4 = [12 x i8] c"dup2: outfd\00"
@.str.5 = [13 x i8] c"/usr/bin/gdb\00"
@.str.6 = [4 x i8] c"gdb\00"
@.str.7 = [6 x i8] c"execl\00"
@__const.main.command = [10 x i8] c"b main\0A\00\00\00"
@.str.8 = [6 x i8] c"write\00"
@.str.9 = [8 x i8] c"write 2\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [2 x i32]
%8 = alloca [2 x i32]
%9 = alloca [100 x i8]
%10 = alloca i8
%11 = alloca [10 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %173
16: ; preds = %2
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%18 = call i64 @pipe(i32* %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 -2)
unreachable
23: ; preds = %16
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%25 = call i64 @pipe(i32* %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%30 = load i32, i32* %29
%31 = call i32 @close(i32 %30)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 @close(i32 %33)
%35 = call i32 @exit(i32 -3)
unreachable
36: ; preds = %23
%37 = call i64 (...) @fork()
store i64 %37, i64* %6
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %54
39: ; preds = %36
%40 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%42 = load i32, i32* %41
%43 = call i32 @close(i32 %42)
%44 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%45 = load i32, i32* %44
%46 = call i32 @close(i32 %45)
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%48 = load i32, i32* %47
%49 = call i32 @close(i32 %48)
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%51 = load i32, i32* %50
%52 = call i32 @close(i32 %51)
%53 = call i32 @exit(i32 -4)
unreachable
54: ; preds = %36
%55 = load i64, i64* %6
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %121
57: ; preds = %54
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%59 = load i32, i32* %58
%60 = load i32, i32* @STDIN_FILENO
%61 = call i64 @dup2(i32 %59, i32 %60)
%62 = icmp slt i64 %61, 0
br i1 %62, label %63, label %78
63: ; preds = %57
%64 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%65 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%66 = load i32, i32* %65
%67 = call i32 @close(i32 %66)
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%69 = load i32, i32* %68
%70 = call i32 @close(i32 %69)
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%72 = load i32, i32* %71
%73 = call i32 @close(i32 %72)
%74 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%75 = load i32, i32* %74
%76 = call i32 @close(i32 %75)
%77 = call i32 @exit(i32 -5)
unreachable
78: ; preds = %57
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%80 = load i32, i32* %79
%81 = load i32, i32* @STDOUT_FILENO
%82 = call i64 @dup2(i32 %80, i32 %81)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %99
84: ; preds = %78
%85 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%87 = load i32, i32* %86
%88 = call i32 @close(i32 %87)
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%90 = load i32, i32* %89
%91 = call i32 @close(i32 %90)
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%93 = load i32, i32* %92
%94 = call i32 @close(i32 %93)
%95 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%96 = load i32, i32* %95
%97 = call i32 @close(i32 %96)
%98 = call i32 @exit(i32 -6)
unreachable
99: ; preds = %78
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%101 = load i32, i32* %100
%102 = call i32 @close(i32 %101)
%103 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%104 = load i32, i32* %103
%105 = call i32 @close(i32 %104)
%106 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%107 = load i32, i32* %106
%108 = call i32 @close(i32 %107)
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%110 = load i32, i32* %109
%111 = call i32 @close(i32 %110)
%112 = load i8**, i8*** %5
%113 = getelementptr inbounds i8*, i8** %112, i64 1
%114 = load i8*, i8** %113
%115 = call i64 @execl(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %114, i8* null)
%116 = icmp slt i64 %115, 0
br i1 %116, label %117, label %120
117: ; preds = %99
%118 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%119 = call i32 @exit(i32 -7)
unreachable
120: ; preds = %99
br label %121
121: ; preds = %120, %54
br label %122
122: ; preds = %121
%123 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%124 = load i32, i32* %123
%125 = call i32 @close(i32 %124)
%126 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%127 = load i32, i32* %126
%128 = call i32 @close(i32 %127)
%129 = bitcast [10 x i8]* %11 to i8*
%130 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%131 = load i32, i32* %130
%132 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%133 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%134 = call i32 @strlen(i8* %133)
%135 = call i64 @write(i32 %131, i8* %132, i32 %134)
%136 = icmp slt i64 %135, 0
br i1 %136, label %137, label %146
137: ; preds = %122
%138 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%139 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%140 = load i32, i32* %139
%141 = call i32 @close(i32 %140)
%142 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%143 = load i32, i32* %142
%144 = call i32 @close(i32 %143)
%145 = call i32 @exit(i32 -8)
unreachable
146: ; preds = %122
br label %147
147: ; preds = %165, %146
%148 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%149 = load i32, i32* %148
%150 = call i32 @read(i32 %149, i8* %10, i32 1)
%151 = icmp eq i32 %150, 1
br i1 %151, label %152, label %166
152: ; preds = %147
%153 = load i32, i32* @STDOUT_FILENO
%154 = call i64 @write(i32 %153, i8* %10, i32 1)
%155 = icmp slt i64 %154, 0
br i1 %155, label %156, label %165
156: ; preds = %152
%157 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%158 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%159 = load i32, i32* %158
%160 = call i32 @close(i32 %159)
%161 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%162 = load i32, i32* %161
%163 = call i32 @close(i32 %162)
%164 = call i32 @exit(i32 -9)
unreachable
165: ; preds = %152
br label %147
166: ; preds = %147
%167 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%168 = load i32, i32* %167
%169 = call i32 @close(i32 %168)
%170 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%171 = load i32, i32* %170
%172 = call i32 @close(i32 %171)
store i32 0, i32* %3
br label %173
173: ; preds = %166, %14
%174 = load i32, i32* %3
ret i32 %174
}

LLVM IR (-O2):
@.str = [11 x i8] c"pipe: infd\00"
@.str.1 = [12 x i8] c"pipe: outfd\00"
@.str.2 = [5 x i8] c"fork\00"
@STDIN_FILENO = global i32 0
@.str.3 = [11 x i8] c"dup2: infd\00"
@STDOUT_FILENO = global i32 0
@.str.4 = [12 x i8] c"dup2: outfd\00"
@.str.5 = [13 x i8] c"/usr/bin/gdb\00"
@.str.6 = [4 x i8] c"gdb\00"
@.str.7 = [6 x i8] c"execl\00"
@__const.main.command = [10 x i8] c"b main\0A\00\00\00"
@.str.8 = [6 x i8] c"write\00"
@.str.9 = [8 x i8] c"write 2\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca i8
%6 = alloca [10 x i8]
%7 = bitcast [2 x i32]* %3 to i8*
%8 = bitcast [2 x i32]* %4 to i8*
%9 = icmp eq i32 %0, 2
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 (...) @usage()
br label %141
12: ; preds = %2
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%14 = call i64 @pipe(i32* %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 -2)
unreachable
19: ; preds = %12
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%21 = call i64 @pipe(i32* %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* %13
%26 = call i32 @close(i32 %25)
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%28 = load i32, i32* %27
%29 = call i32 @close(i32 %28)
%30 = call i32 @exit(i32 -3)
unreachable
31: ; preds = %19
%32 = call i64 (...) @fork()
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %47
34: ; preds = %31
%35 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* %13
%37 = call i32 @close(i32 %36)
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%39 = load i32, i32* %38
%40 = call i32 @close(i32 %39)
%41 = load i32, i32* %20
%42 = call i32 @close(i32 %41)
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%44 = load i32, i32* %43
%45 = call i32 @close(i32 %44)
%46 = call i32 @exit(i32 -4)
unreachable
47: ; preds = %31
%48 = icmp eq i64 %32, 0
br i1 %48, label %49, label %102
49: ; preds = %47
%50 = load i32, i32* %13
%51 = load i32, i32* @STDIN_FILENO
%52 = call i64 @dup2(i32 %50, i32 %51)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %67
54: ; preds = %49
%55 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%56 = load i32, i32* %13
%57 = call i32 @close(i32 %56)
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%59 = load i32, i32* %58
%60 = call i32 @close(i32 %59)
%61 = load i32, i32* %20
%62 = call i32 @close(i32 %61)
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%64 = load i32, i32* %63
%65 = call i32 @close(i32 %64)
%66 = call i32 @exit(i32 -5)
unreachable
67: ; preds = %49
%68 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%69 = load i32, i32* %68
%70 = load i32, i32* @STDOUT_FILENO
%71 = call i64 @dup2(i32 %69, i32 %70)
%72 = icmp slt i64 %71, 0
br i1 %72, label %73, label %85
73: ; preds = %67
%74 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%75 = load i32, i32* %13
%76 = call i32 @close(i32 %75)
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%78 = load i32, i32* %77
%79 = call i32 @close(i32 %78)
%80 = load i32, i32* %20
%81 = call i32 @close(i32 %80)
%82 = load i32, i32* %68
%83 = call i32 @close(i32 %82)
%84 = call i32 @exit(i32 -6)
unreachable
85: ; preds = %67
%86 = load i32, i32* %13
%87 = call i32 @close(i32 %86)
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%89 = load i32, i32* %88
%90 = call i32 @close(i32 %89)
%91 = load i32, i32* %20
%92 = call i32 @close(i32 %91)
%93 = load i32, i32* %68
%94 = call i32 @close(i32 %93)
%95 = getelementptr inbounds i8*, i8** %1, i64 1
%96 = load i8*, i8** %95
%97 = call i64 @execl(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %96, i8* null)
%98 = icmp slt i64 %97, 0
br i1 %98, label %99, label %102
99: ; preds = %85
%100 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%101 = call i32 @exit(i32 -7)
unreachable
102: ; preds = %47, %85
%103 = load i32, i32* %13
%104 = call i32 @close(i32 %103)
%105 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%106 = load i32, i32* %105
%107 = call i32 @close(i32 %106)
%108 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%109 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%110 = load i32, i32* %109
%111 = call i32 @strlen(i8* %108)
%112 = call i64 @write(i32 %110, i8* %108, i32 %111)
%113 = icmp slt i64 %112, 0
br i1 %113, label %114, label %121
114: ; preds = %102
%115 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%116 = load i32, i32* %109
%117 = call i32 @close(i32 %116)
%118 = load i32, i32* %20
%119 = call i32 @close(i32 %118)
%120 = call i32 @exit(i32 -8)
unreachable
121: ; preds = %102, %125
%122 = load i32, i32* %20
%123 = call i32 @read(i32 %122, i8* %5, i32 1)
%124 = icmp eq i32 %123, 1
br i1 %124, label %125, label %136
125: ; preds = %121
%126 = load i32, i32* @STDOUT_FILENO
%127 = call i64 @write(i32 %126, i8* %5, i32 1)
%128 = icmp slt i64 %127, 0
br i1 %128, label %129, label %121
129: ; preds = %125
%130 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%131 = load i32, i32* %109
%132 = call i32 @close(i32 %131)
%133 = load i32, i32* %20
%134 = call i32 @close(i32 %133)
%135 = call i32 @exit(i32 -9)
unreachable
136: ; preds = %121
%137 = load i32, i32* %109
%138 = call i32 @close(i32 %137)
%139 = load i32, i32* %20
%140 = call i32 @close(i32 %139)
br label %141
141: ; preds = %136, %10
%142 = phi i32 [ -1, %10 ], [ 0, %136 ]
ret i32 %142
}