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

/* Variables and functions */
int /*<<< orphan*/ F_GETFD;
int /*<<< orphan*/ assert(int);
int fcntl(int, int /*<<< orphan*/);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int strlen(char *);
int main(int argc, char *argv[]) {
  int i, fds = 0;
  char buf[512], hdr[512];
  struct {
    FILE *fh;
    const char *str;
  } io[3] = {{stdin, "stdin"}, {stdout, "stdout"}, {stderr, "stderr"}};
  (void)argc;
  (void)argv;
  hdr[0] = '\0';
  setbuf(stdin, NULL);
  setbuf(stdout, NULL);
  for (i = 0; i < 3; i++) {
    char str[32];
    int fd = fileno(io[i].fh);
    assert(fd == i);
    if (fcntl(fd, F_GETFD) != -1) {
      fds |= (1 << fd);
    }
    (void)snprintf(str, sizeof(str), "%s%s%s", i == 0 ? "" : ",",
                   (fds & (1 << fd)) ? "" : "!", io[i].str);
    memcpy(hdr + strlen(hdr), str, strlen(str) + 1);
  }
  if (fgets(buf, sizeof(buf), stdin) == NULL) {
    buf[0] = '\0';
  }
  if (fds & (1 << 1)) {
    fprintf(stdout, "%s\n%s", hdr, buf);
  }
  if (fds & (1 << 2)) {
    fprintf(stderr, "%s\n%s", hdr, buf);
  }
  return fds;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    0x2e31(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x450(%rbp)
lea    0xe38(%rip),%rax
mov    %rax,-0x448(%rbp)
mov    0x2df2(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x440(%rbp)
lea    0xe1f(%rip),%rax
mov    %rax,-0x438(%rbp)
mov    0x2de3(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x430(%rbp)
lea    0xe07(%rip),%rax
mov    %rax,-0x428(%rbp)
movb   $0x0,-0x420(%rbp)
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <setbuf@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <setbuf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    139a <main+0x20a>
movslq -0x14(%rbp),%rcx
lea    -0x450(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdi
call   10b0 <fileno@plt>
mov    %eax,-0x474(%rbp)
mov    -0x474(%rbp),%eax
cmp    -0x14(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x474(%rbp),%edi
mov    0x2d44(%rip),%rax
mov    (%rax),%esi
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
je     12af <main+0x11f>
mov    -0x474(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
lea    -0x470(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xd5b(%rip),%rax
lea    0xd57(%rip),%rcx
cmp    $0x0,%edx
cmove  %rcx,%rax
mov    %rax,-0x498(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x474(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    -0x498(%rbp),%rcx
and    %eax,%edx
lea    0xd28(%rip),%r8
lea    0xd22(%rip),%rax
cmp    $0x0,%edx
cmovne %rax,%r8
movslq -0x14(%rbp),%rdx
lea    -0x450(%rbp),%rax
shl    $0x4,%rdx
add    %rdx,%rax
mov    0x8(%rax),%r9
mov    $0x20,%esi
lea    0xcef(%rip),%rdx
call   1060 <snprintf@plt>
lea    -0x420(%rbp),%rax
mov    %rax,-0x490(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x490(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x488(%rbp)
lea    -0x470(%rbp),%rax
mov    %rax,-0x480(%rbp)
lea    -0x470(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x488(%rbp),%rdi
mov    -0x480(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   10a0 <memcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    123f <main+0xaf>
lea    -0x220(%rbp),%rdi
mov    0x2c40(%rip),%rax
mov    (%rax),%edx
mov    $0x200,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
jne    13c5 <main+0x235>
movb   $0x0,-0x220(%rbp)
mov    -0x18(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     13f7 <main+0x267>
mov    0x2bed(%rip),%rax
mov    (%rax),%edi
lea    -0x420(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    0xc2d(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1429 <main+0x299>
mov    0x2bcb(%rip),%rax
mov    (%rax),%edi
lea    -0x420(%rbp),%rdx
lea    -0x220(%rbp),%rcx
lea    0xbfb(%rip),%rsi
call   1090 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x4a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
movslq %eax,%rbx
mov    0x2e14(%rip),%rbp
movslq 0x0(%rbp),%r15
mov    0x2e19(%rip),%rax
movslq (%rax),%rax
mov    %rax,0x8(%rsp)
movb   $0x0,0x10(%rsp)
xor    %r14d,%r14d
mov    %ebx,%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
mov    0x0(%rbp),%edi
xor    %esi,%esi
call   1050 <setbuf@plt>
mov    %rbx,%rdi
call   10b0 <fileno@plt>
mov    %eax,%ebx
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1080 <assert@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1030 <fcntl@plt>
mov    $0x1,%r13d
mov    %ebx,%ecx
shl    %cl,%r13d
mov    $0x1,%ebx
cmp    $0xffffffff,%eax
cmove  %r14d,%r13d
lea    0xdf6(%rip),%rax
lea    0xdf0(%rip),%r12
mov    %r12,%r8
cmove  %rax,%r8
lea    0xdd8(%rip),%rdx
lea    0xdbd(%rip),%r9
lea    0x210(%rsp),%r14
mov    %r14,%rdi
mov    $0x20,%esi
mov    %r12,%rcx
call   1060 <snprintf@plt>
lea    0x10(%rsp),%rdi
call   1040 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rbp
add    $0x10,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbp,%rdi
mov    %r14,%rsi
call   10a0 <memcpy@plt>
mov    %r15,%rdi
call   10b0 <fileno@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
call   1080 <assert@plt>
mov    0x2d2c(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1030 <fcntl@plt>
mov    $0x1,%r15d
mov    %ebp,%ecx
shl    %cl,%r15d
cmp    $0xffffffff,%eax
mov    $0x0,%eax
cmove  %eax,%r15d
or     %r13d,%r15d
bt     %ebp,%r15d
mov    %r12,%r8
lea    0xd48(%rip),%rax
cmovae %rax,%r8
lea    0xd3b(%rip),%rcx
lea    0xd1f(%rip),%r9
mov    %r14,%rdi
mov    $0x20,%esi
lea    0xd1e(%rip),%r13
mov    %r13,%rdx
call   1060 <snprintf@plt>
lea    0x10(%rsp),%rdi
call   1040 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rbp
add    $0x10,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbp,%rdi
mov    %r14,%rsi
call   10a0 <memcpy@plt>
mov    0x8(%rsp),%rdi
call   10b0 <fileno@plt>
mov    %eax,%ebp
xor    %edi,%edi
cmp    $0x2,%eax
sete   %dil
call   1080 <assert@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1030 <fcntl@plt>
mov    %ebp,%ecx
shl    %cl,%ebx
cmp    $0xffffffff,%eax
mov    $0x0,%eax
cmove  %eax,%ebx
or     %r15d,%ebx
bt     %ebp,%ebx
lea    0xcaf(%rip),%rax
cmovae %rax,%r12
lea    0xc94(%rip),%r9
mov    %r14,%rdi
mov    $0x20,%esi
mov    %r13,%rdx
lea    0xc90(%rip),%rcx
mov    %r12,%r8
call   1060 <snprintf@plt>
lea    0x10(%rsp),%rdi
call   1040 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rbp
add    $0x10,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbp,%rdi
mov    %r14,%rsi
call   10a0 <memcpy@plt>
mov    0x2c24(%rip),%rax
mov    (%rax),%edx
lea    0x210(%rsp),%rdi
mov    $0x200,%esi
call   1070 <fgets@plt>
test   %rax,%rax
je     141d <main+0x28d>
test   $0x2,%bl
jne    142a <main+0x29a>
test   $0x4,%bl
je     1409 <main+0x279>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
lea    0xc28(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x210(%rsp),%rcx
call   1090 <fprintf@plt>
mov    %ebx,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movb   $0x0,0x210(%rsp)
test   $0x2,%bl
je     13e2 <main+0x252>
mov    0x2b97(%rip),%rax
mov    (%rax),%edi
lea    0xbe5(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x210(%rsp),%rcx
call   1090 <fprintf@plt>
test   $0x4,%bl
jne    13e7 <main+0x257>
jmp    1409 <main+0x279>

LLVM IR (-O0):
%struct.anon = type { i32*, i8* }
@stdin = global i32 0
@.str = [6 x i8] c"stdin\00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"stdout\00"
@stderr = global i32 0
@.str.2 = [7 x i8] c"stderr\00"
@F_GETFD = global i32 0
@.str.3 = [7 x i8] c"%s%s%s\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [2 x i8] c",\00"
@.str.6 = [2 x i8] c"!\00"
@.str.7 = [6 x i8] c"%s\0A%s\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 [512 x i8]
%9 = alloca [512 x i8]
%10 = alloca [3 x %struct.anon]
%11 = alloca [32 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 = getelementptr inbounds [3 x %struct.anon], [3 x %struct.anon]* %10, i64 0, i64 0
%14 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 0
%15 = load i32, i32* @stdin
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %14
%18 = getelementptr inbounds %struct.anon, %struct.anon* %13, i32 0, i32 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds %struct.anon, %struct.anon* %13, i64 1
%20 = getelementptr inbounds %struct.anon, %struct.anon* %19, i32 0, i32 0
%21 = load i32, i32* @stdout
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %20
%24 = getelementptr inbounds %struct.anon, %struct.anon* %19, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %24
%25 = getelementptr inbounds %struct.anon, %struct.anon* %19, i64 1
%26 = getelementptr inbounds %struct.anon, %struct.anon* %25, i32 0, i32 0
%27 = load i32, i32* @stderr
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i32*
store i32* %29, i32** %26
%30 = getelementptr inbounds %struct.anon, %struct.anon* %25, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %30
%31 = load i32, i32* %4
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
store i8 0, i8* %33
%34 = load i32, i32* @stdin
%35 = call i32 @setbuf(i32 %34, i32* null)
%36 = load i32, i32* @stdout
%37 = call i32 @setbuf(i32 %36, i32* null)
store i32 0, i32* %6
br label %38
38: ; preds = %91, %2
%39 = load i32, i32* %6
%40 = icmp slt i32 %39, 3
br i1 %40, label %41, label %94
41: ; preds = %38
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [3 x %struct.anon], [3 x %struct.anon]* %10, i64 0, i64 %43
%45 = getelementptr inbounds %struct.anon, %struct.anon* %44, i32 0, i32 0
%46 = load i32*, i32** %45
%47 = call i32 @fileno(i32* %46)
store i32 %47, i32* %12
%48 = load i32, i32* %12
%49 = load i32, i32* %6
%50 = icmp eq i32 %48, %49
%51 = zext i1 %50 to i32
%52 = call i32 @assert(i32 %51)
%53 = load i32, i32* %12
%54 = load i32, i32* @F_GETFD
%55 = call i32 @fcntl(i32 %53, i32 %54)
%56 = icmp ne i32 %55, -1
br i1 %56, label %57, label %62
57: ; preds = %41
%58 = load i32, i32* %12
%59 = shl i32 1, %58
%60 = load i32, i32* %7
%61 = or i32 %60, %59
store i32 %61, i32* %7
br label %62
62: ; preds = %57, %41
%63 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%64 = load i32, i32* %6
%65 = icmp eq i32 %64, 0
%66 = zext i1 %65 to i64
%67 = select i1 %65, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%68 = load i32, i32* %7
%69 = load i32, i32* %12
%70 = shl i32 1, %69
%71 = and i32 %68, %70
%72 = icmp ne i32 %71, 0
%73 = zext i1 %72 to i64
%74 = select i1 %72, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [3 x %struct.anon], [3 x %struct.anon]* %10, i64 0, i64 %76
%78 = getelementptr inbounds %struct.anon, %struct.anon* %77, i32 0, i32 1
%79 = load i8*, i8** %78
%80 = call i32 @snprintf(i8* %63, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %67, i8* %74, i8* %79)
%81 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%82 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%83 = call i32 @strlen(i8* %82)
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %81, i64 %84
%86 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%87 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%88 = call i32 @strlen(i8* %87)
%89 = add nsw i32 %88, 1
%90 = call i32 @memcpy(i8* %85, i8* %86, i32 %89)
br label %91
91: ; preds = %62
%92 = load i32, i32* %6
%93 = add nsw i32 %92, 1
store i32 %93, i32* %6
br label %38
94: ; preds = %38
%95 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%96 = load i32, i32* @stdin
%97 = call i32* @fgets(i8* %95, i32 512, i32 %96)
%98 = icmp eq i32* %97, null
br i1 %98, label %99, label %101
99: ; preds = %94
%100 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
store i8 0, i8* %100
br label %101
101: ; preds = %99, %94
%102 = load i32, i32* %7
%103 = and i32 %102, 2
%104 = icmp ne i32 %103, 0
br i1 %104, label %105, label %110
105: ; preds = %101
%106 = load i32, i32* @stdout
%107 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%108 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%109 = call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %107, i8* %108)
br label %110
110: ; preds = %105, %101
%111 = load i32, i32* %7
%112 = and i32 %111, 4
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %119
114: ; preds = %110
%115 = load i32, i32* @stderr
%116 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%117 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%118 = call i32 @fprintf(i32 %115, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %116, i8* %117)
br label %119
119: ; preds = %114, %110
%120 = load i32, i32* %7
ret i32 %120
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"stdin\00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"stdout\00"
@stderr = global i32 0
@.str.2 = [7 x i8] c"stderr\00"
@F_GETFD = global i32 0
@.str.3 = [7 x i8] c"%s%s%s\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [2 x i8] c",\00"
@.str.6 = [2 x i8] c"!\00"
@.str.7 = [6 x i8] c"%s\0A%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [32 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = sext i32 %8 to i64
%10 = inttoptr i64 %9 to i32*
%11 = load i32, i32* @stdout
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32*
%14 = load i32, i32* @stderr
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
store i8 0, i8* %7
%17 = tail call i32 @setbuf(i32 %8, i32* null)
%18 = load i32, i32* @stdout
%19 = tail call i32 @setbuf(i32 %18, i32* null)
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%21 = call i32 @fileno(i32* %10)
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* @F_GETFD
%26 = call i32 @fcntl(i32 %21, i32 %25)
%27 = icmp eq i32 %26, -1
%28 = shl nuw i32 1, %21
%29 = select i1 %27, i32 0, i32 %28
%30 = select i1 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%31 = call i32 @snprintf(i8* %20, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* %30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%32 = call i32 @strlen(i8* %7)
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %33
%35 = call i32 @strlen(i8* %20)
%36 = add nsw i32 %35, 1
%37 = call i32 @memcpy(i8* %34, i8* %20, i32 %36)
%38 = call i32 @fileno(i32* %13)
%39 = icmp eq i32 %38, 1
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load i32, i32* @F_GETFD
%43 = call i32 @fcntl(i32 %38, i32 %42)
%44 = icmp eq i32 %43, -1
%45 = shl nuw i32 1, %38
%46 = select i1 %44, i32 0, i32 %45
%47 = or i32 %46, %29
%48 = and i32 %47, %45
%49 = icmp eq i32 %48, 0
%50 = select i1 %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%51 = call i32 @snprintf(i8* %20, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %50, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%52 = call i32 @strlen(i8* %7)
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %53
%55 = call i32 @strlen(i8* %20)
%56 = add nsw i32 %55, 1
%57 = call i32 @memcpy(i8* %54, i8* %20, i32 %56)
%58 = call i32 @fileno(i32* %16)
%59 = icmp eq i32 %58, 2
%60 = zext i1 %59 to i32
%61 = call i32 @assert(i32 %60)
%62 = load i32, i32* @F_GETFD
%63 = call i32 @fcntl(i32 %58, i32 %62)
%64 = icmp eq i32 %63, -1
%65 = shl nuw i32 1, %58
%66 = select i1 %64, i32 0, i32 %65
%67 = or i32 %66, %47
%68 = and i32 %67, %65
%69 = icmp eq i32 %68, 0
%70 = select i1 %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0)
%71 = call i32 @snprintf(i8* %20, i32 32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %70, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%72 = call i32 @strlen(i8* %7)
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %73
%75 = call i32 @strlen(i8* %20)
%76 = add nsw i32 %75, 1
%77 = call i32 @memcpy(i8* %74, i8* %20, i32 %76)
%78 = load i32, i32* @stdin
%79 = call i32* @fgets(i8* %6, i32 512, i32 %78)
%80 = icmp eq i32* %79, null
br i1 %80, label %81, label %82
81: ; preds = %2
store i8 0, i8* %6
br label %82
82: ; preds = %81, %2
%83 = and i32 %67, 2
%84 = icmp eq i32 %83, 0
br i1 %84, label %88, label %85
85: ; preds = %82
%86 = load i32, i32* @stdout
%87 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %7, i8* %6)
br label %88
88: ; preds = %85, %82
%89 = and i32 %67, 4
%90 = icmp eq i32 %89, 0
br i1 %90, label %94, label %91
91: ; preds = %88
%92 = load i32, i32* @stderr
%93 = call i32 @fprintf(i32 %92, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8* %7, i8* %6)
br label %94
94: ; preds = %91, %88
ret i32 %67
}