#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*/ uid_t;
struct iovec {
  char *iov_base;
  int iov_len;
};
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ SOCK_STREAM;
int STDIN_FILENO;
int STDOUT_FILENO;
int /*<<< orphan*/ close(int);
int dup2(int, int);
int /*<<< orphan*/ err_sys(char *);
scalar_t__ execl(char *, char *, char *);
scalar_t__ fork();
int recv_fd(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ socketpair(int /*<<< orphan*/, int /*<<< orphan*/,
                      int /*<<< orphan*/, int *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void *strlen(char *);
int /*<<< orphan*/ write;
int writev(int, struct iovec *, int);
int csopen(char *name, int oflag) {
  pid_t pid;
  int len = 0;
  char buf[10] = {0};
  struct iovec iov[3];
  static int fd[2] = {-1, -1};
  if (fd[0] < 0) {
    if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0)
      err_sys("socketpair error");
    if ((pid = fork()) < 0) {
      err_sys("fork error");
    } else if (pid == 0) {
      close(fd[0]);
      if (fd[1] != STDIN_FILENO && dup2(fd[1], STDIN_FILENO) != STDIN_FILENO)
        err_sys("dup2 error to stdin");
      if (fd[1] != STDOUT_FILENO && dup2(fd[1], STDOUT_FILENO) != STDOUT_FILENO)
        err_sys("dup2 error to stdout");
      if (execl("./csopend", "csopend", (char *)0) < 0)
        err_sys("execl error");
      return -1;
    }
    close(fd[1]);
  }
  sprintf(buf, " %d", oflag);
  iov[0].iov_base = "open ";
  iov[0].iov_len = strlen("open ");
  iov[1].iov_base = name;
  iov[1].iov_len = strlen(name);
  iov[2].iov_base = buf;
  iov[2].iov_len = strlen(buf) + 1;
  len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
  if (writev(fd[0], &iov[0], 3) != len)
    err_sys("writev error");
  uid_t uid = 0;
  return recv_fd(fd[0], &uid, write);
}


x86 assembly (clang, -O0):
<csopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x2e(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <memset@plt>
cmpl   $0x0,0x2e9b(%rip)
jge    1326 <csopen+0x176>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
mov    0x2dd5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
lea    0x2e7a(%rip),%rcx
call   1090 <socketpair@plt>
cmp    $0x0,%rax
jge    1219 <csopen+0x69>
lea    0xdec(%rip),%rdi
call   1040 <err_sys@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jge    123f <csopen+0x8f>
lea    0xddc(%rip),%rdi
call   1040 <err_sys@plt>
jmp    131b <csopen+0x16b>
cmpq   $0x0,-0x20(%rbp)
jne    1316 <csopen+0x166>
mov    0x2e28(%rip),%edi
call   1080 <close@plt>
mov    0x2e21(%rip),%eax
mov    0x2d5e(%rip),%rcx
cmp    (%rcx),%eax
je     1299 <csopen+0xe9>
mov    0x2e0c(%rip),%edi
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
call   1060 <dup2@plt>
mov    0x2d3b(%rip),%rcx
cmp    (%rcx),%eax
je     1299 <csopen+0xe9>
lea    0xd88(%rip),%rdi
call   1040 <err_sys@plt>
mov    0x2ddd(%rip),%eax
mov    0x2d4a(%rip),%rcx
cmp    (%rcx),%eax
je     12dd <csopen+0x12d>
mov    0x2dc8(%rip),%edi
mov    0x2d35(%rip),%rax
mov    (%rax),%esi
call   1060 <dup2@plt>
mov    0x2d27(%rip),%rcx
cmp    (%rcx),%eax
je     12dd <csopen+0x12d>
lea    0xd58(%rip),%rdi
call   1040 <err_sys@plt>
lea    0xd61(%rip),%rdi
lea    0xd5c(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10c0 <execl@plt>
cmp    $0x0,%rax
jge    130a <csopen+0x15a>
lea    0xd4a(%rip),%rdi
call   1040 <err_sys@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13d6 <csopen+0x226>
jmp    131b <csopen+0x16b>
mov    0x2d5b(%rip),%edi
call   1080 <close@plt>
lea    -0x2e(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xd27(%rip),%rsi
call   10b0 <sprintf@plt>
lea    0xd1f(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xd14(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x48(%rbp)
lea    -0x2e(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x2e(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%rax
mov    %eax,-0x38(%rbp)
mov    -0x58(%rbp),%eax
add    -0x48(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2ce7(%rip),%edi
lea    -0x60(%rbp),%rsi
mov    $0x3,%edx
call   1030 <writev@plt>
cmp    -0x24(%rbp),%eax
je     13b4 <csopen+0x204>
lea    0xcb6(%rip),%rdi
call   1040 <err_sys@plt>
movl   $0x0,-0x64(%rbp)
mov    0x2cb7(%rip),%edi
mov    0x2c10(%rip),%rax
mov    (%rax),%edx
lea    -0x64(%rbp),%rsi
call   10a0 <recv_fd@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csopen>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
movw   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
cmpl   $0x0,0x2ea7(%rip)
jns    12bc <csopen+0x11c>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
lea    0x2e88(%rip),%rcx
xor    %edx,%edx
call   1080 <socketpair@plt>
test   %rax,%rax
jns    1200 <csopen+0x60>
lea    0xe05(%rip),%rdi
call   1040 <err_sys@plt>
xor    %eax,%eax
call   10c0 <fork@plt>
test   %rax,%rax
js     12a5 <csopen+0x105>
jne    12b1 <csopen+0x111>
mov    0x2e54(%rip),%edi
call   1070 <close@plt>
mov    0x2e4d(%rip),%edi
mov    0x2d92(%rip),%rbx
mov    (%rbx),%esi
cmp    %esi,%edi
je     1249 <csopen+0xa9>
call   1060 <dup2@plt>
cmp    (%rbx),%eax
je     1249 <csopen+0xa9>
lea    0xdd8(%rip),%rdi
call   1040 <err_sys@plt>
mov    0x2e25(%rip),%edi
mov    0x2d9a(%rip),%rbx
mov    (%rbx),%esi
cmp    %esi,%edi
je     1271 <csopen+0xd1>
call   1060 <dup2@plt>
cmp    (%rbx),%eax
je     1271 <csopen+0xd1>
lea    0xdc4(%rip),%rdi
call   1040 <err_sys@plt>
lea    0xdcd(%rip),%rdi
lea    0xdc8(%rip),%rsi
xor    %edx,%edx
call   10b0 <execl@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jns    1363 <csopen+0x1c3>
lea    0xdb4(%rip),%rdi
call   1040 <err_sys@plt>
jmp    1363 <csopen+0x1c3>
lea    0xd65(%rip),%rdi
call   1040 <err_sys@plt>
mov    0x2dbd(%rip),%edi
call   1070 <close@plt>
lea    0xd98(%rip),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    %r14d,%edx
call   10a0 <sprintf@plt>
lea    0xd85(%rip),%rdi
mov    %rdi,0x20(%rsp)
call   1050 <strlen@plt>
mov    %rax,%rbx
mov    %ebx,0x28(%rsp)
mov    %r15,0x30(%rsp)
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    %ebp,0x38(%rsp)
mov    %r12,0x40(%rsp)
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%ecx
mov    %ecx,0x48(%rsp)
add    %ebx,%ebp
lea    (%rax,%rbp,1),%ebx
add    $0x1,%ebx
mov    0x2d4f(%rip),%edi
lea    0x20(%rsp),%rsi
mov    $0x3,%edx
call   1030 <writev@plt>
cmp    %ebx,%eax
je     1340 <csopen+0x1a0>
lea    0xd2a(%rip),%rdi
call   1040 <err_sys@plt>
movl   $0x0,0xc(%rsp)
mov    0x2d22(%rip),%edi
mov    0x2c83(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rsi
call   1090 <recv_fd@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.iovec = type { i8*, i32 }
@csopen.fd = internal global [2 x i32] [i32 -1, i32 -1]
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [17 x i8] c"socketpair error\00"
@.str.1 = [11 x i8] c"fork error\00"
@STDIN_FILENO = global i32 0
@.str.2 = [20 x i8] c"dup2 error to stdin\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [21 x i8] c"dup2 error to stdout\00"
@.str.4 = [10 x i8] c"./csopend\00"
@.str.5 = [8 x i8] c"csopend\00"
@.str.6 = [12 x i8] c"execl error\00"
@.str.7 = [4 x i8] c" %d\00"
@.str.8 = [6 x i8] c"open \00"
@.str.9 = [13 x i8] c"writev error\00"
@write = global i32 0
define i32 @csopen(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i32
%8 = alloca [10 x i8]
%9 = alloca [3 x %struct.iovec]
%10 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %7
%11 = bitcast [10 x i8]* %8 to i8*
%12 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %65
14: ; preds = %2
%15 = load i32, i32* @AF_UNIX
%16 = load i32, i32* @SOCK_STREAM
%17 = call i64 @socketpair(i32 %15, i32 %16, i32 0, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0))
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 @err_sys(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
%22 = call i64 (...) @fork()
store i64 %22, i64* %6
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @err_sys(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %62
26: ; preds = %21
%27 = load i64, i64* %6
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %61
29: ; preds = %26
%30 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0)
%31 = call i32 @close(i32 %30)
%32 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 1)
%33 = load i32, i32* @STDIN_FILENO
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %43
35: ; preds = %29
%36 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 1)
%37 = load i32, i32* @STDIN_FILENO
%38 = call i32 @dup2(i32 %36, i32 %37)
%39 = load i32, i32* @STDIN_FILENO
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = call i32 @err_sys(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %43
43: ; preds = %41, %35, %29
%44 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 1)
%45 = load i32, i32* @STDOUT_FILENO
%46 = icmp ne i32 %44, %45
br i1 %46, label %47, label %55
47: ; preds = %43
%48 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 1)
%49 = load i32, i32* @STDOUT_FILENO
%50 = call i32 @dup2(i32 %48, i32 %49)
%51 = load i32, i32* @STDOUT_FILENO
%52 = icmp ne i32 %50, %51
br i1 %52, label %53, label %55
53: ; preds = %47
%54 = call i32 @err_sys(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53, %47, %43
%56 = call i64 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* null)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %55
%59 = call i32 @err_sys(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %60
60: ; preds = %58, %55
store i32 -1, i32* %3
br label %114
61: ; preds = %26
br label %62
62: ; preds = %61, %24
%63 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 1)
%64 = call i32 @close(i32 %63)
br label %65
65: ; preds = %62, %2
%66 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%67 = load i32, i32* %5
%68 = call i32 @sprintf(i8* %66, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %67)
%69 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 0
%70 = getelementptr inbounds %struct.iovec, %struct.iovec* %69, i32 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8** %70
%71 = call i8* @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%72 = ptrtoint i8* %71 to i32
%73 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 0
%74 = getelementptr inbounds %struct.iovec, %struct.iovec* %73, i32 0, i32 1
store i32 %72, i32* %74
%75 = load i8*, i8** %4
%76 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 1
%77 = getelementptr inbounds %struct.iovec, %struct.iovec* %76, i32 0, i32 0
store i8* %75, i8** %77
%78 = load i8*, i8** %4
%79 = call i8* @strlen(i8* %78)
%80 = ptrtoint i8* %79 to i32
%81 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 1
%82 = getelementptr inbounds %struct.iovec, %struct.iovec* %81, i32 0, i32 1
store i32 %80, i32* %82
%83 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%84 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 2
%85 = getelementptr inbounds %struct.iovec, %struct.iovec* %84, i32 0, i32 0
store i8* %83, i8** %85
%86 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%87 = call i8* @strlen(i8* %86)
%88 = getelementptr i8, i8* %87, i64 1
%89 = ptrtoint i8* %88 to i32
%90 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 2
%91 = getelementptr inbounds %struct.iovec, %struct.iovec* %90, i32 0, i32 1
store i32 %89, i32* %91
%92 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 0
%93 = getelementptr inbounds %struct.iovec, %struct.iovec* %92, i32 0, i32 1
%94 = load i32, i32* %93
%95 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 1
%96 = getelementptr inbounds %struct.iovec, %struct.iovec* %95, i32 0, i32 1
%97 = load i32, i32* %96
%98 = add nsw i32 %94, %97
%99 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 2
%100 = getelementptr inbounds %struct.iovec, %struct.iovec* %99, i32 0, i32 1
%101 = load i32, i32* %100
%102 = add nsw i32 %98, %101
store i32 %102, i32* %7
%103 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0)
%104 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %9, i64 0, i64 0
%105 = call i32 @writev(i32 %103, %struct.iovec* %104, i32 3)
%106 = load i32, i32* %7
%107 = icmp ne i32 %105, %106
br i1 %107, label %108, label %110
108: ; preds = %65
%109 = call i32 @err_sys(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %110
110: ; preds = %108, %65
store i32 0, i32* %10
%111 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0)
%112 = load i32, i32* @write
%113 = call i32 @recv_fd(i32 %111, i32* %10, i32 %112)
store i32 %113, i32* %3
br label %114
114: ; preds = %110, %60
%115 = load i32, i32* %3
ret i32 %115
}

LLVM IR (-O2):
%struct.iovec = type { i8*, i32 }
@csopen.fd = internal global [2 x i32] [i32 -1, i32 -1]
@AF_UNIX = global i32 0
@SOCK_STREAM = global i32 0
@.str = [17 x i8] c"socketpair error\00"
@.str.1 = [11 x i8] c"fork error\00"
@STDIN_FILENO = global i32 0
@.str.2 = [20 x i8] c"dup2 error to stdin\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [21 x i8] c"dup2 error to stdout\00"
@.str.4 = [10 x i8] c"./csopend\00"
@.str.5 = [8 x i8] c"csopend\00"
@.str.6 = [12 x i8] c"execl error\00"
@.str.7 = [4 x i8] c" %d\00"
@.str.8 = [6 x i8] c"open \00"
@.str.9 = [13 x i8] c"writev error\00"
@write = global i32 0
define i32 @csopen(i8* %0, i32 %1) {
%3 = alloca [10 x i8]
%4 = alloca [3 x %struct.iovec]
%5 = alloca i32
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = bitcast [3 x %struct.iovec]* %4 to i8*
%8 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %54
10: ; preds = %2
%11 = load i32, i32* @AF_UNIX
%12 = load i32, i32* @SOCK_STREAM
%13 = tail call i64 @socketpair(i32 %11, i32 %12, i32 0, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0))
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = tail call i32 @err_sys(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %10
%18 = tail call i64 (...) @fork()
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @err_sys(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %51
22: ; preds = %17
%23 = icmp eq i64 %18, 0
br i1 %23, label %24, label %51
24: ; preds = %22
%25 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0)
%26 = tail call i32 @close(i32 %25)
%27 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 1)
%28 = load i32, i32* @STDIN_FILENO
%29 = icmp eq i32 %27, %28
br i1 %29, label %36, label %30
30: ; preds = %24
%31 = tail call i32 @dup2(i32 %27, i32 %28)
%32 = load i32, i32* @STDIN_FILENO
%33 = icmp eq i32 %31, %32
br i1 %33, label %36, label %34
34: ; preds = %30
%35 = tail call i32 @err_sys(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %30, %24
%37 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 1)
%38 = load i32, i32* @STDOUT_FILENO
%39 = icmp eq i32 %37, %38
br i1 %39, label %46, label %40
40: ; preds = %36
%41 = tail call i32 @dup2(i32 %37, i32 %38)
%42 = load i32, i32* @STDOUT_FILENO
%43 = icmp eq i32 %41, %42
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = tail call i32 @err_sys(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %40, %36
%47 = tail call i64 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* null)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %85
49: ; preds = %46
%50 = tail call i32 @err_sys(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %85
51: ; preds = %22, %20
%52 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 1)
%53 = tail call i32 @close(i32 %52)
br label %54
54: ; preds = %51, %2
%55 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %1)
%56 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %4, i64 0, i64 0
%57 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %4, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8** %57
%58 = tail call i8* @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%59 = ptrtoint i8* %58 to i64
%60 = trunc i64 %59 to i32
%61 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %4, i64 0, i64 0, i32 1
store i32 %60, i32* %61
%62 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %4, i64 0, i64 1, i32 0
store i8* %0, i8** %62
%63 = tail call i8* @strlen(i8* %0)
%64 = ptrtoint i8* %63 to i64
%65 = trunc i64 %64 to i32
%66 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %4, i64 0, i64 1, i32 1
store i32 %65, i32* %66
%67 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %4, i64 0, i64 2, i32 0
store i8* %6, i8** %67
%68 = call i8* @strlen(i8* %6)
%69 = getelementptr i8, i8* %68, i64 1
%70 = ptrtoint i8* %69 to i64
%71 = trunc i64 %70 to i32
%72 = getelementptr inbounds [3 x %struct.iovec], [3 x %struct.iovec]* %4, i64 0, i64 2, i32 1
store i32 %71, i32* %72
%73 = add nsw i32 %65, %60
%74 = add nsw i32 %73, %71
%75 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0)
%76 = call i32 @writev(i32 %75, %struct.iovec* %56, i32 3)
%77 = icmp eq i32 %76, %74
br i1 %77, label %80, label %78
78: ; preds = %54
%79 = call i32 @err_sys(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0))
br label %80
80: ; preds = %78, %54
%81 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%82 = load i32, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @csopen.fd, i64 0, i64 0)
%83 = load i32, i32* @write
%84 = call i32 @recv_fd(i32 %82, i32* %5, i32 %83)
br label %85
85: ; preds = %46, %49, %80
%86 = phi i32 [ %84, %80 ], [ -1, %49 ], [ -1, %46 ]
ret i32 %86
}