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

/* Variables and functions */
int EXIT_FAILURE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ pipe(int *);
int pollreader(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ proccmd(char *, int *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
char *strerror(int /*<<< orphan*/);
int strlen(char *);
scalar_t__ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  char line[1024];
  int quit = 0;
  if (argc > 2) {
    fprintf(stderr, "Error: Unexpected arg count\n");
    fprintf(stderr, "Usage: <shell> [batchFile]\n");
    exit(EXIT_FAILURE);
  }
  int fd[2];
  if (pipe(fd)) {
    fprintf(stderr, "Error: Pipe failed\n");
    exit(EXIT_FAILURE);
  }
  if (argc == 1) {
    while (1) {
      printf(">> ");
      if (fgets(line, sizeof line, stdin) != NULL) {
        proccmd(line, fd, 0);
        while (wait(NULL) > 0)
          ;
        int stat = pollreader(fd[0]);
        if (stat == EXIT_FAILURE)
          exit(stat);
        else if (stat == strlen("quit")) {
          printf("\nExiting...\n");
          break;
        }
      } else
        printf("How did you make that null\n");
    }
  } else {
    FILE *batch = fopen(argv[1], "r");
    char bytes[1024];
    if (batch == NULL) {
      fprintf(stderr, "Error: Unable to open file\n%s\n", strerror(errno));
      exit(EXIT_FAILURE);
    }
    while (fgets(line, sizeof line, batch) != NULL) {
      proccmd(line, fd, 1);
      while (wait(NULL) > 0)
        ;
      int stat = pollreader(fd[0]);
      if (stat == EXIT_FAILURE)
        exit(stat);
      else if (stat == strlen("quit")) {
        printf("\nExiting...\n");
        break;
      }
    }
    fclose(batch);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1229 <main+0x69>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
lea    0xe09(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    -0x41c(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
je     1264 <main+0xa4>
mov    0x2d92(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
jne    135b <main+0x19b>
jmp    1273 <main+0xb3>
lea    0xdd3(%rip),%rdi
call   1060 <printf@plt>
lea    -0x410(%rbp),%rdi
mov    0x2d5b(%rip),%rax
mov    (%rax),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1345 <main+0x185>
lea    -0x410(%rbp),%rdi
lea    -0x41c(%rbp),%rsi
xor    %edx,%edx
call   1050 <proccmd@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <wait@plt>
cmp    $0x0,%rax
jle    12d1 <main+0x111>
jmp    12b9 <main+0xf9>
mov    -0x41c(%rbp),%edi
call   10e0 <pollreader@plt>
mov    %eax,-0x420(%rbp)
mov    -0x420(%rbp),%eax
mov    0x2cd9(%rip),%rcx
cmp    (%rcx),%eax
jne    1302 <main+0x142>
mov    -0x420(%rbp),%edi
call   10b0 <exit@plt>
mov    -0x420(%rbp),%eax
mov    %eax,-0x838(%rbp)
lea    0xd3c(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x838(%rbp),%eax
cmp    %ecx,%eax
jne    133b <main+0x17b>
lea    0xd25(%rip),%rdi
call   1060 <printf@plt>
jmp    1356 <main+0x196>
jmp    1340 <main+0x180>
jmp    1351 <main+0x191>
lea    0xd17(%rip),%rdi
call   1060 <printf@plt>
jmp    1273 <main+0xb3>
jmp    149d <main+0x2dd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd15(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
jne    13c6 <main+0x206>
mov    0x2c4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x83c(%rbp)
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x83c(%rbp),%edi
mov    %rax,%rdx
lea    0xcd0(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2c09(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    13cb <main+0x20b>
lea    -0x410(%rbp),%rdi
mov    -0x428(%rbp),%rdx
mov    $0x400,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1491 <main+0x2d1>
lea    -0x410(%rbp),%rdi
lea    -0x41c(%rbp),%rsi
mov    $0x1,%edx
call   1050 <proccmd@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <wait@plt>
cmp    $0x0,%rax
jle    141d <main+0x25d>
jmp    1405 <main+0x245>
mov    -0x41c(%rbp),%edi
call   10e0 <pollreader@plt>
mov    %eax,-0x834(%rbp)
mov    -0x834(%rbp),%eax
mov    0x2b8d(%rip),%rcx
cmp    (%rcx),%eax
jne    144e <main+0x28e>
mov    -0x834(%rbp),%edi
call   10b0 <exit@plt>
mov    -0x834(%rbp),%eax
mov    %eax,-0x840(%rbp)
lea    0xbf0(%rip),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x840(%rbp),%eax
cmp    %ecx,%eax
jne    1487 <main+0x2c7>
lea    0xbd9(%rip),%rdi
call   1060 <printf@plt>
jmp    1491 <main+0x2d1>
jmp    148c <main+0x2cc>
jmp    13cb <main+0x20b>
mov    -0x428(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
cmp    $0x3,%edi
jge    1378 <main+0x1a8>
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x8(%rsp),%rdi
call   1080 <pipe@plt>
test   %rax,%rax
jne    139a <main+0x1ca>
cmp    $0x1,%ebp
jne    12ae <main+0xde>
lea    0xe3b(%rip),%r14
mov    0x2dcf(%rip),%r15
lea    0x10(%rsp),%rbx
mov    0x2da3(%rip),%r12
lea    0xe25(%rip),%r13
jmp    123c <main+0x6c>
xchg   %ax,%ax
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1070 <printf@plt>
mov    (%r15),%rdx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1230 <main+0x60>
mov    %rbx,%rdi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1060 <proccmd@plt>
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   10e0 <wait@plt>
test   %rax,%rax
jg     1270 <main+0xa0>
mov    0x8(%rsp),%edi
call   10f0 <pollreader@plt>
mov    %eax,%ebp
cmp    (%r12),%eax
je     1371 <main+0x1a1>
mov    %r13,%rdi
call   1050 <strlen@plt>
cmp    %eax,%ebp
jne    123c <main+0x6c>
lea    0xdee(%rip),%rdi
call   1030 <puts@plt>
jmp    135d <main+0x18d>
mov    0x8(%rbx),%rdi
lea    0xd9d(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13b3 <main+0x1e3>
mov    %rax,%rbx
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
mov    0x2ced(%rip),%r13
lea    0xd6f(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1355 <main+0x185>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1060 <proccmd@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
call   10e0 <wait@plt>
test   %rax,%rax
jg     1320 <main+0x150>
mov    0x8(%rsp),%edi
call   10f0 <pollreader@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     1371 <main+0x1a1>
mov    %r12,%rdi
call   1050 <strlen@plt>
cmp    %eax,%ebp
jne    12f0 <main+0x120>
lea    0xd42(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%edi
call   10c0 <exit@plt>
mov    0x2c59(%rip),%rbx
mov    (%rbx),%edi
lea    0xc78(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc85(%rip),%rsi
jmp    13aa <main+0x1da>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
lea    0xc8f(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    13dd <main+0x20d>
mov    0x2c1e(%rip),%rax
mov    (%rax),%ebx
mov    0x2c0d(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xc87(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    0x2be4(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Error: Unexpected arg count\0A\00"
@.str.1 = [28 x i8] c"Usage: <shell> [batchFile]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [20 x i8] c"Error: Pipe failed\0A\00"
@.str.3 = [4 x i8] c">> \00"
@stdin = global i32* null
@.str.4 = [5 x i8] c"quit\00"
@.str.5 = [13 x i8] c"\0AExiting...\0A\00"
@.str.6 = [28 x i8] c"How did you make that null\0A\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [31 x i8] c"Error: Unable to open file\0A%s\0A\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = alloca [2 x i32]
%9 = alloca i32
%10 = alloca i32*
%11 = alloca [1024 x i8]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 2
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%24 = call i64 @pipe(i32* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %22
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %71
34: ; preds = %31
br label %35
35: ; preds = %34, %69
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%38 = load i32*, i32** @stdin
%39 = call i32* @fgets(i8* %37, i32 1024, i32* %38)
%40 = icmp ne i32* %39, null
br i1 %40, label %41, label %67
41: ; preds = %35
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%44 = call i32 @proccmd(i8* %42, i32* %43, i32 0)
br label %45
45: ; preds = %48, %41
%46 = call i64 @wait(i32* null)
%47 = icmp sgt i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %45
br label %45
49: ; preds = %45
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%51 = load i32, i32* %50
%52 = call i32 @pollreader(i32 %51)
store i32 %52, i32* %9
%53 = load i32, i32* %9
%54 = load i32, i32* @EXIT_FAILURE
%55 = icmp eq i32 %53, %54
br i1 %55, label %56, label %59
56: ; preds = %49
%57 = load i32, i32* %9
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %49
%60 = load i32, i32* %9
%61 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%62 = icmp eq i32 %60, %61
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %70
65: ; preds = %59
br label %66
66: ; preds = %65
br label %69
67: ; preds = %35
%68 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %69
69: ; preds = %67, %66
br label %35
70: ; preds = %63
br label %120
71: ; preds = %31
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 1
%74 = load i8*, i8** %73
%75 = call i32* @fopen(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %75, i32** %10
%76 = load i32*, i32** %10
%77 = icmp eq i32* %76, null
br i1 %77, label %78, label %85
78: ; preds = %71
%79 = load i32, i32* @stderr
%80 = load i32, i32* @errno
%81 = call i8* @strerror(i32 %80)
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* %81)
%83 = load i32, i32* @EXIT_FAILURE
%84 = call i32 @exit(i32 %83)
unreachable
85: ; preds = %71
br label %86
86: ; preds = %116, %85
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%88 = load i32*, i32** %10
%89 = call i32* @fgets(i8* %87, i32 1024, i32* %88)
%90 = icmp ne i32* %89, null
br i1 %90, label %91, label %117
91: ; preds = %86
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%93 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%94 = call i32 @proccmd(i8* %92, i32* %93, i32 1)
br label %95
95: ; preds = %98, %91
%96 = call i64 @wait(i32* null)
%97 = icmp sgt i64 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %95
br label %95
99: ; preds = %95
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
%101 = load i32, i32* %100
%102 = call i32 @pollreader(i32 %101)
store i32 %102, i32* %12
%103 = load i32, i32* %12
%104 = load i32, i32* @EXIT_FAILURE
%105 = icmp eq i32 %103, %104
br i1 %105, label %106, label %109
106: ; preds = %99
%107 = load i32, i32* %12
%108 = call i32 @exit(i32 %107)
unreachable
109: ; preds = %99
%110 = load i32, i32* %12
%111 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%112 = icmp eq i32 %110, %111
br i1 %112, label %113, label %115
113: ; preds = %109
%114 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %117
115: ; preds = %109
br label %116
116: ; preds = %115
br label %86
117: ; preds = %113, %86
%118 = load i32*, i32** %10
%119 = call i32 @fclose(i32* %118)
br label %120
120: ; preds = %117, %70
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Error: Unexpected arg count\0A\00"
@.str.1 = [28 x i8] c"Usage: <shell> [batchFile]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [20 x i8] c"Error: Pipe failed\0A\00"
@.str.3 = [4 x i8] c">> \00"
@stdin = global i32* null
@.str.4 = [5 x i8] c"quit\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [31 x i8] c"Error: Unable to open file\0A%s\0A\00"
@errno = global i32 0
@str.9 = [27 x i8] c"How did you make that null\00"
@str.10 = [12 x i8] c"\0AExiting...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [2 x i32]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = icmp sgt i32 %0, 2
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = bitcast [2 x i32]* %4 to i8*
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%17 = call i64 @pipe(i32* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %14
%25 = icmp eq i32 %0, 1
br i1 %25, label %26, label %51
26: ; preds = %24, %46
%27 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32*, i32** @stdin
%29 = call i32* @fgets(i8* %5, i32 1024, i32* %28)
%30 = icmp eq i32* %29, null
br i1 %30, label %49, label %31
31: ; preds = %26
%32 = call i32 @proccmd(i8* %5, i32* %16, i32 0)
br label %33
33: ; preds = %33, %31
%34 = call i64 @wait(i32* null)
%35 = icmp sgt i64 %34, 0
br i1 %35, label %33, label %36
36: ; preds = %33
%37 = load i32, i32* %16
%38 = call i32 @pollreader(i32 %37)
%39 = load i32, i32* @EXIT_FAILURE
%40 = icmp eq i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 @exit(i32 %38)
unreachable
43: ; preds = %36
%44 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%45 = icmp eq i32 %38, %44
br i1 %45, label %47, label %46
46: ; preds = %43, %49
br label %26
47: ; preds = %43
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0))
br label %85
49: ; preds = %26
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
br label %46
51: ; preds = %24
%52 = getelementptr inbounds i8*, i8** %1, i64 1
%53 = load i8*, i8** %52
%54 = call i32* @fopen(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %63
56: ; preds = %51
%57 = load i32, i32* @stderr
%58 = load i32, i32* @errno
%59 = call i8* @strerror(i32 %58)
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i8* %59)
%61 = load i32, i32* @EXIT_FAILURE
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %51, %78
%64 = call i32* @fgets(i8* %5, i32 1024, i32* %54)
%65 = icmp eq i32* %64, null
br i1 %65, label %83, label %66
66: ; preds = %63
%67 = call i32 @proccmd(i8* %5, i32* %16, i32 1)
br label %68
68: ; preds = %68, %66
%69 = call i64 @wait(i32* null)
%70 = icmp sgt i64 %69, 0
br i1 %70, label %68, label %71
71: ; preds = %68
%72 = load i32, i32* %16
%73 = call i32 @pollreader(i32 %72)
%74 = load i32, i32* @EXIT_FAILURE
%75 = icmp eq i32 %73, %74
br i1 %75, label %76, label %78
76: ; preds = %71
%77 = call i32 @exit(i32 %73)
unreachable
78: ; preds = %71
%79 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%80 = icmp eq i32 %73, %79
br i1 %80, label %81, label %63
81: ; preds = %78
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0))
br label %83
83: ; preds = %63, %81
%84 = call i32 @fclose(i32* %54)
br label %85
85: ; preds = %47, %83
ret i32 0
}