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

/* Variables and functions */
scalar_t__ EINTR;
int atoi(char *);
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getopt(int, char **, char *);
char *optarg;
int optind;
int /*<<< orphan*/ perror(char *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage();
scalar_t__ write(int, char *, scalar_t__ const);
int main(int argc, char *argv[]) {
  int read_fd = 0;
  int opt;
  while ((opt = getopt(argc, argv, "hr:")) != -1) {
    switch (opt) {
    case 'h':
      usage();
      break;
    case 'r':
      read_fd = atoi(optarg);
      break;
    default:
      usage();
    }
  }
  if (optind == argc) {
    fprintf(stderr, "Error: No fds given\n");
    usage();
  }
  size_t const fd_cnt = argc - optind;
  int fds[fd_cnt];
  size_t fdidx = 0;
  for (int aidx = optind; aidx < argc; ++aidx, ++fdidx) {
    fds[fdidx] = atoi(argv[aidx]);
  }
  char buffer[4096];
  while (1) {
    ssize_t const bytes_read = read(read_fd, buffer, sizeof(buffer));
    if (bytes_read < 0 && errno == EINTR)
      continue;
    if (bytes_read <= 0)
      break;
    for (size_t fdidx = 0; fdidx < fd_cnt; ++fdidx) {
      if (fds[fdidx] != -1) {
        ssize_t const wr = write(fds[fdidx], buffer, bytes_read);
        if (wr == -1) {
          perror("write - closing fd");
          close(fds[fdidx]);
          fds[fdidx] = -1;
          continue;
        }
        if (wr != bytes_read) {
          perror("Could not write all data");
          close(fds[fdidx]);
          fds[fdidx] = -1;
          continue;
        }
      }
    }
  }
  for (size_t fdidx = 1; fdidx < fd_cnt; ++fdidx) {
    if (fds[fdidx] != -1) {
      close(fds[fdidx]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1070,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe52(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     1219 <main+0x99>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1064(%rbp)
sub    $0x68,%eax
je     11ea <main+0x6a>
jmp    11d6 <main+0x56>
mov    -0x1064(%rbp),%eax
sub    $0x72,%eax
je     11f6 <main+0x76>
jmp    120d <main+0x8d>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    1214 <main+0x94>
mov    0x2dfb(%rip),%rax
mov    (%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    1214 <main+0x94>
mov    $0x0,%al
call   1070 <usage@plt>
jmp    11a0 <main+0x20>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    1247 <main+0xc7>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1070 <usage@plt>
mov    -0x8(%rbp),%eax
mov    0x2d8f(%rip),%rcx
mov    (%rcx),%ecx
sub    %ecx,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1070(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    0x2d4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12e1 <main+0x161>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <atoi@plt>
mov    %eax,%edx
mov    -0x1070(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    129a <main+0x11a>
jmp    12e6 <main+0x166>
jmp    12eb <main+0x16b>
mov    -0x14(%rbp),%edi
lea    -0x1040(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <read@plt>
mov    %rax,-0x1048(%rbp)
cmpq   $0x0,-0x1048(%rbp)
jge    1333 <main+0x1b3>
mov    0x2cad(%rip),%rax
mov    (%rax),%rax
mov    0x2c9b(%rip),%rcx
cmp    (%rcx),%rax
jne    1333 <main+0x1b3>
jmp    12e6 <main+0x166>
cmpq   $0x0,-0x1048(%rbp)
jg     1346 <main+0x1c6>
jmp    1465 <main+0x2e5>
movq   $0x0,-0x1050(%rbp)
mov    -0x1050(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1460 <main+0x2e0>
mov    -0x1070(%rbp),%rax
mov    -0x1050(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     1444 <main+0x2c4>
mov    -0x1070(%rbp),%rax
mov    -0x1050(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
lea    -0x1040(%rbp),%rsi
mov    -0x1048(%rbp),%rdx
call   1030 <write@plt>
mov    %rax,-0x1058(%rbp)
cmpq   $0xffffffffffffffff,-0x1058(%rbp)
ff
jne    13ef <main+0x26f>
lea    0xc5f(%rip),%rdi
call   1080 <perror@plt>
mov    -0x1070(%rbp),%rax
mov    -0x1050(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <close@plt>
mov    -0x1070(%rbp),%rax
mov    -0x1050(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    1449 <main+0x2c9>
mov    -0x1058(%rbp),%rax
cmp    -0x1048(%rbp),%rax
je     143f <main+0x2bf>
lea    0xc22(%rip),%rdi
call   1080 <perror@plt>
mov    -0x1070(%rbp),%rax
mov    -0x1050(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <close@plt>
mov    -0x1070(%rbp),%rax
mov    -0x1050(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    1449 <main+0x2c9>
jmp    1444 <main+0x2c4>
jmp    1449 <main+0x2c9>
mov    -0x1050(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1050(%rbp)
jmp    1351 <main+0x1d1>
jmp    12e6 <main+0x166>
movq   $0x1,-0x1060(%rbp)
mov    -0x1060(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    14cb <main+0x34b>
mov    -0x1070(%rbp),%rax
mov    -0x1060(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     14af <main+0x32f>
mov    -0x1070(%rbp),%rax
mov    -0x1060(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <close@plt>
jmp    14b4 <main+0x334>
mov    -0x1060(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1060(%rbp)
jmp    1470 <main+0x2f0>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%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    $0x1018,%rsp
mov    %rsi,%r15
mov    %edi,%ebx
lea    0xe60(%rip),%r12
mov    0x2e51(%rip),%r14
movl   $0x0,-0x2c(%rbp)
jmp    11b7 <main+0x37>
xor    %eax,%eax
call   1070 <usage@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r12,%rdx
call   1090 <getopt@plt>
cmp    $0x68,%eax
je     11b0 <main+0x30>
cmp    $0xffffffff,%eax
je     11e0 <main+0x60>
cmp    $0x72,%eax
jne    11b0 <main+0x30>
mov    (%r14),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    11b7 <main+0x37>
mov    0x2df9(%rip),%r14
mov    (%r14),%eax
cmp    %ebx,%eax
jne    120d <main+0x8d>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1070 <usage@plt>
mov    (%r14),%eax
mov    %ebx,%ecx
sub    %eax,%ecx
mov    %ecx,-0x30(%rbp)
movslq %ecx,%r12
lea    0xf(,%r12,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r13
sub    %rcx,%r13
mov    %r13,%rsp
cmp    %eax,%ebx
jle    1257 <main+0xd7>
cltq
lea    (%r15,%rax,8),%r14
mov    -0x30(%rbp),%r15d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdi
call   10a0 <atoi@plt>
mov    %eax,0x0(%r13,%rbx,4)
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1240 <main+0xc0>
cmp    $0x2,%r12
mov    $0x1,%r14d
mov    %r12,-0x38(%rbp)
cmovae %r12,%r14
mov    -0x2c(%rbp),%ebx
jmp    1298 <main+0x118>
xchg   %ax,%ax
mov    0x2d51(%rip),%rax
mov    (%rax),%rcx
mov    $0x8,%eax
mov    0x2d3a(%rip),%rdx
cmp    (%rdx),%rcx
jne    132a <main+0x1aa>
cmp    $0x9,%eax
je     132a <main+0x1aa>
mov    %ebx,%edi
lea    -0x1040(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <read@plt>
test   %rax,%rax
js     1270 <main+0xf0>
mov    %rax,%r12
sete   %al
movzbl %al,%eax
lea    (%rax,%rax,8),%eax
je     128f <main+0x10f>
cmpl   $0x0,-0x30(%rbp)
je     128f <main+0x10f>
xor    %r15d,%r15d
jmp    12e9 <main+0x169>
call   1080 <perror@plt>
mov    %ebx,%edi
call   1040 <close@plt>
movl   $0xffffffff,0x0(%r13,%r15,4)
ff ff
xchg   %ax,%ax
add    $0x1,%r15
cmp    %r15,%r14
je     1320 <main+0x1a0>
mov    0x0(%r13,%r15,4),%ebx
cmp    $0xffffffff,%ebx
je     12e0 <main+0x160>
mov    %ebx,%edi
lea    -0x1040(%rbp),%rsi
mov    %r12,%rdx
call   1030 <write@plt>
lea    0xd0e(%rip),%rdi
cmp    $0xffffffffffffffff,%rax
je     12c9 <main+0x149>
lea    0xd14(%rip),%rdi
cmp    %r12,%rax
je     12e0 <main+0x160>
jmp    12c9 <main+0x149>
nop
xor    %eax,%eax
mov    -0x2c(%rbp),%ebx
jmp    128f <main+0x10f>
cmpl   $0x2,-0x30(%rbp)
jb     136a <main+0x1ea>
mov    -0x38(%rbp),%rax
cmp    $0x3,%rax
mov    $0x2,%r14d
cmovae %rax,%r14
mov    $0x1,%ebx
jmp    1359 <main+0x1d9>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r14
je     136a <main+0x1ea>
mov    0x0(%r13,%rbx,4),%edi
cmp    $0xffffffff,%edi
je     1350 <main+0x1d0>
call   1040 <close@plt>
jmp    1350 <main+0x1d0>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"hr:\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"Error: No fds given\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.2 = [19 x i8] c"write - closing fd\00"
@.str.3 = [25 x i8] c"Could not write all data\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 i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca [4096 x i8]
%14 = alloca i64
%15 = alloca i64
%16 = alloca i64
%17 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %18
18: ; preds = %32, %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt(i32 %19, i8** %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32 %21, i32* %7
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %33
23: ; preds = %18
%24 = load i32, i32* %7
switch i32 %24, label %30 [
i32 104, label %25
i32 114, label %27
]
25: ; preds = %23
%26 = call i32 (...) @usage()
br label %32
27: ; preds = %23
%28 = load i8*, i8** @optarg
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %6
br label %32
30: ; preds = %23
%31 = call i32 (...) @usage()
br label %32
32: ; preds = %30, %27, %25
br label %18
33: ; preds = %18
%34 = load i32, i32* @optind
%35 = load i32, i32* %4
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 (...) @usage()
br label %41
41: ; preds = %37, %33
%42 = load i32, i32* %4
%43 = load i32, i32* @optind
%44 = sub nsw i32 %42, %43
%45 = sext i32 %44 to i64
store i64 %45, i64* %8
%46 = load i64, i64* %8
%47 = call i8* @llvm.stacksave()
store i8* %47, i8** %9
%48 = alloca i32, i64 %46
store i64 %46, i64* %10
store i64 0, i64* %11
%49 = load i32, i32* @optind
store i32 %49, i32* %12
br label %50
50: ; preds = %63, %41
%51 = load i32, i32* %12
%52 = load i32, i32* %4
%53 = icmp slt i32 %51, %52
br i1 %53, label %54, label %68
54: ; preds = %50
%55 = load i8**, i8*** %5
%56 = load i32, i32* %12
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @atoi(i8* %59)
%61 = load i64, i64* %11
%62 = getelementptr inbounds i32, i32* %48, i64 %61
store i32 %60, i32* %62
br label %63
63: ; preds = %54
%64 = load i32, i32* %12
%65 = add nsw i32 %64, 1
store i32 %65, i32* %12
%66 = load i64, i64* %11
%67 = add i64 %66, 1
store i64 %67, i64* %11
br label %50
68: ; preds = %50
br label %69
69: ; preds = %129, %80, %68
br label %70
70: ; preds = %69
%71 = load i32, i32* %6
%72 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%73 = call i64 @read(i32 %71, i8* %72, i32 4096)
store i64 %73, i64* %14
%74 = load i64, i64* %14
%75 = icmp slt i64 %74, 0
br i1 %75, label %76, label %81
76: ; preds = %70
%77 = load i64, i64* @errno
%78 = load i64, i64* @EINTR
%79 = icmp eq i64 %77, %78
br i1 %79, label %80, label %81
80: ; preds = %76
br label %69
81: ; preds = %76, %70
%82 = load i64, i64* %14
%83 = icmp sle i64 %82, 0
br i1 %83, label %84, label %85
84: ; preds = %81
br label %130
85: ; preds = %81
store i64 0, i64* %15
br label %86
86: ; preds = %126, %85
%87 = load i64, i64* %15
%88 = load i64, i64* %8
%89 = icmp ult i64 %87, %88
br i1 %89, label %90, label %129
90: ; preds = %86
%91 = load i64, i64* %15
%92 = getelementptr inbounds i32, i32* %48, i64 %91
%93 = load i32, i32* %92
%94 = icmp ne i32 %93, -1
br i1 %94, label %95, label %125
95: ; preds = %90
%96 = load i64, i64* %15
%97 = getelementptr inbounds i32, i32* %48, i64 %96
%98 = load i32, i32* %97
%99 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%100 = load i64, i64* %14
%101 = call i64 @write(i32 %98, i8* %99, i64 %100)
store i64 %101, i64* %16
%102 = load i64, i64* %16
%103 = icmp eq i64 %102, -1
br i1 %103, label %104, label %112
104: ; preds = %95
%105 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%106 = load i64, i64* %15
%107 = getelementptr inbounds i32, i32* %48, i64 %106
%108 = load i32, i32* %107
%109 = call i32 @close(i32 %108)
%110 = load i64, i64* %15
%111 = getelementptr inbounds i32, i32* %48, i64 %110
store i32 -1, i32* %111
br label %126
112: ; preds = %95
%113 = load i64, i64* %16
%114 = load i64, i64* %14
%115 = icmp ne i64 %113, %114
br i1 %115, label %116, label %124
116: ; preds = %112
%117 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%118 = load i64, i64* %15
%119 = getelementptr inbounds i32, i32* %48, i64 %118
%120 = load i32, i32* %119
%121 = call i32 @close(i32 %120)
%122 = load i64, i64* %15
%123 = getelementptr inbounds i32, i32* %48, i64 %122
store i32 -1, i32* %123
br label %126
124: ; preds = %112
br label %125
125: ; preds = %124, %90
br label %126
126: ; preds = %125, %116, %104
%127 = load i64, i64* %15
%128 = add i64 %127, 1
store i64 %128, i64* %15
br label %86
129: ; preds = %86
br label %69
130: ; preds = %84
store i64 1, i64* %17
br label %131
131: ; preds = %146, %130
%132 = load i64, i64* %17
%133 = load i64, i64* %8
%134 = icmp ult i64 %132, %133
br i1 %134, label %135, label %149
135: ; preds = %131
%136 = load i64, i64* %17
%137 = getelementptr inbounds i32, i32* %48, i64 %136
%138 = load i32, i32* %137
%139 = icmp ne i32 %138, -1
br i1 %139, label %140, label %145
140: ; preds = %135
%141 = load i64, i64* %17
%142 = getelementptr inbounds i32, i32* %48, i64 %141
%143 = load i32, i32* %142
%144 = call i32 @close(i32 %143)
br label %145
145: ; preds = %140, %135
br label %146
146: ; preds = %145
%147 = load i64, i64* %17
%148 = add i64 %147, 1
store i64 %148, i64* %17
br label %131
149: ; preds = %131
store i32 0, i32* %3
%150 = load i8*, i8** %9
%151 = load i32, i32* %3
ret i32 %151
}

LLVM IR (-O2):
@.str = [4 x i8] c"hr:\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [21 x i8] c"Error: No fds given\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.2 = [19 x i8] c"write - closing fd\00"
@.str.3 = [25 x i8] c"Could not write all data\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [4096 x i8]
br label %4
4: ; preds = %10, %2
%5 = phi i32 [ %12, %10 ], [ 0, %2 ]
br label %6
6: ; preds = %15, %4
%7 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
switch i32 %7, label %13 [
i32 -1, label %16
i32 104, label %8
i32 114, label %10
]
8: ; preds = %6
%9 = tail call i32 (...) @usage()
br label %15
10: ; preds = %6
%11 = load i8*, i8** @optarg
%12 = tail call i32 @atoi(i8* %11)
br label %4
13: ; preds = %6
%14 = tail call i32 (...) @usage()
br label %15
15: ; preds = %13, %8
br label %6
16: ; preds = %6
%17 = load i32, i32* @optind
%18 = icmp eq i32 %17, %0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 (...) @usage()
%23 = load i32, i32* @optind
br label %24
24: ; preds = %19, %16
%25 = phi i32 [ %23, %19 ], [ %17, %16 ]
%26 = sub i32 %0, %25
%27 = sext i32 %26 to i64
%28 = alloca i32, i64 %27
%29 = icmp slt i32 %25, %0
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = sext i32 %25 to i64
br label %36
32: ; preds = %36, %24
%33 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%34 = icmp eq i32 %26, 0
%35 = call i64 @llvm.umax.i64(i64 %27, i64 1)
br label %47
36: ; preds = %30, %36
%37 = phi i64 [ %31, %30 ], [ %43, %36 ]
%38 = phi i64 [ 0, %30 ], [ %44, %36 ]
%39 = getelementptr inbounds i8*, i8** %1, i64 %37
%40 = load i8*, i8** %39
%41 = tail call i32 @atoi(i8* %40)
%42 = getelementptr inbounds i32, i32* %28, i64 %38
store i32 %41, i32* %42
%43 = add nsw i64 %37, 1
%44 = add nuw nsw i64 %38, 1
%45 = trunc i64 %44 to i32
%46 = icmp eq i32 %26, %45
br i1 %46, label %32, label %36
47: ; preds = %75, %32
%48 = call i64 @read(i32 %5, i8* %33, i32 4096)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = load i64, i64* @errno
%52 = load i64, i64* @EINTR
%53 = icmp eq i64 %51, %52
br i1 %53, label %75, label %78
54: ; preds = %47
%55 = icmp eq i64 %48, 0
%56 = select i1 %55, i1 true, i1 %34
%57 = select i1 %55, i32 9, i32 0
br i1 %56, label %75, label %58
58: ; preds = %54, %72
%59 = phi i64 [ %73, %72 ], [ 0, %54 ]
%60 = getelementptr inbounds i32, i32* %28, i64 %59
%61 = load i32, i32* %60
%62 = icmp eq i32 %61, -1
br i1 %62, label %72, label %63
63: ; preds = %58
%64 = call i64 @write(i32 %61, i8* %33, i64 %48)
%65 = icmp eq i64 %64, -1
br i1 %65, label %68, label %66
66: ; preds = %63
%67 = icmp eq i64 %64, %48
br i1 %67, label %72, label %68
68: ; preds = %66, %63
%69 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), %63 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), %66 ]
%70 = tail call i32 @perror(i8* %69)
%71 = tail call i32 @close(i32 %61)
store i32 -1, i32* %60
br label %72
72: ; preds = %68, %66, %58
%73 = add nuw i64 %59, 1
%74 = icmp eq i64 %73, %35
br i1 %74, label %75, label %58
75: ; preds = %72, %50, %54
%76 = phi i32 [ %57, %54 ], [ 8, %50 ], [ 0, %72 ]
%77 = icmp eq i32 %76, 9
br i1 %77, label %78, label %47
78: ; preds = %50, %75
%79 = icmp ugt i32 %26, 1
br i1 %79, label %80, label %82
80: ; preds = %78
%81 = call i64 @llvm.umax.i64(i64 %27, i64 2)
br label %83
82: ; preds = %90, %78
ret i32 0
83: ; preds = %80, %90
%84 = phi i64 [ %91, %90 ], [ 1, %80 ]
%85 = getelementptr inbounds i32, i32* %28, i64 %84
%86 = load i32, i32* %85
%87 = icmp eq i32 %86, -1
br i1 %87, label %90, label %88
88: ; preds = %83
%89 = tail call i32 @close(i32 %86)
br label %90
90: ; preds = %83, %88
%91 = add nuw i64 %84, 1
%92 = icmp eq i64 %91, %81
br i1 %92, label %82, label %83
}