#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;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int STDIN_FILENO;
int /*<<< orphan*/ close(int);
int dup2(int, int);
scalar_t__ execl(char *, char *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fork();
char *getenv(char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
char *strrchr(char *, char);
scalar_t__ waitpid(scalar_t__, int /*<<< orphan*/ *, int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int fds[2];
  FILE *fp = NULL;
  if (argc < 2) {
    printf("Usage %s <filename>\n", argv[0]);
    exit(1);
  }
  if ((fp = fopen(argv[1], "r")) == NULL) {
    perror("fopen error");
    exit(1);
  }
  if (pipe(fds) < 0) {
    perror("pipe error");
    exit(1);
  }
  printf("fd0=%d, fd1=%d\n", fds[0], fds[1]);
  pid_t pid;
  if ((pid = fork()) < 0) {
    perror("fork error");
    exit(1);
  } else if (pid > 0) {
    close(fds[0]);
    char line[1024];
    int n = 0;
    while (fgets(line, 1024, fp) != NULL) {
      n = strlen(line);
      if (write(fds[1], line, n) != n) {
        perror("write error");
        exit(1);
      }
    }
    if (ferror(fp)) {
      perror("fgets error");
      exit(1);
    }
    fclose(fp);
    close(fds[1]);
    if (waitpid(pid, NULL, 0) < 0) {
      perror("waitpid error");
      exit(1);
    }
    exit(0);
  } else {
    close(fds[1]);
    if (fds[0] != STDIN_FILENO) {
      if (dup2(fds[0], STDIN_FILENO) != STDIN_FILENO) {
        perror("dup2 error");
        exit(1);
      }
    }
    char *pager = NULL;
    char *argv0 = NULL;
    if ((pager = getenv("PAGER")) == NULL)
      pager = "/bin/more";
    if ((argv0 = strrchr(pager, '/')) != NULL) {
      ++argv0;
    } else {
      argv0 = pager;
    }
    if (execl(pager, argv0, (char *)NULL) < 0) {
      perror("execl error");
      exit(1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    125a <main+0x4a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0d(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1292 <main+0x82>
lea    0xd92(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x18(%rbp),%rdi
call   10c0 <pipe@plt>
cmp    $0x0,%rax
jge    12bb <main+0xab>
lea    0xd75(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x0,%al
call   1130 <fork@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jge    12fa <main+0xea>
lea    0xd51(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
cmpq   $0x0,-0x28(%rbp)
jle    13f4 <main+0x1e4>
mov    -0x18(%rbp),%edi
call   10b0 <close@plt>
movl   $0x0,-0x434(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x400,%esi
call   10d0 <fgets@plt>
cmp    $0x0,%rax
je     1384 <main+0x174>
lea    -0x430(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x434(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    -0x434(%rbp),%edx
call   1050 <write@plt>
cmp    -0x434(%rbp),%eax
je     137f <main+0x16f>
lea    0xcd7(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    1317 <main+0x107>
mov    -0x20(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     13ad <main+0x19d>
lea    0xcb5(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x14(%rbp),%edi
call   10b0 <close@plt>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10e0 <waitpid@plt>
cmp    $0x0,%rax
jge    13ed <main+0x1dd>
lea    0xc81(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%edi
call   10b0 <close@plt>
mov    -0x18(%rbp),%eax
mov    0x2bda(%rip),%rcx
cmp    (%rcx),%eax
je     1449 <main+0x239>
mov    -0x18(%rbp),%edi
mov    0x2bc8(%rip),%rax
mov    (%rax),%esi
call   1080 <dup2@plt>
mov    0x2bba(%rip),%rcx
cmp    (%rcx),%eax
je     1444 <main+0x234>
lea    0xc38(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    1449 <main+0x239>
movq   $0x0,-0x440(%rbp)
movq   $0x0,-0x448(%rbp)
lea    0xc12(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x440(%rbp)
cmp    $0x0,%rax
jne    148a <main+0x27a>
lea    0xbfb(%rip),%rax
mov    %rax,-0x440(%rbp)
mov    -0x440(%rbp),%rdi
mov    $0x2f,%esi
call   10a0 <strrchr@plt>
mov    %rax,-0x448(%rbp)
cmp    $0x0,%rax
je     14c3 <main+0x2b3>
mov    -0x448(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x448(%rbp)
jmp    14d1 <main+0x2c1>
mov    -0x440(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    -0x440(%rbp),%rdi
mov    -0x448(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1120 <execl@plt>
cmp    $0x0,%rax
jge    1508 <main+0x2f8>
lea    0xb8f(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
jmp    150d <main+0x2fd>
jmp    1512 <main+0x302>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x418,%rsp
cmp    $0x1,%edi
jle    12fd <main+0xed>
mov    0x8(%rsi),%rdi
lea    0xe45(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1318 <main+0x108>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
call   10c0 <pipe@plt>
test   %rax,%rax
js     1324 <main+0x114>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xdc8(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
xor    %eax,%eax
call   1130 <fork@plt>
test   %rax,%rax
js     1330 <main+0x120>
jne    133c <main+0x12c>
mov    0xc(%rsp),%edi
call   10b0 <close@plt>
mov    0x8(%rsp),%edi
mov    0x2d4b(%rip),%rbx
mov    (%rbx),%esi
cmp    %esi,%edi
je     12a8 <main+0x98>
call   1080 <dup2@plt>
cmp    (%rbx),%eax
jne    1393 <main+0x183>
lea    0xdc9(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xdc0(%rip),%rbx
cmovne %rax,%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   10a0 <strrchr@plt>
lea    0x1(%rax),%rsi
test   %rax,%rax
cmove  %rbx,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1120 <execl@plt>
test   %rax,%rax
js     138a <main+0x17a>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsi),%rsi
lea    0xcf9(%rip),%rdi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xcf6(%rip),%rdi
jmp    13db <main+0x1cb>
lea    0xcf6(%rip),%rdi
jmp    13db <main+0x1cb>
lea    0xd05(%rip),%rdi
jmp    13db <main+0x1cb>
mov    %rax,%r14
mov    0x8(%rsp),%edi
call   10b0 <close@plt>
lea    0x10(%rsp),%r15
nopl   (%rax)
mov    %r15,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   10d0 <fgets@plt>
test   %rax,%rax
je     139c <main+0x18c>
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1050 <write@plt>
cmp    %ebp,%eax
je     1350 <main+0x140>
lea    0xcbf(%rip),%rdi
jmp    13db <main+0x1cb>
lea    0xcf7(%rip),%rdi
jmp    13db <main+0x1cb>
lea    0xcd3(%rip),%rdi
jmp    13db <main+0x1cb>
mov    %rbx,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    13d4 <main+0x1c4>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0xc(%rsp),%edi
call   10b0 <close@plt>
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10e0 <waitpid@plt>
test   %rax,%rax
jns    13ea <main+0x1da>
lea    0xc8d(%rip),%rdi
jmp    13db <main+0x1cb>
lea    0xc78(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
xor    %edi,%edi
call   1110 <exit@plt>

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

LLVM IR (-O2):
@.str = [21 x i8] c"Usage %s <filename>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [12 x i8] c"fopen error\00"
@.str.3 = [11 x i8] c"pipe error\00"
@.str.4 = [16 x i8] c"fd0=%d, fd1=%d\0A\00"
@.str.5 = [11 x i8] c"fork error\00"
@.str.6 = [12 x i8] c"write error\00"
@.str.7 = [12 x i8] c"fgets error\00"
@.str.8 = [14 x i8] c"waitpid error\00"
@STDIN_FILENO = global i32 0
@.str.9 = [11 x i8] c"dup2 error\00"
@.str.10 = [6 x i8] c"PAGER\00"
@.str.11 = [10 x i8] c"/bin/more\00"
@.str.12 = [12 x i8] c"execl error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = alloca [1024 x i8]
%5 = bitcast [2 x i32]* %3 to i8*
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %11
%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 %26
23: ; preds = %19
%24 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %19
%27 = load i32, i32* %20
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 %29)
%31 = call i64 (...) @fork()
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %26
%34 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %26
%37 = icmp eq i64 %31, 0
br i1 %37, label %70, label %38
38: ; preds = %36
%39 = load i32, i32* %20
%40 = call i32 @close(i32 %39)
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
br label %42
42: ; preds = %45, %38
%43 = call i32* @fgets(i8* %41, i32 1024, i32* %14)
%44 = icmp eq i32* %43, null
br i1 %44, label %53, label %45
45: ; preds = %42
%46 = call i32 @strlen(i8* %41)
%47 = load i32, i32* %28
%48 = call i32 @write(i32 %47, i8* %41, i32 %46)
%49 = icmp eq i32 %48, %46
br i1 %49, label %42, label %50
50: ; preds = %45
%51 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %42
%54 = call i64 @ferror(i32* %14)
%55 = icmp eq i64 %54, 0
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%58 = call i32 @exit(i32 1)
unreachable
59: ; preds = %53
%60 = call i32 @fclose(i32* %14)
%61 = load i32, i32* %28
%62 = call i32 @close(i32 %61)
%63 = call i64 @waitpid(i64 %31, i32* null, i32 0)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %59
%66 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %59
%69 = call i32 @exit(i32 0)
unreachable
70: ; preds = %36
%71 = load i32, i32* %28
%72 = call i32 @close(i32 %71)
%73 = load i32, i32* %20
%74 = load i32, i32* @STDIN_FILENO
%75 = icmp eq i32 %73, %74
br i1 %75, label %83, label %76
76: ; preds = %70
%77 = call i32 @dup2(i32 %73, i32 %74)
%78 = load i32, i32* @STDIN_FILENO
%79 = icmp eq i32 %77, %78
br i1 %79, label %83, label %80
80: ; preds = %76
%81 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %76, %70
%84 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%85 = icmp eq i8* %84, null
%86 = select i1 %85, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %84
%87 = call i8* @strrchr(i8* dereferenceable(1) %86, i8 signext 47)
%88 = icmp eq i8* %87, null
%89 = getelementptr inbounds i8, i8* %87, i64 1
%90 = select i1 %88, i8* %86, i8* %89
%91 = call i64 @execl(i8* %86, i8* %90, i8* null)
%92 = icmp slt i64 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %83
%94 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %83
ret i32 0
}