#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*/ tc;
struct termios {
  int c_lflag;
  int *c_cc;
};
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int ECHO;
int ICANON;
int /*<<< orphan*/ SHUT_WR;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ dup2(int, int);
scalar_t__ fork();
scalar_t__ isatty(int);
int /*<<< orphan*/ memset(struct termios *, int /*<<< orphan*/, int);
int read(int, char *, int);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int /*<<< orphan*/ shuttle(int, char const *);
int socketpair(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
               int *);
int tcgetattr(int, struct termios *);
int tcsetattr(int /*<<< orphan*/, int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ wait(int *);
int /*<<< orphan*/ write(int, char *, int);
int lned_run(int argc, char **argv, const char *prompt,
             int (*worker)(int, char **)) {
  struct termios tc[4];
  struct termios *t;
  char cb[8];
  int sp[2] = {-1, -1};
  int i;
  int res;
  int st;
  pid_t pid;
  memset(tc, 0, sizeof(tc));
  for (i = 0; i < 3; i++) {
    res = tcgetattr(i, &(tc[i]));
    if (res < 0 && i < 2)
      goto Direct;
  }
  res = socketpair(AF_UNIX, SOCK_STREAM, 0, sp);
  if (res < 0)
    goto Direct;
  t = &(tc[3]);
  *t = tc[0];
  t->c_lflag &= ~(ECHO | ICANON);
  t->c_cc[VMIN] = 1;
  t->c_cc[VTIME] = 0;
  res = tcsetattr(0, TCSANOW, t);
  if (res < 0)
    goto Direct;
  pid = fork();
  if (pid == 0) {
    dup2(sp[1], 0);
    dup2(sp[1], 1);
    if (isatty(2))
      dup2(sp[1], 2);
    close(sp[0]);
    close(sp[1]);
    goto Direct;
  }
  close(sp[1]);
  dup2(1, 2);
  shuttle(sp[0], prompt);
  shutdown(sp[0], SHUT_WR);
  while (read(sp[0], cb, 1) == 1)
    write(1, cb, 1);
  wait(&st);
  tcsetattr(0, TCSANOW, &(tc[0]));
  return (st);
Direct:
  return (worker(argc, argv));
}


x86 assembly (clang, -O0):
<lned_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0xe0f(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1080 <memset@plt>
movl   $0x0,-0x7c(%rbp)
cmpl   $0x3,-0x7c(%rbp)
jge    125c <lned_run+0x8c>
mov    -0x7c(%rbp),%edi
movslq -0x7c(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x4,%rax
add    %rax,%rsi
call   10c0 <tcgetattr@plt>
mov    %eax,-0x80(%rbp)
cmpl   $0x0,-0x80(%rbp)
jge    1249 <lned_run+0x79>
cmpl   $0x2,-0x7c(%rbp)
jge    1249 <lned_run+0x79>
jmp    1419 <lned_run+0x249>
jmp    124e <lned_run+0x7e>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    120c <lned_run+0x3c>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
mov    0x2d4c(%rip),%rax
mov    (%rax),%esi
lea    -0x78(%rbp),%rcx
xor    %edx,%edx
call   10b0 <socketpair@plt>
mov    %eax,-0x80(%rbp)
cmpl   $0x0,-0x80(%rbp)
jge    128b <lned_run+0xbb>
jmp    1419 <lned_run+0x249>
lea    -0x60(%rbp),%rax
add    $0x30,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    %rcx,(%rax)
mov    -0x58(%rbp),%rcx
mov    %rcx,0x8(%rax)
mov    0x2d1f(%rip),%rax
mov    (%rax),%ecx
mov    0x2cee(%rip),%rax
or     (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x68(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2cf2(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2cc1(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2cd8(%rip),%rax
mov    (%rax),%esi
mov    -0x68(%rbp),%rdx
xor    %edi,%edi
call   10d0 <tcsetattr@plt>
mov    %eax,-0x80(%rbp)
cmpl   $0x0,-0x80(%rbp)
jge    131f <lned_run+0x14f>
jmp    1419 <lned_run+0x249>
mov    $0x0,%al
call   10f0 <fork@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
jne    1388 <lned_run+0x1b8>
mov    -0x74(%rbp),%edi
xor    %esi,%esi
call   1070 <dup2@plt>
mov    -0x74(%rbp),%edi
mov    $0x1,%esi
call   1070 <dup2@plt>
mov    $0x2,%edi
call   1040 <isatty@plt>
cmp    $0x0,%rax
je     1373 <lned_run+0x1a3>
mov    -0x74(%rbp),%edi
mov    $0x2,%esi
call   1070 <dup2@plt>
mov    -0x78(%rbp),%edi
call   1090 <close@plt>
mov    -0x74(%rbp),%edi
call   1090 <close@plt>
jmp    1419 <lned_run+0x249>
mov    -0x74(%rbp),%edi
call   1090 <close@plt>
mov    $0x1,%edi
mov    $0x2,%esi
call   1070 <dup2@plt>
mov    -0x78(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1030 <shuttle@plt>
mov    -0x78(%rbp),%edi
mov    0x2c33(%rip),%rax
mov    (%rax),%esi
call   1060 <shutdown@plt>
mov    -0x78(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
cmp    $0x1,%eax
jne    13eb <lned_run+0x21b>
lea    -0x70(%rbp),%rsi
mov    $0x1,%edx
mov    %edx,%edi
call   1050 <write@plt>
jmp    13bc <lned_run+0x1ec>
lea    -0x84(%rbp),%rdi
call   10e0 <wait@plt>
mov    0x2bda(%rip),%rax
mov    (%rax),%esi
lea    -0x60(%rbp),%rdx
xor    %edi,%edi
call   10d0 <tcsetattr@plt>
mov    -0x84(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1429 <lned_run+0x259>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   *%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lned_run>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %edi,%ebp
movq   $0xffffffffffffffff,0x8(%rsp)
ff ff
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1080 <memset@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <tcgetattr@plt>
test   %eax,%eax
js     13bc <lned_run+0x1ec>
lea    0x30(%rsp),%rsi
mov    $0x1,%edi
call   10c0 <tcgetattr@plt>
test   %eax,%eax
js     13bc <lned_run+0x1ec>
lea    0x40(%rsp),%rsi
mov    $0x2,%edi
call   10c0 <tcgetattr@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
mov    0x2d6a(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rcx
xor    %edx,%edx
call   10b0 <socketpair@plt>
test   %eax,%eax
js     13bc <lned_run+0x1ec>
lea    0x50(%rsp),%rdx
movaps 0x20(%rsp),%xmm0
movaps %xmm0,0x50(%rsp)
mov    0x2d56(%rip),%rax
mov    0x2d27(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
not    %ecx
and    %ecx,0x50(%rsp)
mov    0x58(%rsp),%rax
mov    0x2d31(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2d08(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2d1f(%rip),%r13
mov    0x0(%r13),%esi
xor    %edi,%edi
call   10d0 <tcsetattr@plt>
test   %eax,%eax
js     13bc <lned_run+0x1ec>
xor    %eax,%eax
call   10f0 <fork@plt>
mov    0xc(%rsp),%edi
test   %rax,%rax
je     1378 <lned_run+0x1a8>
call   1090 <close@plt>
mov    $0x1,%edi
mov    $0x2,%esi
call   1070 <dup2@plt>
mov    0x8(%rsp),%edi
mov    %r15,%rsi
call   1030 <shuttle@plt>
mov    0x8(%rsp),%edi
mov    0x2cdd(%rip),%rax
mov    (%rax),%esi
call   1060 <shutdown@plt>
mov    0x8(%rsp),%edi
lea    0x18(%rsp),%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
cmp    $0x1,%eax
jne    1358 <lned_run+0x188>
lea    0x18(%rsp),%rbx
nop
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
cmp    $0x1,%eax
je     1330 <lned_run+0x160>
lea    0x14(%rsp),%rdi
call   10e0 <wait@plt>
mov    0x0(%r13),%esi
lea    0x20(%rsp),%rdx
xor    %edi,%edi
call   10d0 <tcsetattr@plt>
mov    0x14(%rsp),%eax
jmp    13c4 <lned_run+0x1f4>
xor    %esi,%esi
call   1070 <dup2@plt>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
call   1070 <dup2@plt>
mov    $0x2,%edi
call   1040 <isatty@plt>
test   %rax,%rax
je     13aa <lned_run+0x1da>
mov    0xc(%rsp),%edi
mov    $0x2,%esi
call   1070 <dup2@plt>
mov    0x8(%rsp),%edi
call   1090 <close@plt>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    %ebp,%edi
mov    %r12,%rsi
call   *%r14
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32* }
@__const.lned_run.sp = [2 x i32] [i32 -1, i32 -1]
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@ECHO = global i32 0
@ICANON = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
@SHUT_WR = global i32 0
define i32 @lned_run(i32 %0, i8** %1, i8* %2, i32 (i32, i8**)* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i32 (i32, i8**)*
%10 = alloca [4 x %struct.termios]
%11 = alloca %struct.termios*
%12 = alloca [8 x i8]
%13 = alloca [2 x i32]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i64
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8* %2, i8** %8
store i32 (i32, i8**)* %3, i32 (i32, i8**)** %9
%18 = bitcast [2 x i32]* %13 to i8*
%19 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %10, i64 0, i64 0
%20 = call i32 @memset(%struct.termios* %19, i32 0, i32 64)
store i32 0, i32* %14
br label %21
21: ; preds = %37, %4
%22 = load i32, i32* %14
%23 = icmp slt i32 %22, 3
br i1 %23, label %24, label %40
24: ; preds = %21
%25 = load i32, i32* %14
%26 = load i32, i32* %14
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %10, i64 0, i64 %27
%29 = call i32 @tcgetattr(i32 %25, %struct.termios* %28)
store i32 %29, i32* %15
%30 = load i32, i32* %15
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %24
%33 = load i32, i32* %14
%34 = icmp slt i32 %33, 2
br i1 %34, label %35, label %36
35: ; preds = %32
br label %130
36: ; preds = %32, %24
br label %37
37: ; preds = %36
%38 = load i32, i32* %14
%39 = add nsw i32 %38, 1
store i32 %39, i32* %14
br label %21
40: ; preds = %21
%41 = load i32, i32* @AF_UNIX
%42 = load i32, i32* @SOCK_STREAM
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%44 = call i32 @socketpair(i32 %41, i32 %42, i32 0, i32* %43)
store i32 %44, i32* %15
%45 = load i32, i32* %15
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %40
br label %130
48: ; preds = %40
%49 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %10, i64 0, i64 3
store %struct.termios* %49, %struct.termios** %11
%50 = load %struct.termios*, %struct.termios** %11
%51 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %10, i64 0, i64 0
%52 = bitcast %struct.termios* %50 to i8*
%53 = bitcast %struct.termios* %51 to i8*
%54 = load i32, i32* @ECHO
%55 = load i32, i32* @ICANON
%56 = or i32 %54, %55
%57 = xor i32 %56, -1
%58 = load %struct.termios*, %struct.termios** %11
%59 = getelementptr inbounds %struct.termios, %struct.termios* %58, i32 0, i32 0
%60 = load i32, i32* %59
%61 = and i32 %60, %57
store i32 %61, i32* %59
%62 = load %struct.termios*, %struct.termios** %11
%63 = getelementptr inbounds %struct.termios, %struct.termios* %62, i32 0, i32 1
%64 = load i32*, i32** %63
%65 = load i64, i64* @VMIN
%66 = getelementptr inbounds i32, i32* %64, i64 %65
store i32 1, i32* %66
%67 = load %struct.termios*, %struct.termios** %11
%68 = getelementptr inbounds %struct.termios, %struct.termios* %67, i32 0, i32 1
%69 = load i32*, i32** %68
%70 = load i64, i64* @VTIME
%71 = getelementptr inbounds i32, i32* %69, i64 %70
store i32 0, i32* %71
%72 = load i32, i32* @TCSANOW
%73 = load %struct.termios*, %struct.termios** %11
%74 = call i32 @tcsetattr(i32 0, i32 %72, %struct.termios* %73)
store i32 %74, i32* %15
%75 = load i32, i32* %15
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %78
77: ; preds = %48
br label %130
78: ; preds = %48
%79 = call i64 (...) @fork()
store i64 %79, i64* %17
%80 = load i64, i64* %17
%81 = icmp eq i64 %80, 0
br i1 %81, label %82, label %102
82: ; preds = %78
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%84 = load i32, i32* %83
%85 = call i32 @dup2(i32 %84, i32 0)
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%87 = load i32, i32* %86
%88 = call i32 @dup2(i32 %87, i32 1)
%89 = call i64 @isatty(i32 2)
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %95
91: ; preds = %82
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%93 = load i32, i32* %92
%94 = call i32 @dup2(i32 %93, i32 2)
br label %95
95: ; preds = %91, %82
%96 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%97 = load i32, i32* %96
%98 = call i32 @close(i32 %97)
%99 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%100 = load i32, i32* %99
%101 = call i32 @close(i32 %100)
br label %130
102: ; preds = %78
%103 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
%104 = load i32, i32* %103
%105 = call i32 @close(i32 %104)
%106 = call i32 @dup2(i32 1, i32 2)
%107 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%108 = load i32, i32* %107
%109 = load i8*, i8** %8
%110 = call i32 @shuttle(i32 %108, i8* %109)
%111 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%112 = load i32, i32* %111
%113 = load i32, i32* @SHUT_WR
%114 = call i32 @shutdown(i32 %112, i32 %113)
br label %115
115: ; preds = %121, %102
%116 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%117 = load i32, i32* %116
%118 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%119 = call i32 @read(i32 %117, i8* %118, i32 1)
%120 = icmp eq i32 %119, 1
br i1 %120, label %121, label %124
121: ; preds = %115
%122 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%123 = call i32 @write(i32 1, i8* %122, i32 1)
br label %115
124: ; preds = %115
%125 = call i32 @wait(i32* %16)
%126 = load i32, i32* @TCSANOW
%127 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %10, i64 0, i64 0
%128 = call i32 @tcsetattr(i32 0, i32 %126, %struct.termios* %127)
%129 = load i32, i32* %16
store i32 %129, i32* %5
br label %135
130: ; preds = %95, %77, %47, %35
%131 = load i32 (i32, i8**)*, i32 (i32, i8**)** %9
%132 = load i32, i32* %6
%133 = load i8**, i8*** %7
%134 = call i32 %131(i32 %132, i8** %133)
store i32 %134, i32* %5
br label %135
135: ; preds = %130, %124
%136 = load i32, i32* %5
ret i32 %136
}

LLVM IR (-O2):
%struct.termios = type { i32, i32* }
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@ECHO = global i32 0
@ICANON = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
@SHUT_WR = global i32 0
define i32 @lned_run(i32 %0, i8** %1, i8* %2, i32 (i32, i8**)* nocapture %3) {
%5 = alloca [4 x %struct.termios]
%6 = alloca [8 x i8]
%7 = alloca i64
%8 = bitcast i64* %7 to [2 x i32]*
%9 = alloca i32
%10 = bitcast [4 x %struct.termios]* %5 to i8*
%11 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%12 = bitcast i64* %7 to i8*
store i64 -1, i64* %7
%13 = bitcast i32* %9 to i8*
%14 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %5, i64 0, i64 0
%15 = call i32 @memset(%struct.termios* %14, i32 0, i32 64)
%16 = call i32 @tcgetattr(i32 0, %struct.termios* %14)
%17 = icmp slt i32 %16, 0
br i1 %17, label %89, label %18
18: ; preds = %4
%19 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %5, i64 0, i64 1
%20 = call i32 @tcgetattr(i32 1, %struct.termios* %19)
%21 = icmp slt i32 %20, 0
br i1 %21, label %89, label %22
22: ; preds = %18
%23 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %5, i64 0, i64 2
%24 = call i32 @tcgetattr(i32 2, %struct.termios* %23)
%25 = load i32, i32* @AF_UNIX
%26 = load i32, i32* @SOCK_STREAM
%27 = bitcast i64* %7 to i32*
%28 = call i32 @socketpair(i32 %25, i32 %26, i32 0, i32* %27)
%29 = icmp slt i32 %28, 0
br i1 %29, label %89, label %30
30: ; preds = %22
%31 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %5, i64 0, i64 3
%32 = bitcast %struct.termios* %31 to i8*
%33 = load i32, i32* @ECHO
%34 = load i32, i32* @ICANON
%35 = or i32 %34, %33
%36 = xor i32 %35, -1
%37 = getelementptr inbounds %struct.termios, %struct.termios* %31, i64 0, i32 0
%38 = load i32, i32* %37
%39 = and i32 %38, %36
store i32 %39, i32* %37
%40 = getelementptr inbounds [4 x %struct.termios], [4 x %struct.termios]* %5, i64 0, i64 3, i32 1
%41 = load i32*, i32** %40
%42 = load i64, i64* @VMIN
%43 = getelementptr inbounds i32, i32* %41, i64 %42
store i32 1, i32* %43
%44 = load i64, i64* @VTIME
%45 = getelementptr inbounds i32, i32* %41, i64 %44
store i32 0, i32* %45
%46 = load i32, i32* @TCSANOW
%47 = call i32 @tcsetattr(i32 0, i32 %46, %struct.termios* %31)
%48 = icmp slt i32 %47, 0
br i1 %48, label %89, label %49
49: ; preds = %30
%50 = call i64 (...) @fork()
%51 = icmp eq i64 %50, 0
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
%53 = load i32, i32* %52
br i1 %51, label %54, label %68
54: ; preds = %49
%55 = call i32 @dup2(i32 %53, i32 0)
%56 = load i32, i32* %52
%57 = call i32 @dup2(i32 %56, i32 1)
%58 = call i64 @isatty(i32 2)
%59 = icmp eq i64 %58, 0
br i1 %59, label %63, label %60
60: ; preds = %54
%61 = load i32, i32* %52
%62 = call i32 @dup2(i32 %61, i32 2)
br label %63
63: ; preds = %60, %54
%64 = load i32, i32* %27
%65 = call i32 @close(i32 %64)
%66 = load i32, i32* %52
%67 = call i32 @close(i32 %66)
br label %89
68: ; preds = %49
%69 = call i32 @close(i32 %53)
%70 = call i32 @dup2(i32 1, i32 2)
%71 = load i32, i32* %27
%72 = call i32 @shuttle(i32 %71, i8* %2)
%73 = load i32, i32* %27
%74 = load i32, i32* @SHUT_WR
%75 = call i32 @shutdown(i32 %73, i32 %74)
%76 = load i32, i32* %27
%77 = call i32 @read(i32 %76, i8* %11, i32 1)
%78 = icmp eq i32 %77, 1
br i1 %78, label %79, label %84
79: ; preds = %68, %79
%80 = call i32 @write(i32 1, i8* %11, i32 1)
%81 = load i32, i32* %27
%82 = call i32 @read(i32 %81, i8* %11, i32 1)
%83 = icmp eq i32 %82, 1
br i1 %83, label %79, label %84
84: ; preds = %79, %68
%85 = call i32 @wait(i32* %9)
%86 = load i32, i32* @TCSANOW
%87 = call i32 @tcsetattr(i32 0, i32 %86, %struct.termios* %14)
%88 = load i32, i32* %9
br label %91
89: ; preds = %4, %18, %30, %22, %63
%90 = call i32 %3(i32 %0, i8** %1)
br label %91
91: ; preds = %89, %84
%92 = phi i32 [ %90, %89 ], [ %88, %84 ]
ret i32 %92
}