#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;

/* Variables and functions */
scalar_t__ EINTR;
scalar_t__ MM_OK;
int STDERR_FILENO;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ close(int);
int dup2(int, int);
int /*<<< orphan*/ err(int, char *);
scalar_t__ errno;
scalar_t__ fmtmsg(long, char const *, int, char const *, char const *,
                  char const *);
int fork();
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int /*<<< orphan*/ *memchr(char *, char, int);
int pipe(int *);
int read(int, char *, int);
char *realloc(char *, size_t);
int waitpid(int, int *, int /*<<< orphan*/);
char *run_test(long classification, const char *label, int severity,
               const char *text, const char *action, const char *tag) {
  int pip[2];
  pid_t pid, wpid;
  char *result, *p;
  size_t resultsize;
  ssize_t n;
  int status;
  if (pipe(pip) == -1)
    err(2, "pipe");
  pid = fork();
  if (pid == -1)
    err(2, "fork");
  if (pid == 0) {
    close(pip[0]);
    if (pip[1] != STDERR_FILENO && dup2(pip[1], STDERR_FILENO) == -1)
      _exit(2);
    if (fmtmsg(classification, label, severity, text, action, tag) != MM_OK)
      _exit(1);
    else
      _exit(0);
  }
  close(pip[1]);
  resultsize = 1024;
  result = malloc(resultsize);
  p = result;
  while ((n = read(pip[0], p, result + resultsize - p - 1)) != 0) {
    if (n == -1) {
      if (errno == EINTR)
        continue;
      else
        err(2, "read");
    }
    p += n;
    if (result + resultsize == p - 1) {
      resultsize *= 2;
      result = realloc(result, resultsize);
      if (result == NULL)
        err(2, "realloc");
    }
  }
  if (memchr(result, '\0', p - result) != NULL) {
    free(result);
    return (NULL);
  }
  *p = '\0';
  close(pip[0]);
  while ((wpid = waitpid(pid, &status, 0)) == -1 && errno == EINTR)
    ;
  if (wpid == -1)
    err(2, "waitpid");
  if (status != 0) {
    free(result);
    return (NULL);
  }
  return (result);
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
lea    -0x40(%rbp),%rdi
call   1080 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1212 <run_test+0x42>
mov    $0x2,%edi
lea    0xdf3(%rip),%rsi
call   10b0 <err@plt>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    1237 <run_test+0x67>
mov    $0x2,%edi
lea    0xdd3(%rip),%rsi
call   10b0 <err@plt>
cmpl   $0x0,-0x44(%rbp)
jne    12bc <run_test+0xec>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
mov    -0x3c(%rbp),%eax
mov    0x2d85(%rip),%rcx
cmp    (%rcx),%eax
je     127f <run_test+0xaf>
mov    -0x3c(%rbp),%edi
mov    0x2d73(%rip),%rax
mov    (%rax),%esi
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    127f <run_test+0xaf>
mov    $0x2,%edi
call   1040 <_exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
call   1060 <fmtmsg@plt>
mov    0x2d1e(%rip),%rcx
cmp    (%rcx),%rax
je     12b5 <run_test+0xe5>
mov    $0x1,%edi
call   1040 <_exit@plt>
xor    %edi,%edi
call   1040 <_exit@plt>
mov    -0x3c(%rbp),%edi
call   1070 <close@plt>
movq   $0x400,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
call   10c0 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rax
add    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
sub    %rcx,%rax
sub    $0x1,%rax
mov    %eax,%edx
call   10a0 <read@plt>
mov    %eax,-0x64(%rbp)
cmp    $0x0,%eax
je     13ba <run_test+0x1ea>
cmpl   $0xffffffff,-0x64(%rbp)
jne    134d <run_test+0x17d>
mov    0x2cc1(%rip),%rax
mov    (%rax),%rax
mov    0x2ca7(%rip),%rcx
cmp    (%rcx),%rax
jne    1337 <run_test+0x167>
jmp    12e1 <run_test+0x111>
mov    $0x2,%edi
lea    0xcc7(%rip),%rsi
call   10b0 <err@plt>
jmp    134d <run_test+0x17d>
mov    -0x64(%rbp),%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rax
add    -0x60(%rbp),%rax
mov    -0x58(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
jne    13b5 <run_test+0x1e5>
mov    -0x60(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x60(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   10d0 <realloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13b0 <run_test+0x1e0>
mov    $0x2,%edi
lea    0xc64(%rip),%rsi
call   10b0 <err@plt>
jmp    13b5 <run_test+0x1e5>
jmp    12e1 <run_test+0x111>
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rax
mov    -0x50(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1090 <memchr@plt>
cmp    $0x0,%rax
je     13f2 <run_test+0x222>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1494 <run_test+0x2c4>
mov    -0x58(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
mov    -0x44(%rbp),%edi
lea    -0x68(%rbp),%rsi
xor    %edx,%edx
call   10e0 <waitpid@plt>
mov    %eax,%ecx
mov    %ecx,-0x48(%rbp)
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x69(%rbp)
jne    143c <run_test+0x26c>
mov    0x2bb7(%rip),%rax
mov    (%rax),%rax
mov    0x2b9d(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x69(%rbp)
mov    -0x69(%rbp),%al
test   $0x1,%al
jne    144c <run_test+0x27c>
jmp    1451 <run_test+0x281>
jmp    1401 <run_test+0x231>
cmpl   $0xffffffff,-0x48(%rbp)
jne    146c <run_test+0x29c>
mov    $0x2,%edi
lea    0xbb0(%rip),%rsi
call   10b0 <err@plt>
cmpl   $0x0,-0x68(%rbp)
je     148c <run_test+0x2bc>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1494 <run_test+0x2c4>
mov    -0x50(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%rbx
mov    %r8,%r15
mov    %rcx,%r12
mov    %edx,%r13d
mov    %rsi,%rbp
mov    %rdi,%r14
mov    %rsp,%rdi
call   1080 <pipe@plt>
cmp    $0xffffffff,%eax
jne    120e <run_test+0x3e>
lea    0xdfc(%rip),%rsi
mov    $0x2,%edi
call   10b0 <err@plt>
xor    %eax,%eax
call   10f0 <fork@plt>
cmp    $0xffffffff,%eax
mov    %eax,0x8(%rsp)
je     1257 <run_test+0x87>
test   %eax,%eax
jne    1268 <run_test+0x98>
mov    (%rsp),%edi
call   1070 <close@plt>
mov    0x4(%rsp),%edi
mov    0x2da3(%rip),%rax
mov    (%rax),%esi
cmp    %esi,%edi
je     13d3 <run_test+0x203>
call   1050 <dup2@plt>
cmp    $0xffffffff,%eax
jne    13d3 <run_test+0x203>
mov    $0x2,%edi
call   1040 <_exit@plt>
lea    0xda7(%rip),%rsi
mov    $0x2,%edi
call   10b0 <err@plt>
mov    0x4(%rsp),%edi
call   1070 <close@plt>
mov    $0x400,%ebp
mov    $0x400,%edi
call   10c0 <malloc@plt>
mov    0x2d59(%rip),%r15
mov    0x2d42(%rip),%r14
mov    %rax,%rbx
mov    %rax,0x10(%rsp)
mov    %rbp,0x18(%rsp)
add    %rbp,%rax
mov    %rax,0x20(%rsp)
mov    %rbx,%rbp
mov    %ebp,%r13d
not    %r13d
add    %eax,%r13d
nop
mov    (%rsp),%edi
mov    %rbp,%rsi
mov    %r13d,%edx
call   10a0 <read@plt>
mov    %eax,%r12d
cmp    $0xffffffff,%eax
jne    12f0 <run_test+0x120>
mov    (%r15),%rax
cmp    (%r14),%rax
je     12b0 <run_test+0xe0>
mov    $0x2,%edi
lea    0xd30(%rip),%rsi
call   10b0 <err@plt>
jmp    12f5 <run_test+0x125>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %r12d,%r12d
je     1346 <run_test+0x176>
movslq %r12d,%rax
lea    (%rax,%rbp,1),%rbx
add    %rbp,%rax
add    $0xffffffffffffffff,%rax
mov    0x20(%rsp),%rcx
cmp    %rax,%rcx
mov    %rcx,%rax
jne    12a3 <run_test+0xd3>
mov    0x18(%rsp),%rbp
add    %rbp,%rbp
mov    0x10(%rsp),%rdi
mov    %rbp,%rsi
call   10d0 <realloc@plt>
test   %rax,%rax
jne    1291 <run_test+0xc1>
mov    $0x2,%edi
lea    0xcd5(%rip),%rsi
call   10b0 <err@plt>
xor    %eax,%eax
jmp    1291 <run_test+0xc1>
mov    %ebp,%edx
mov    0x10(%rsp),%r12
sub    %r12d,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1090 <memchr@plt>
test   %rax,%rax
jne    13b6 <run_test+0x1e6>
movb   $0x0,0x0(%rbp)
mov    (%rsp),%edi
call   1070 <close@plt>
lea    0xc(%rsp),%rbp
mov    0x8(%rsp),%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
mov    %rbp,%rsi
xor    %edx,%edx
call   10e0 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    1399 <run_test+0x1c9>
mov    (%r14),%rcx
cmp    %rcx,(%r15)
je     1380 <run_test+0x1b0>
cmp    $0xffffffff,%eax
jne    13af <run_test+0x1df>
lea    0xc72(%rip),%rsi
mov    $0x2,%edi
call   10b0 <err@plt>
cmpl   $0x0,0xc(%rsp)
je     13c1 <run_test+0x1f1>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %r12d,%r12d
mov    %r12,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r13d,%edx
mov    %r12,%rcx
mov    %r15,%r8
mov    %rbx,%r9
call   1060 <fmtmsg@plt>
mov    0x2bcf(%rip),%rcx
cmp    (%rcx),%rax
jne    13fd <run_test+0x22d>
xor    %edi,%edi
call   1040 <_exit@plt>
mov    $0x1,%edi
call   1040 <_exit@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"pipe\00"
@.str.1 = [5 x i8] c"fork\00"
@STDERR_FILENO = global i32 0
@MM_OK = global i64 0
@errno = global i64 0
@EINTR = global i64 0
@.str.2 = [5 x i8] c"read\00"
@.str.3 = [8 x i8] c"realloc\00"
@.str.4 = [8 x i8] c"waitpid\00"
define i8* @run_test(i64 %0, i8* %1, i32 %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca [2 x i32]
%8 = alloca i32
%9 = bitcast [2 x i32]* %7 to i8*
%10 = bitcast i32* %8 to i8*
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%12 = call i32 @pipe(i32* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %6
%15 = call i32 @err(i32 2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %6
%17 = call i32 (...) @fork()
switch i32 %17, label %40 [
i32 -1, label %18
i32 0, label %20
]
18: ; preds = %16
%19 = call i32 @err(i32 2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %40
20: ; preds = %16
%21 = load i32, i32* %11
%22 = call i32 @close(i32 %21)
%23 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%24 = load i32, i32* %23
%25 = load i32, i32* @STDERR_FILENO
%26 = icmp eq i32 %24, %25
br i1 %26, label %32, label %27
27: ; preds = %20
%28 = call i32 @dup2(i32 %24, i32 %25)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @_exit(i32 2)
unreachable
32: ; preds = %27, %20
%33 = call i64 @fmtmsg(i64 %0, i8* %1, i32 %2, i8* %3, i8* %4, i8* %5)
%34 = load i64, i64* @MM_OK
%35 = icmp eq i64 %33, %34
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = call i32 @_exit(i32 1)
unreachable
38: ; preds = %32
%39 = call i32 @_exit(i32 0)
unreachable
40: ; preds = %18, %16
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%42 = load i32, i32* %41
%43 = call i32 @close(i32 %42)
%44 = call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
br label %45
45: ; preds = %77, %40
%46 = phi i8* [ %44, %40 ], [ %78, %77 ]
%47 = phi i8* [ %44, %40 ], [ %68, %77 ]
%48 = phi i64 [ 1024, %40 ], [ %72, %77 ]
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = ptrtoint i8* %49 to i64
br label %51
51: ; preds = %45, %66
%52 = phi i8* [ %68, %66 ], [ %47, %45 ]
%53 = ptrtoint i8* %52 to i64
%54 = xor i64 %53, -1
%55 = add i64 %50, %54
%56 = trunc i64 %55 to i32
br label %57
57: ; preds = %51, %60
%58 = load i32, i32* %11
%59 = call i32 @read(i32 %58, i8* %52, i32 %56)
switch i32 %59, label %66 [
i32 0, label %79
i32 -1, label %60
]
60: ; preds = %57
%61 = load i64, i64* @errno
%62 = load i64, i64* @EINTR
%63 = icmp eq i64 %61, %62
br i1 %63, label %57, label %64
64: ; preds = %60
%65 = call i32 @err(i32 2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %66
66: ; preds = %57, %64
%67 = sext i32 %59 to i64
%68 = getelementptr inbounds i8, i8* %52, i64 %67
%69 = getelementptr inbounds i8, i8* %68, i64 -1
%70 = icmp eq i8* %49, %69
br i1 %70, label %71, label %51
71: ; preds = %66
%72 = shl i64 %48, 1
%73 = call i8* @realloc(i8* %46, i64 %72)
%74 = icmp eq i8* %73, null
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = call i32 @err(i32 2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %77
77: ; preds = %75, %71
%78 = phi i8* [ %73, %71 ], [ null, %75 ]
br label %45
79: ; preds = %57
%80 = ptrtoint i8* %52 to i64
%81 = ptrtoint i8* %46 to i64
%82 = sub i64 %80, %81
%83 = trunc i64 %82 to i32
%84 = call i32* @memchr(i8* %46, i8 signext 0, i32 %83)
%85 = icmp eq i32* %84, null
br i1 %85, label %86, label %102
86: ; preds = %79
store i8 0, i8* %52
%87 = load i32, i32* %11
%88 = call i32 @close(i32 %87)
br label %89
89: ; preds = %89, %86
%90 = call i32 @waitpid(i32 %17, i32* %8, i32 0)
%91 = icmp eq i32 %90, -1
%92 = load i64, i64* @errno
%93 = load i64, i64* @EINTR
%94 = icmp eq i64 %92, %93
%95 = select i1 %91, i1 %94, i1 false
br i1 %95, label %89, label %96
96: ; preds = %89
br i1 %91, label %97, label %99
97: ; preds = %96
%98 = call i32 @err(i32 2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %99
99: ; preds = %97, %96
%100 = load i32, i32* %8
%101 = icmp eq i32 %100, 0
br i1 %101, label %104, label %102
102: ; preds = %99, %79
%103 = call i32 @free(i8* %46)
br label %104
104: ; preds = %102, %99
%105 = phi i8* [ %46, %99 ], [ null, %102 ]
ret i8* %105
}