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

/* Variables and functions */
int BUFSIZ;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
int /*<<< orphan*/ WTERMSIG(int);
int /*<<< orphan*/ close(int);
scalar_t__ dup2(int, int /*<<< orphan*/);
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
int /*<<< orphan*/ raise(int /*<<< orphan*/);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin_to_stream(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int waitpid(int, int *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  ssize_t r;
  int run_if_empty;
  char **argv_exec;
  int fds[2];
  int child_status;
  pid_t child_pid;
  char buf[BUFSIZ];
  FILE *outf;
  if ((argc < 2) || ((argc == 2) && (!strcmp((argv[1]), ("-n"))))) {
    fprintf(stderr, "Usage: ifne [-n] command [args]\n");
    return EXIT_FAILURE;
  }
  if ((!strcmp((argv[1]), ("-n")))) {
    run_if_empty = 1;
    argv_exec = &argv[2];
  } else {
    run_if_empty = 0;
    argv_exec = &argv[1];
  }
  r = read(0, buf, BUFSIZ * sizeof(char));
  if ((r == 0) && !run_if_empty)
    return EXIT_SUCCESS;
  else if (r == -1) {
    perror("read");
    return EXIT_FAILURE;
  }
  if (pipe(fds)) {
    perror("pipe");
    return EXIT_FAILURE;
  }
  if (r && run_if_empty) {
    stdin_to_stream(buf, r, stdout);
    return EXIT_SUCCESS;
  }
  child_pid = fork();
  if (!child_pid) {
    close(fds[1]);
    if (dup2(fds[0], 0)) {
      perror("dup2");
      return EXIT_FAILURE;
    }
    execvp(*argv_exec, argv_exec);
    perror(*argv_exec);
    close(fds[0]);
    return EXIT_FAILURE;
  } else if (child_pid == -1) {
    perror("fork");
    return EXIT_FAILURE;
  }
  close(fds[0]);
  outf = fdopen(fds[1], "w");
  if (!outf) {
    perror("fdopen");
    exit(1);
  }
  stdin_to_stream(buf, r, outf);
  fclose(outf);
  if (waitpid(child_pid, &child_status, 0) != child_pid) {
    perror("waitpid");
    return EXIT_FAILURE;
  }
  if (WIFEXITED(child_status)) {
    return (WEXITSTATUS(child_status));
  } else if (WIFSIGNALED(child_status)) {
    raise(WTERMSIG(child_status));
    return EXIT_FAILURE;
  }
  return EXIT_FAILURE;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     12a3 <main+0x73>
cmpl   $0x2,-0x8(%rbp)
jne    12d0 <main+0xa0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd6b(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    12d0 <main+0xa0>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xd50(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd21(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1305 <main+0xd5>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x20(%rbp)
jmp    1318 <main+0xe8>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x58(%rbp),%rsi
mov    0x2cb5(%rip),%rax
movslq (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edx
xor    %edi,%edi
call   1080 <read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1362 <main+0x132>
cmpl   $0x0,-0x18(%rbp)
jne    1362 <main+0x132>
mov    0x2c6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
cmpl   $0xffffffff,-0x14(%rbp)
jne    1390 <main+0x160>
lea    0xcb1(%rip),%rdi
call   1100 <perror@plt>
mov    0x2c51(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
jmp    1395 <main+0x165>
lea    -0x28(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
je     13cc <main+0x19c>
lea    0xc7a(%rip),%rdi
call   1100 <perror@plt>
mov    0x2c15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
cmpl   $0x0,-0x14(%rbp)
je     140e <main+0x1de>
cmpl   $0x0,-0x18(%rbp)
je     140e <main+0x1de>
mov    -0x58(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    0x2bda(%rip),%rax
mov    (%rax),%rdx
call   1140 <stdin_to_stream@plt>
mov    0x2bc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
mov    $0x0,%al
call   1150 <fork@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    149e <main+0x26e>
mov    -0x24(%rbp),%edi
call   1060 <close@plt>
mov    -0x28(%rbp),%edi
xor    %esi,%esi
call   1050 <dup2@plt>
cmp    $0x0,%rax
je     1462 <main+0x232>
lea    0xbe9(%rip),%rdi
call   1100 <perror@plt>
mov    0x2b7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%rsi
call   1110 <execvp@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1100 <perror@plt>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    0x2b43(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
cmpl   $0xffffffff,-0x30(%rbp)
jne    14cc <main+0x29c>
lea    0xb84(%rip),%rdi
call   1100 <perror@plt>
mov    0x2b15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
jmp    14d1 <main+0x2a1>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x24(%rbp),%edi
lea    0xb55(%rip),%rsi
call   10d0 <fdopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    150d <main+0x2dd>
lea    0xb3c(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x58(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x48(%rbp),%rdx
call   1140 <stdin_to_stream@plt>
mov    -0x48(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%edi
lea    -0x2c(%rbp),%rsi
xor    %edx,%edx
call   10f0 <waitpid@plt>
cmp    -0x30(%rbp),%eax
je     1561 <main+0x331>
lea    0xafd(%rip),%rdi
call   1100 <perror@plt>
mov    0x2a80(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
mov    -0x2c(%rbp),%edi
call   1120 <WIFEXITED@plt>
cmp    $0x0,%rax
je     158a <main+0x35a>
mov    -0x2c(%rbp),%edi
call   10e0 <WEXITSTATUS@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
mov    -0x2c(%rbp),%edi
call   1090 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     15c3 <main+0x393>
mov    -0x2c(%rbp),%edi
call   10c0 <WTERMSIG@plt>
mov    %eax,%edi
call   1030 <raise@plt>
mov    0x2a1e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    15db <main+0x3ab>
jmp    15c8 <main+0x398>
mov    0x2a01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsp,%r12
mov    0x2d8d(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmp    $0x2,%edi
jge    1288 <main+0x58>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
lea    0xd8e(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%eax
jmp    1322 <main+0xf2>
mov    %rsi,%r14
mov    0x8(%rsi),%r15
jne    12a4 <main+0x74>
lea    0xd68(%rip),%rsi
mov    %r15,%rdi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     1265 <main+0x35>
mov    %r12,-0x38(%rbp)
lea    0xd51(%rip),%rsi
mov    %r15,%rdi
call   10a0 <strcmp@plt>
mov    %eax,%r12d
test   %eax,%eax
sete   -0x29(%rbp)
mov    0x0(%r13),%edx
xor    %edi,%edi
mov    %rbx,%rsi
call   1080 <read@plt>
mov    %eax,%r15d
test   %eax,%eax
jne    12da <main+0xaa>
test   %r12d,%r12d
jne    1315 <main+0xe5>
cmp    $0xffffffff,%r15d
je     13df <main+0x1af>
lea    -0x44(%rbp),%rdi
call   1070 <pipe@plt>
test   %rax,%rax
jne    13e8 <main+0x1b8>
test   %r15d,%r15d
je     1334 <main+0x104>
test   %r12d,%r12d
jne    1334 <main+0x104>
mov    0x2cc1(%rip),%rax
mov    (%rax),%rdx
mov    %rbx,%rdi
mov    %r15d,%esi
call   1140 <stdin_to_stream@plt>
mov    0x2ca4(%rip),%rax
mov    (%rax),%eax
mov    -0x38(%rbp),%r12
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1150 <fork@plt>
cmp    $0xffffffff,%eax
je     13f1 <main+0x1c1>
mov    %eax,%r12d
test   %eax,%eax
je     13fa <main+0x1ca>
mov    -0x44(%rbp),%edi
call   1060 <close@plt>
mov    -0x40(%rbp),%edi
lea    0xcd7(%rip),%rsi
call   10d0 <fdopen@plt>
test   %rax,%rax
je     146d <main+0x23d>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %rax,%rdx
call   1140 <stdin_to_stream@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    -0x3c(%rbp),%rsi
mov    %r12d,%edi
xor    %edx,%edx
call   10f0 <waitpid@plt>
cmp    %r12d,%eax
jne    1444 <main+0x214>
mov    -0x3c(%rbp),%edi
call   1120 <WIFEXITED@plt>
mov    -0x3c(%rbp),%edi
test   %rax,%rax
mov    -0x38(%rbp),%r12
je     13bd <main+0x18d>
call   10e0 <WEXITSTATUS@plt>
jmp    1322 <main+0xf2>
call   1090 <WIFSIGNALED@plt>
test   %rax,%rax
je     127a <main+0x4a>
mov    -0x3c(%rbp),%edi
call   10c0 <WTERMSIG@plt>
mov    %eax,%edi
call   1030 <raise@plt>
jmp    127a <main+0x4a>
lea    0xc3e(%rip),%rdi
jmp    144b <main+0x21b>
lea    0xc3a(%rip),%rdi
jmp    144b <main+0x21b>
lea    0xc3b(%rip),%rdi
jmp    144b <main+0x21b>
mov    -0x40(%rbp),%edi
call   1060 <close@plt>
mov    -0x44(%rbp),%edi
xor    %esi,%esi
call   1050 <dup2@plt>
test   %rax,%rax
mov    -0x38(%rbp),%r12
jne    145c <main+0x22c>
xor    %eax,%eax
mov    -0x29(%rbp),%cl
mov    %cl,%al
lea    (%r14,%rax,8),%rbx
add    $0x8,%rbx
mov    (%rbx),%rdi
mov    %rbx,%rsi
call   1110 <execvp@plt>
mov    (%rbx),%rdi
call   1100 <perror@plt>
mov    -0x44(%rbp),%edi
call   1060 <close@plt>
jmp    127a <main+0x4a>
lea    0xbf6(%rip),%rdi
call   1100 <perror@plt>
mov    0x2b79(%rip),%rax
jmp    131c <main+0xec>
lea    0xbcb(%rip),%rdi
call   1100 <perror@plt>
jmp    127a <main+0x4a>
lea    0xbc6(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>

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

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [3 x i8] c"-n\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Usage: ifne [-n] command [args]\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.2 = [5 x i8] c"read\00"
@.str.3 = [5 x i8] c"pipe\00"
@stdout = global i32* null
@.str.4 = [5 x i8] c"dup2\00"
@.str.5 = [5 x i8] c"fork\00"
@.str.6 = [2 x i8] c"w\00"
@.str.7 = [7 x i8] c"fdopen\00"
@.str.8 = [8 x i8] c"waitpid\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = bitcast [2 x i32]* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* @BUFSIZ
%8 = zext i32 %7 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i8, i64 %8
%11 = icmp slt i32 %0, 2
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = icmp eq i32 %0, 2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
br i1 %13, label %16, label %23
16: ; preds = %12
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16, %2
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
br label %110
23: ; preds = %12, %16
%24 = tail call i32 @strcmp(i8* dereferenceable(1) %15, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i64 2, i64 1
%27 = getelementptr inbounds i8*, i8** %1, i64 %26
%28 = load i32, i32* @BUFSIZ
%29 = call i32 @read(i32 0, i8* %10, i32 %28)
%30 = icmp ne i32 %29, 0
%31 = select i1 %30, i1 true, i1 %25
br i1 %31, label %34, label %32
32: ; preds = %23
%33 = load i32, i32* @EXIT_SUCCESS
br label %110
34: ; preds = %23
%35 = icmp eq i32 %29, -1
br i1 %35, label %36, label %39
36: ; preds = %34
%37 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32, i32* @EXIT_FAILURE
br label %110
39: ; preds = %34
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%41 = call i64 @pipe(i32* %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %39
%44 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
br label %110
46: ; preds = %39
%47 = select i1 %30, i1 %25, i1 false
br i1 %47, label %48, label %52
48: ; preds = %46
%49 = load i32*, i32** @stdout
%50 = call i32 @stdin_to_stream(i8* %10, i32 %29, i32* %49)
%51 = load i32, i32* @EXIT_SUCCESS
br label %110
52: ; preds = %46
%53 = call i32 (...) @fork()
switch i32 %53, label %75 [
i32 0, label %54
i32 -1, label %72
]
54: ; preds = %52
%55 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%56 = load i32, i32* %55
%57 = call i32 @close(i32 %56)
%58 = load i32, i32* %40
%59 = call i64 @dup2(i32 %58, i32 0)
%60 = icmp eq i64 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %54
%62 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%63 = load i32, i32* @EXIT_FAILURE
br label %110
64: ; preds = %54
%65 = load i8*, i8** %27
%66 = call i32 @execvp(i8* %65, i8** %27)
%67 = load i8*, i8** %27
%68 = call i32 @perror(i8* %67)
%69 = load i32, i32* %40
%70 = call i32 @close(i32 %69)
%71 = load i32, i32* @EXIT_FAILURE
br label %110
72: ; preds = %52
%73 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%74 = load i32, i32* @EXIT_FAILURE
br label %110
75: ; preds = %52
%76 = load i32, i32* %40
%77 = call i32 @close(i32 %76)
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%79 = load i32, i32* %78
%80 = call i32* @fdopen(i32 %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%81 = icmp eq i32* %80, null
br i1 %81, label %82, label %85
82: ; preds = %75
%83 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %75
%86 = call i32 @stdin_to_stream(i8* %10, i32 %29, i32* %80)
%87 = call i32 @fclose(i32* %80)
%88 = call i32 @waitpid(i32 %53, i32* %4, i32 0)
%89 = icmp eq i32 %88, %53
br i1 %89, label %93, label %90
90: ; preds = %85
%91 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
br label %110
93: ; preds = %85
%94 = load i32, i32* %4
%95 = call i64 @WIFEXITED(i32 %94)
%96 = icmp eq i64 %95, 0
%97 = load i32, i32* %4
br i1 %96, label %100, label %98
98: ; preds = %93
%99 = call i32 @WEXITSTATUS(i32 %97)
br label %110
100: ; preds = %93
%101 = call i64 @WIFSIGNALED(i32 %97)
%102 = icmp eq i64 %101, 0
br i1 %102, label %108, label %103
103: ; preds = %100
%104 = load i32, i32* %4
%105 = call i32 @WTERMSIG(i32 %104)
%106 = call i32 @raise(i32 %105)
%107 = load i32, i32* @EXIT_FAILURE
br label %110
108: ; preds = %100
%109 = load i32, i32* @EXIT_FAILURE
br label %110
110: ; preds = %108, %103, %98, %90, %72, %64, %61, %48, %43, %36, %32, %19
%111 = phi i32 [ %22, %19 ], [ %38, %36 ], [ %45, %43 ], [ %51, %48 ], [ %74, %72 ], [ %92, %90 ], [ %99, %98 ], [ %107, %103 ], [ %109, %108 ], [ %63, %61 ], [ %71, %64 ], [ %33, %32 ]
ret i32 %111
}