#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*/ FILE;

/* Variables and functions */
int EXIT_FAILURE;
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/ *);
int getopt(int, char **, char *);
int optind;
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ *stdout;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  FILE *output[argc];
  int i, exitcode = 0, opt;
  bool append = false;
  while ((opt = getopt(argc, argv, "ai")) != -1) {
    switch (opt) {
    case 'a':
      append = true;
      break;
    case 'i':
      signal(SIGINT, SIG_IGN);
      break;
    default:
      fprintf(stderr, "Usage: %s [−ai] [file...]\n", argv[0]);
      exit(EXIT_FAILURE);
    }
  }
  for (i = optind; i < argc; i++) {
    if (append)
      output[i] = fopen(argv[i], "a");
    else
      output[i] = fopen(argv[i], "w");
    if (output[i]) {
      setvbuf(output[i], NULL, _IONBF, 0);
    } else {
      fprintf(stderr, "ERROR: %s\n", strerror(errno));
      exitcode = EXIT_FAILURE;
    }
  }
  char buffer[4096];
  size_t numbytes;
  while (1) {
    numbytes = fread(buffer, sizeof(unsigned char), 4096, stdin);
    for (i = optind; i < argc; i++)
      if (output[i])
        fwrite(buffer, sizeof(unsigned char), numbytes, output[i]);
    fwrite(buffer, sizeof(unsigned char), numbytes, stdout);
    if (numbytes < 4096)
      break;
  }
  for (i = optind; i < argc; i++)
    if (output[i])
      fclose(output[i]);
  return exitcode;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x1040(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe01(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
je     1292 <main+0xf2>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1044(%rbp)
sub    $0x61,%eax
je     123b <main+0x9b>
jmp    1227 <main+0x87>
mov    -0x1044(%rbp),%eax
sub    $0x69,%eax
je     1247 <main+0xa7>
jmp    1263 <main+0xc3>
movl   $0x1,-0x30(%rbp)
jmp    128d <main+0xed>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    0x2d71(%rip),%rax
mov    (%rax),%esi
call   1050 <signal@plt>
jmp    128d <main+0xed>
mov    0x2d4e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd89(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
jmp    11f1 <main+0x51>
mov    0x2d37(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    139c <main+0x1fc>
cmpl   $0x0,-0x30(%rbp)
je     12e3 <main+0x143>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd59(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rdx
mov    -0x1040(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    130d <main+0x16d>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd2c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rdx
mov    -0x1040(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1040(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     134b <main+0x1ab>
mov    -0x1040(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2c9f(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1070 <setvbuf@plt>
jmp    1389 <main+0x1e9>
mov    0x2c66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1048(%rbp)
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    -0x1048(%rbp),%edi
mov    %rax,%rdx
lea    0xcac(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2c24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
jmp    138e <main+0x1ee>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    129e <main+0xfe>
jmp    13a1 <main+0x201>
jmp    13a6 <main+0x206>
lea    -0x1030(%rbp),%rdi
mov    0x2c2c(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,-0x1038(%rbp)
mov    0x2bfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1434 <main+0x294>
mov    -0x1040(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1421 <main+0x281>
mov    -0x1040(%rbp),%rax
lea    -0x1030(%rbp),%rdi
mov    -0x1038(%rbp),%rdx
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
jmp    1426 <main+0x286>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    13d8 <main+0x238>
lea    -0x1030(%rbp),%rdi
mov    -0x1038(%rbp),%rdx
mov    0x2b57(%rip),%rax
mov    (%rax),%rcx
mov    $0x1,%esi
call   10b0 <fwrite@plt>
cmpq   $0x1000,-0x1038(%rbp)
jae    146c <main+0x2cc>
jmp    1471 <main+0x2d1>
jmp    13a1 <main+0x201>
mov    0x2b58(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14c6 <main+0x326>
mov    -0x1040(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     14b3 <main+0x313>
mov    -0x1040(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <fclose@plt>
jmp    14b8 <main+0x318>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    147d <main+0x2dd>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%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    $0x1028,%rsp
mov    %rsi,%rbx
mov    %edi,%r12d
mov    %edi,%eax
mov    %rsp,%rcx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
lea    0xe46(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe19(%rip),%r13
mov    0x2dfa(%rip),%r14
mov    0x2dd3(%rip),%r15
jmp    120b <main+0x6b>
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    (%r15),%esi
call   1050 <signal@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1090 <getopt@plt>
cmp    $0x69,%eax
je     1200 <main+0x60>
cmp    $0xffffffff,%eax
je     1239 <main+0x99>
cmp    $0x61,%eax
jne    13eb <main+0x24b>
lea    0xded(%rip),%rax
mov    %rax,-0x40(%rbp)
jmp    120b <main+0x6b>
mov    0x2d90(%rip),%rax
movslq (%rax),%rax
movl   $0x0,-0x2c(%rbp)
cmp    %r12d,%eax
jge    12ee <main+0x14e>
mov    -0x38(%rbp),%rcx
lea    (%rcx,%rax,8),%rcx
mov    %rcx,-0x50(%rbp)
lea    (%rbx,%rax,8),%r15
mov    %r12d,%r13d
sub    %eax,%r13d
xor    %r14d,%r14d
movl   $0x0,-0x2c(%rbp)
jmp    129e <main+0xfe>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x2d51(%rip),%rcx
mov    (%rcx),%edx
mov    %rax,%rdi
xor    %esi,%esi
xor    %ecx,%ecx
call   1070 <setvbuf@plt>
add    $0x1,%r14
cmp    %r14d,%r13d
je     12ee <main+0x14e>
mov    (%r15,%r14,8),%rdi
mov    -0x40(%rbp),%rsi
call   1080 <fopen@plt>
mov    -0x50(%rbp),%rcx
mov    %rax,(%rcx,%r14,8)
test   %rax,%rax
jne    1280 <main+0xe0>
mov    0x2cf9(%rip),%rax
mov    (%rax),%ebx
mov    0x2ce8(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %ebx,%edi
lea    0xd4c(%rip),%rsi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    0x2cc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
jmp    1295 <main+0xf5>
lea    -0x1050(%rbp),%r15
mov    %r12,-0x48(%rbp)
jmp    1327 <main+0x187>
nopl   0x0(%rax,%rax,1)
mov    0x2c99(%rip),%rax
mov    (%rax),%rcx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   10b0 <fwrite@plt>
cmp    $0xfff,%rbx
mov    -0x48(%rbp),%r12
jbe    1394 <main+0x1f4>
mov    0x2cb2(%rip),%rax
mov    (%rax),%ecx
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,%rbx
mov    0x2c84(%rip),%rax
movslq (%rax),%rax
cmp    %r12d,%eax
jge    1300 <main+0x160>
mov    -0x38(%rbp),%rcx
lea    (%rcx,%rax,8),%r14
mov    -0x48(%rbp),%r13
sub    %eax,%r13d
xor    %r12d,%r12d
jmp    1379 <main+0x1d9>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r12
cmp    %r12d,%r13d
je     1300 <main+0x160>
mov    (%r14,%r12,8),%rcx
test   %rcx,%rcx
je     1370 <main+0x1d0>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   10b0 <fwrite@plt>
jmp    1370 <main+0x1d0>
mov    0x2c35(%rip),%rax
movslq (%rax),%rax
cmp    %r12d,%eax
jge    13d9 <main+0x239>
mov    -0x38(%rbp),%rcx
lea    (%rcx,%rax,8),%r14
sub    %eax,%r12d
xor    %ebx,%ebx
jmp    13c9 <main+0x229>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %ebx,%r12d
je     13d9 <main+0x239>
mov    (%r14,%rbx,8),%rdi
test   %rdi,%rdi
je     13c0 <main+0x220>
call   1040 <fclose@plt>
jmp    13c0 <main+0x220>
mov    -0x2c(%rbp),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bc6(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xc05(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2b9e(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"ai\00"
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@stderr = global i32 0
@.str.1 = [29 x i8] c"Usage: %s [\E2\88\92ai] [file...]\0A\00"
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [2 x i8] c"w\00"
@_IONBF = global i32 0
@.str.4 = [11 x i8] c"ERROR: %s\0A\00"
@errno = global i32 0
@stdin = global i32 0
@stdout = global i32* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4096 x i8]
%13 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %6
%17 = alloca i32*, i64 %15
store i64 %15, i64* %7
store i32 0, i32* %9
store i32 0, i32* %11
br label %18
18: ; preds = %38, %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt(i32 %19, i8** %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %21, i32* %10
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %39
23: ; preds = %18
%24 = load i32, i32* %10
switch i32 %24, label %30 [
i32 97, label %25
i32 105, label %26
]
25: ; preds = %23
store i32 1, i32* %11
br label %38
26: ; preds = %23
%27 = load i32, i32* @SIGINT
%28 = load i32, i32* @SIG_IGN
%29 = call i32 @signal(i32 %27, i32 %28)
br label %38
30: ; preds = %23
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %26, %25
br label %18
39: ; preds = %18
%40 = load i32, i32* @optind
store i32 %40, i32* %8
br label %41
41: ; preds = %88, %39
%42 = load i32, i32* %8
%43 = load i32, i32* %4
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %91
45: ; preds = %41
%46 = load i32, i32* %11
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %58
48: ; preds = %45
%49 = load i8**, i8*** %5
%50 = load i32, i32* %8
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
%54 = call i32* @fopen(i8* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%55 = load i32, i32* %8
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32*, i32** %17, i64 %56
store i32* %54, i32** %57
br label %68
58: ; preds = %45
%59 = load i8**, i8*** %5
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32* @fopen(i8* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%65 = load i32, i32* %8
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32*, i32** %17, i64 %66
store i32* %64, i32** %67
br label %68
68: ; preds = %58, %48
%69 = load i32, i32* %8
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i32*, i32** %17, i64 %70
%72 = load i32*, i32** %71
%73 = icmp ne i32* %72, null
br i1 %73, label %74, label %81
74: ; preds = %68
%75 = load i32, i32* %8
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i32*, i32** %17, i64 %76
%78 = load i32*, i32** %77
%79 = load i32, i32* @_IONBF
%80 = call i32 @setvbuf(i32* %78, i32* null, i32 %79, i32 0)
br label %87
81: ; preds = %68
%82 = load i32, i32* @stderr
%83 = load i32, i32* @errno
%84 = call i8* @strerror(i32 %83)
%85 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %84)
%86 = load i32, i32* @EXIT_FAILURE
store i32 %86, i32* %9
br label %87
87: ; preds = %81, %74
br label %88
88: ; preds = %87
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
br label %41
91: ; preds = %41
br label %92
92: ; preds = %128, %91
br label %93
93: ; preds = %92
%94 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%95 = load i32, i32* @stdin
%96 = call i64 @fread(i8* %94, i32 1, i32 4096, i32 %95)
store i64 %96, i64* %13
%97 = load i32, i32* @optind
store i32 %97, i32* %8
br label %98
98: ; preds = %117, %93
%99 = load i32, i32* %8
%100 = load i32, i32* %4
%101 = icmp slt i32 %99, %100
br i1 %101, label %102, label %120
102: ; preds = %98
%103 = load i32, i32* %8
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i32*, i32** %17, i64 %104
%106 = load i32*, i32** %105
%107 = icmp ne i32* %106, null
br i1 %107, label %108, label %116
108: ; preds = %102
%109 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%110 = load i64, i64* %13
%111 = load i32, i32* %8
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i32*, i32** %17, i64 %112
%114 = load i32*, i32** %113
%115 = call i32 @fwrite(i8* %109, i32 1, i64 %110, i32* %114)
br label %116
116: ; preds = %108, %102
br label %117
117: ; preds = %116
%118 = load i32, i32* %8
%119 = add nsw i32 %118, 1
store i32 %119, i32* %8
br label %98
120: ; preds = %98
%121 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%122 = load i64, i64* %13
%123 = load i32*, i32** @stdout
%124 = call i32 @fwrite(i8* %121, i32 1, i64 %122, i32* %123)
%125 = load i64, i64* %13
%126 = icmp ult i64 %125, 4096
br i1 %126, label %127, label %128
127: ; preds = %120
br label %129
128: ; preds = %120
br label %92
129: ; preds = %127
%130 = load i32, i32* @optind
store i32 %130, i32* %8
br label %131
131: ; preds = %148, %129
%132 = load i32, i32* %8
%133 = load i32, i32* %4
%134 = icmp slt i32 %132, %133
br i1 %134, label %135, label %151
135: ; preds = %131
%136 = load i32, i32* %8
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i32*, i32** %17, i64 %137
%139 = load i32*, i32** %138
%140 = icmp ne i32* %139, null
br i1 %140, label %141, label %147
141: ; preds = %135
%142 = load i32, i32* %8
%143 = sext i32 %142 to i64
%144 = getelementptr inbounds i32*, i32** %17, i64 %143
%145 = load i32*, i32** %144
%146 = call i32 @fclose(i32* %145)
br label %147
147: ; preds = %141, %135
br label %148
148: ; preds = %147
%149 = load i32, i32* %8
%150 = add nsw i32 %149, 1
store i32 %150, i32* %8
br label %131
151: ; preds = %131
%152 = load i32, i32* %9
store i32 %152, i32* %3
%153 = load i8*, i8** %6
%154 = load i32, i32* %3
ret i32 %154
}

LLVM IR (-O2):
@.str = [3 x i8] c"ai\00"
@SIGINT = global i32 0
@SIG_IGN = global i32 0
@stderr = global i32 0
@.str.1 = [29 x i8] c"Usage: %s [\E2\88\92ai] [file...]\0A\00"
@EXIT_FAILURE = global i32 0
@optind = global i32 0
@.str.2 = [2 x i8] c"a\00"
@.str.3 = [2 x i8] c"w\00"
@_IONBF = global i32 0
@.str.4 = [11 x i8] c"ERROR: %s\0A\00"
@errno = global i32 0
@stdin = global i32 0
@stdout = global i32* null
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [4096 x i8]
%4 = zext i32 %0 to i64
%5 = alloca i32*, i64 %4
br label %6
6: ; preds = %8, %2
%7 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %2 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %8 ]
br label %8
8: ; preds = %6, %10
%9 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %9, label %14 [
i32 -1, label %20
i32 97, label %6
i32 105, label %10
]
10: ; preds = %8
%11 = load i32, i32* @SIGINT
%12 = load i32, i32* @SIG_IGN
%13 = tail call i32 @signal(i32 %11, i32 %12)
br label %8
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = tail call i32 @exit(i32 %18)
unreachable
20: ; preds = %8
%21 = load i32, i32* @optind
%22 = icmp slt i32 %21, %0
br i1 %22, label %23, label %47
23: ; preds = %20
%24 = sext i32 %21 to i64
br label %25
25: ; preds = %23, %42
%26 = phi i64 [ %24, %23 ], [ %44, %42 ]
%27 = phi i32 [ 0, %23 ], [ %43, %42 ]
%28 = getelementptr inbounds i8*, i8** %1, i64 %26
%29 = load i8*, i8** %28
%30 = tail call i32* @fopen(i8* %29, i8* %7)
%31 = getelementptr inbounds i32*, i32** %5, i64 %26
store i32* %30, i32** %31
%32 = icmp eq i32* %30, null
br i1 %32, label %36, label %33
33: ; preds = %25
%34 = load i32, i32* @_IONBF
%35 = tail call i32 @setvbuf(i32* %30, i32* null, i32 %34, i32 0)
br label %42
36: ; preds = %25
%37 = load i32, i32* @stderr
%38 = load i32, i32* @errno
%39 = tail call i8* @strerror(i32 %38)
%40 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %39)
%41 = load i32, i32* @EXIT_FAILURE
br label %42
42: ; preds = %33, %36
%43 = phi i32 [ %27, %33 ], [ %41, %36 ]
%44 = add nsw i64 %26, 1
%45 = trunc i64 %44 to i32
%46 = icmp eq i32 %45, %0
br i1 %46, label %47, label %25
47: ; preds = %42, %20
%48 = phi i32 [ 0, %20 ], [ %43, %42 ]
%49 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
br label %50
50: ; preds = %68, %47
%51 = load i32, i32* @stdin
%52 = call i64 @fread(i8* %49, i32 1, i32 4096, i32 %51)
%53 = load i32, i32* @optind
%54 = icmp slt i32 %53, %0
br i1 %54, label %55, label %68
55: ; preds = %50
%56 = sext i32 %53 to i64
br label %57
57: ; preds = %55, %64
%58 = phi i64 [ %56, %55 ], [ %65, %64 ]
%59 = getelementptr inbounds i32*, i32** %5, i64 %58
%60 = load i32*, i32** %59
%61 = icmp eq i32* %60, null
br i1 %61, label %64, label %62
62: ; preds = %57
%63 = call i32 @fwrite(i8* %49, i32 1, i64 %52, i32* %60)
br label %64
64: ; preds = %57, %62
%65 = add nsw i64 %58, 1
%66 = trunc i64 %65 to i32
%67 = icmp eq i32 %66, %0
br i1 %67, label %68, label %57
68: ; preds = %64, %50
%69 = load i32*, i32** @stdout
%70 = call i32 @fwrite(i8* %49, i32 1, i64 %52, i32* %69)
%71 = icmp ult i64 %52, 4096
br i1 %71, label %72, label %50
72: ; preds = %68
%73 = load i32, i32* @optind
%74 = icmp slt i32 %73, %0
br i1 %74, label %75, label %88
75: ; preds = %72
%76 = sext i32 %73 to i64
br label %77
77: ; preds = %75, %84
%78 = phi i64 [ %76, %75 ], [ %85, %84 ]
%79 = getelementptr inbounds i32*, i32** %5, i64 %78
%80 = load i32*, i32** %79
%81 = icmp eq i32* %80, null
br i1 %81, label %84, label %82
82: ; preds = %77
%83 = call i32 @fclose(i32* %80)
br label %84
84: ; preds = %77, %82
%85 = add nsw i64 %78, 1
%86 = trunc i64 %85 to i32
%87 = icmp eq i32 %86, %0
br i1 %87, label %88, label %77
88: ; preds = %84, %72
ret i32 %48
}