#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 */
struct stat {
  unsigned long long st_size;
};

/* Variables and functions */
int O_CREAT;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ STDIN_FILENO;
int S_IRWXG;
int S_IRWXU;
unsigned long long atoll(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ isprint(char);
int open(char *, int, int);
char *optarg;
scalar_t__ opterr;
int optind;
char optopt;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
size_t read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ usage();
size_t write(int, char *, size_t);
int main(int argc, char **argv) {
  char *fname = NULL;
  unsigned long long maxfsize = 5368709120;
  int index;
  int opt;
  char buf[4096];
  size_t written;
  size_t nread;
  size_t nwrit;
  int status = 0;
  int fh;
  struct stat sb;
  opterr = 0;
  while ((opt = getopt(argc, argv, "m:f:")) != -1) {
    switch (opt) {
    case 'm':
      maxfsize = atoll(optarg);
      break;
    case 'f':
      fname = optarg;
      break;
    case '?':
      if (optopt == 'm' || optopt == 'f')
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      else if (isprint(optopt))
        fprintf(stderr, "Unknown option '-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character '\\x%x'.\n", optopt);
      usage();
      return 1;
    default:
      usage();
      return 1;
    }
  }
  for (index = optind; index < argc; ++index) {
    fprintf(stderr, "Unknown argument: '%s'.\n", argv[index]);
    usage();
    return 1;
  }
  if ((NULL == fname) || (1 > strlen(fname))) {
    fprintf(stderr, "No filename given!\n");
    usage();
    return 1;
  }
  fh = open(fname, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG);
  if (-1 == fh) {
    perror("Cannot open file");
    return 1;
  }
  while (1) {
    nread = read(STDIN_FILENO, buf, sizeof buf);
    if (0 == nread) {
      break;
    }
    stat(fname, &sb);
    if (sb.st_size > maxfsize) {
      printf("File exceeded limit, emptying file and exiting.\n");
      close(fh);
      fh = open(fname, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG);
      status = 1;
      break;
    }
    written = 0;
    while (written < nread) {
      nwrit = write(fh, buf + written, nread - written);
      if (written < 1)
        break;
      written += nwrit;
    }
  }
  close(fh);
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movabs $0x140000000,%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x104c(%rbp)
mov    0x2d90(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xddb(%rip),%rdx
call   10f0 <getopt@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
je     137b <main+0x1ab>
mov    -0x28(%rbp),%eax
mov    %eax,-0x105c(%rbp)
sub    $0x3f,%eax
je     12a0 <main+0xd0>
jmp    124d <main+0x7d>
mov    -0x105c(%rbp),%eax
sub    $0x66,%eax
je     128d <main+0xbd>
jmp    1261 <main+0x91>
mov    -0x105c(%rbp),%eax
sub    $0x6d,%eax
jne    1363 <main+0x193>
jmp    1275 <main+0xa5>
mov    0x2d74(%rip),%rax
mov    (%rax),%rdi
call   1080 <atoll@plt>
mov    %rax,-0x20(%rbp)
jmp    1376 <main+0x1a6>
mov    0x2d5c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1376 <main+0x1a6>
mov    0x2d19(%rip),%rax
movsbl (%rax),%eax
cmp    $0x6d,%eax
je     12c6 <main+0xf6>
mov    0x2d06(%rip),%rax
movsbl (%rax),%eax
cmp    $0x66,%eax
jne    12ec <main+0x11c>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
mov    0x2cea(%rip),%rax
movsbl (%rax),%edx
lea    0xd25(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1350 <main+0x180>
mov    0x2ccd(%rip),%rax
movsbl (%rax),%edi
call   10c0 <isprint@plt>
cmp    $0x0,%eax
je     132a <main+0x15a>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
mov    0x2cac(%rip),%rax
movsbl (%rax),%edx
lea    0xd09(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    134b <main+0x17b>
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
mov    0x2c86(%rip),%rax
movsbl (%rax),%edx
lea    0xcfa(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1350 <main+0x180>
mov    $0x0,%al
call   10b0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    15cc <main+0x3fc>
mov    $0x0,%al
call   10b0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    15cc <main+0x3fc>
jmp    1217 <main+0x47>
mov    0x2c36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13c9 <main+0x1f9>
mov    0x2c0e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xcb1(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10b0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    15cc <main+0x3fc>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     13ed <main+0x21d>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jle    1417 <main+0x247>
mov    0x2bb4(%rip),%rax
mov    (%rax),%edi
lea    0xc7c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x0,%al
call   10b0 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    15cc <main+0x3fc>
mov    -0x18(%rbp),%rdi
mov    0x2b66(%rip),%rax
mov    (%rax),%esi
mov    0x2bcd(%rip),%rax
or     (%rax),%esi
mov    0x2bb4(%rip),%rax
or     (%rax),%esi
mov    0x2b93(%rip),%rax
mov    (%rax),%edx
mov    0x2b82(%rip),%rax
or     (%rax),%edx
call   10d0 <open@plt>
mov    %eax,-0x1050(%rbp)
mov    $0xffffffff,%eax
cmp    -0x1050(%rbp),%eax
jne    147c <main+0x2ac>
lea    0xc22(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    15cc <main+0x3fc>
jmp    1481 <main+0x2b1>
mov    0x2b10(%rip),%rax
mov    (%rax),%edi
lea    -0x1030(%rbp),%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
mov    %rax,-0x1040(%rbp)
xor    %eax,%eax
cmp    -0x1040(%rbp),%rax
jne    14b6 <main+0x2e6>
jmp    15b8 <main+0x3e8>
mov    -0x18(%rbp),%rdi
lea    -0x1058(%rbp),%rsi
call   10a0 <stat@plt>
mov    -0x1058(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    1539 <main+0x369>
lea    0xbc0(%rip),%rdi
call   1050 <printf@plt>
mov    -0x1050(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%rdi
mov    0x2a8f(%rip),%rax
mov    (%rax),%esi
mov    0x2af6(%rip),%rax
or     (%rax),%esi
mov    0x2add(%rip),%rax
or     (%rax),%esi
mov    0x2abc(%rip),%rax
mov    (%rax),%edx
mov    0x2aab(%rip),%rax
or     (%rax),%edx
call   10d0 <open@plt>
mov    %eax,-0x1050(%rbp)
movl   $0x1,-0x104c(%rbp)
jmp    15b8 <main+0x3e8>
movq   $0x0,-0x1038(%rbp)
mov    -0x1038(%rbp),%rax
cmp    -0x1040(%rbp),%rax
jae    15b3 <main+0x3e3>
mov    -0x1050(%rbp),%edi
lea    -0x1030(%rbp),%rsi
add    -0x1038(%rbp),%rsi
mov    -0x1040(%rbp),%rdx
sub    -0x1038(%rbp),%rdx
call   1030 <write@plt>
mov    %rax,-0x1048(%rbp)
cmpq   $0x1,-0x1038(%rbp)
01
jae    1599 <main+0x3c9>
jmp    15b3 <main+0x3e3>
mov    -0x1048(%rbp),%rax
add    -0x1038(%rbp),%rax
mov    %rax,-0x1038(%rbp)
jmp    1544 <main+0x374>
jmp    1481 <main+0x2b1>
mov    -0x1050(%rbp),%edi
call   1060 <close@plt>
mov    -0x104c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
mov    0x2db3(%rip),%rax
movq   $0x0,(%rax)
movabs $0x140000000,%r14
xor    %r12d,%r12d
lea    0xdf8(%rip),%r15
mov    0x2de1(%rip),%r13
jmp    1224 <main+0x54>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%r13),%r12
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
call   10f0 <getopt@plt>
cmp    $0x66,%eax
je     1220 <main+0x50>
cmp    $0xffffffff,%eax
je     1257 <main+0x87>
cmp    $0x3f,%eax
je     1286 <main+0xb6>
cmp    $0x6d,%eax
jne    13d1 <main+0x201>
mov    0x0(%r13),%rdi
call   1080 <atoll@plt>
mov    %rax,%r14
jmp    1224 <main+0x54>
mov    0x2d5a(%rip),%rax
movslq (%rax),%rax
cmp    %ebx,%eax
jge    12b3 <main+0xe3>
mov    0x2d3c(%rip),%rcx
mov    (%rcx),%edi
mov    0x0(%rbp,%rax,8),%rdx
lea    0xde6(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13d1 <main+0x201>
mov    0x2d33(%rip),%rbx
movzbl (%rbx),%edx
cmp    $0x6d,%edx
je     129e <main+0xce>
cmp    $0x66,%dl
jne    1389 <main+0x1b9>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
lea    0xd57(%rip),%rsi
jmp    13ca <main+0x1fa>
test   %r12,%r12
je     13aa <main+0x1da>
mov    %r12,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    13aa <main+0x1da>
mov    0x2cb5(%rip),%rax
mov    0x2d1e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d03(%rip),%rax
or     (%rax),%esi
mov    0x2ce2(%rip),%rax
mov    0x2cd3(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %r12,%rdi
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     144c <main+0x27c>
mov    %eax,%r15d
mov    0x2c84(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1442 <main+0x272>
mov    %rax,%r13
lea    0x10(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
lea    0x8(%rsp),%rsi
call   10a0 <stat@plt>
cmp    %r14,0x8(%rsp)
ja     13f1 <main+0x221>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1040 <write@plt>
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
mov    %rax,%r13
test   %rax,%rax
jne    1340 <main+0x170>
jmp    1442 <main+0x272>
movsbl %dl,%edi
call   10c0 <isprint@plt>
mov    0x2c10(%rip),%rcx
mov    (%rcx),%edi
movsbl (%rbx),%edx
test   %eax,%eax
je     13c3 <main+0x1f3>
lea    0xc7f(%rip),%rsi
jmp    13ca <main+0x1fa>
mov    0x2bf7(%rip),%rax
mov    (%rax),%edi
lea    0xcbf(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    13d1 <main+0x201>
lea    0xc74(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
xor    %eax,%eax
call   10b0 <usage@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xca6(%rip),%rdi
call   1030 <puts@plt>
mov    %r15d,%edi
call   1060 <close@plt>
mov    0x2bec(%rip),%rax
mov    (%rax),%esi
mov    0x2b73(%rip),%rax
or     (%rax),%esi
mov    0x2bca(%rip),%rax
or     (%rax),%esi
mov    0x2ba1(%rip),%rax
mov    (%rax),%edx
mov    0x2ba0(%rip),%rax
or     (%rax),%edx
mov    %r12,%rdi
call   10d0 <open@plt>
mov    %eax,%r15d
mov    $0x1,%ebp
mov    %r15d,%edi
call   1060 <close@plt>
jmp    13dd <main+0x20d>
lea    0xc3a(%rip),%rdi
call   10e0 <perror@plt>
jmp    13d8 <main+0x208>

LLVM IR (-O0):
%struct.stat = type { i64 }
@opterr = global i64 0
@.str = [5 x i8] c"m:f:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option '-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character '\\x%x'.\0A\00"
@optind = global i32 0
@.str.4 = [25 x i8] c"Unknown argument: '%s'.\0A\00"
@.str.5 = [20 x i8] c"No filename given!\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@.str.6 = [17 x i8] c"Cannot open file\00"
@STDIN_FILENO = global i32 0
@.str.7 = [49 x i8] c"File exceeded limit, emptying file and exiting.\0A\00"
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 [4096 x i8]
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i32
%15 = alloca i32
%16 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i64 5368709120, i64* %7
store i32 0, i32* %14
store i64 0, i64* @opterr
br label %17
17: ; preds = %61, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt(i32 %18, i8** %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %9
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %62
22: ; preds = %17
%23 = load i32, i32* %9
switch i32 %23, label %59 [
i32 109, label %24
i32 102, label %27
i32 63, label %29
]
24: ; preds = %22
%25 = load i8*, i8** @optarg
%26 = call i64 @atoll(i8* %25)
store i64 %26, i64* %7
br label %61
27: ; preds = %22
%28 = load i8*, i8** @optarg
store i8* %28, i8** %6
br label %61
29: ; preds = %22
%30 = load i8, i8* @optopt
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 109
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i8, i8* @optopt
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 102
br i1 %36, label %37, label %42
37: ; preds = %33, %29
%38 = load i32, i32* @stderr
%39 = load i8, i8* @optopt
%40 = sext i8 %39 to i32
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %40)
br label %57
42: ; preds = %33
%43 = load i8, i8* @optopt
%44 = call i32 @isprint(i8 signext %43)
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = load i32, i32* @stderr
%48 = load i8, i8* @optopt
%49 = sext i8 %48 to i32
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %49)
br label %56
51: ; preds = %42
%52 = load i32, i32* @stderr
%53 = load i8, i8* @optopt
%54 = sext i8 %53 to i32
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %51, %46
br label %57
57: ; preds = %56, %37
%58 = call i32 (...) @usage()
store i32 1, i32* %3
br label %161
59: ; preds = %22
%60 = call i32 (...) @usage()
store i32 1, i32* %3
br label %161
61: ; preds = %27, %24
br label %17
62: ; preds = %17
%63 = load i32, i32* @optind
store i32 %63, i32* %8
br label %64
64: ; preds = %77, %62
%65 = load i32, i32* %8
%66 = load i32, i32* %4
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %80
68: ; preds = %64
%69 = load i32, i32* @stderr
%70 = load i8**, i8*** %5
%71 = load i32, i32* %8
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8*, i8** %70, i64 %72
%74 = load i8*, i8** %73
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %74)
%76 = call i32 (...) @usage()
store i32 1, i32* %3
br label %161
77: ; No predecessors!
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
br label %64
80: ; preds = %64
%81 = load i8*, i8** %6
%82 = icmp eq i8* null, %81
br i1 %82, label %87, label %83
83: ; preds = %80
%84 = load i8*, i8** %6
%85 = call i32 @strlen(i8* %84)
%86 = icmp sgt i32 1, %85
br i1 %86, label %87, label %91
87: ; preds = %83, %80
%88 = load i32, i32* @stderr
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%90 = call i32 (...) @usage()
store i32 1, i32* %3
br label %161
91: ; preds = %83
%92 = load i8*, i8** %6
%93 = load i32, i32* @O_WRONLY
%94 = load i32, i32* @O_CREAT
%95 = or i32 %93, %94
%96 = load i32, i32* @O_TRUNC
%97 = or i32 %95, %96
%98 = load i32, i32* @S_IRWXU
%99 = load i32, i32* @S_IRWXG
%100 = or i32 %98, %99
%101 = call i32 @open(i8* %92, i32 %97, i32 %100)
store i32 %101, i32* %15
%102 = load i32, i32* %15
%103 = icmp eq i32 -1, %102
br i1 %103, label %104, label %106
104: ; preds = %91
%105 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %161
106: ; preds = %91
br label %107
107: ; preds = %106, %156
%108 = load i32, i32* @STDIN_FILENO
%109 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%110 = call i64 @read(i32 %108, i8* %109, i32 4096)
store i64 %110, i64* %12
%111 = load i64, i64* %12
%112 = icmp eq i64 0, %111
br i1 %112, label %113, label %114
113: ; preds = %107
br label %157
114: ; preds = %107
%115 = load i8*, i8** %6
%116 = call i32 @stat(i8* %115, %struct.stat* %16)
%117 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%118 = load i64, i64* %117
%119 = load i64, i64* %7
%120 = icmp ugt i64 %118, %119
br i1 %120, label %121, label %135
121: ; preds = %114
%122 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.7, i64 0, i64 0))
%123 = load i32, i32* %15
%124 = call i32 @close(i32 %123)
%125 = load i8*, i8** %6
%126 = load i32, i32* @O_WRONLY
%127 = load i32, i32* @O_CREAT
%128 = or i32 %126, %127
%129 = load i32, i32* @O_TRUNC
%130 = or i32 %128, %129
%131 = load i32, i32* @S_IRWXU
%132 = load i32, i32* @S_IRWXG
%133 = or i32 %131, %132
%134 = call i32 @open(i8* %125, i32 %130, i32 %133)
store i32 %134, i32* %15
store i32 1, i32* %14
br label %157
135: ; preds = %114
store i64 0, i64* %11
br label %136
136: ; preds = %152, %135
%137 = load i64, i64* %11
%138 = load i64, i64* %12
%139 = icmp ult i64 %137, %138
br i1 %139, label %140, label %156
140: ; preds = %136
%141 = load i32, i32* %15
%142 = getelementptr inbounds [4096 x i8], [4096 x i8]* %10, i64 0, i64 0
%143 = load i64, i64* %11
%144 = getelementptr inbounds i8, i8* %142, i64 %143
%145 = load i64, i64* %12
%146 = load i64, i64* %11
%147 = sub i64 %145, %146
%148 = call i64 @write(i32 %141, i8* %144, i64 %147)
store i64 %148, i64* %13
%149 = load i64, i64* %11
%150 = icmp ult i64 %149, 1
br i1 %150, label %151, label %152
151: ; preds = %140
br label %156
152: ; preds = %140
%153 = load i64, i64* %13
%154 = load i64, i64* %11
%155 = add i64 %154, %153
store i64 %155, i64* %11
br label %136
156: ; preds = %151, %136
br label %107
157: ; preds = %121, %113
%158 = load i32, i32* %15
%159 = call i32 @close(i32 %158)
%160 = load i32, i32* %14
store i32 %160, i32* %3
br label %161
161: ; preds = %157, %104, %87, %68, %59, %57
%162 = load i32, i32* %3
ret i32 %162
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@opterr = global i64 0
@.str = [5 x i8] c"m:f:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option '-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character '\\x%x'.\0A\00"
@optind = global i32 0
@.str.4 = [25 x i8] c"Unknown argument: '%s'.\0A\00"
@.str.5 = [20 x i8] c"No filename given!\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRWXU = global i32 0
@S_IRWXG = global i32 0
@.str.6 = [17 x i8] c"Cannot open file\00"
@STDIN_FILENO = global i32 0
@str = [48 x i8] c"File exceeded limit, emptying file and exiting.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [4096 x i8]
%4 = alloca %struct.stat
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.stat* %4 to i8*
store i64 0, i64* @opterr
br label %7
7: ; preds = %13, %2
%8 = phi i64 [ %15, %13 ], [ 5368709120, %2 ]
%9 = phi i8* [ %11, %13 ], [ null, %2 ]
br label %10
10: ; preds = %7, %16
%11 = phi i8* [ %17, %16 ], [ %9, %7 ]
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %36 [
i32 -1, label %38
i32 109, label %13
i32 102, label %16
i32 63, label %18
]
13: ; preds = %10
%14 = load i8*, i8** @optarg
%15 = tail call i64 @atoll(i8* %14)
br label %7
16: ; preds = %10
%17 = load i8*, i8** @optarg
br label %10
18: ; preds = %10
%19 = load i8, i8* @optopt
switch i8 %19, label %24 [
i8 109, label %20
i8 102, label %20
]
20: ; preds = %18, %18
%21 = zext i8 %19 to i32
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %34
24: ; preds = %18
%25 = tail call i32 @isprint(i8 signext %19)
%26 = icmp eq i32 %25, 0
%27 = load i32, i32* @stderr
%28 = load i8, i8* @optopt
%29 = sext i8 %28 to i32
br i1 %26, label %32, label %30
30: ; preds = %24
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %34
32: ; preds = %24
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %34
34: ; preds = %30, %32, %20
%35 = tail call i32 (...) @usage()
br label %102
36: ; preds = %10
%37 = tail call i32 (...) @usage()
br label %102
38: ; preds = %10
%39 = load i32, i32* @optind
%40 = icmp slt i32 %39, %0
br i1 %40, label %41, label %48
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = sext i32 %39 to i64
%44 = getelementptr inbounds i8*, i8** %1, i64 %43
%45 = load i8*, i8** %44
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %45)
%47 = tail call i32 (...) @usage()
br label %102
48: ; preds = %38
%49 = icmp eq i8* %11, null
br i1 %49, label %53, label %50
50: ; preds = %48
%51 = tail call i32 @strlen(i8* %11)
%52 = icmp slt i32 %51, 1
br i1 %52, label %53, label %57
53: ; preds = %50, %48
%54 = load i32, i32* @stderr
%55 = tail call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%56 = tail call i32 (...) @usage()
br label %102
57: ; preds = %50
%58 = load i32, i32* @O_WRONLY
%59 = load i32, i32* @O_CREAT
%60 = or i32 %59, %58
%61 = load i32, i32* @O_TRUNC
%62 = or i32 %60, %61
%63 = load i32, i32* @S_IRWXU
%64 = load i32, i32* @S_IRWXG
%65 = or i32 %64, %63
%66 = tail call i32 @open(i8* %11, i32 %62, i32 %65)
%67 = icmp eq i32 %66, -1
br i1 %67, label %74, label %68
68: ; preds = %57
%69 = load i32, i32* @STDIN_FILENO
%70 = call i64 @read(i32 %69, i8* %5, i32 4096)
%71 = icmp eq i64 %70, 0
br i1 %71, label %98, label %72
72: ; preds = %68
%73 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
br label %76
74: ; preds = %57
%75 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %102
76: ; preds = %72, %93
%77 = phi i64 [ %70, %72 ], [ %96, %93 ]
%78 = call i32 @stat(i8* %11, %struct.stat* %4)
%79 = load i64, i64* %73
%80 = icmp ugt i64 %79, %8
br i1 %80, label %81, label %93
81: ; preds = %76
%82 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%83 = tail call i32 @close(i32 %66)
%84 = load i32, i32* @O_WRONLY
%85 = load i32, i32* @O_CREAT
%86 = or i32 %85, %84
%87 = load i32, i32* @O_TRUNC
%88 = or i32 %86, %87
%89 = load i32, i32* @S_IRWXU
%90 = load i32, i32* @S_IRWXG
%91 = or i32 %90, %89
%92 = tail call i32 @open(i8* %11, i32 %88, i32 %91)
br label %98
93: ; preds = %76
%94 = call i64 @write(i32 %66, i8* %5, i64 %77)
%95 = load i32, i32* @STDIN_FILENO
%96 = call i64 @read(i32 %95, i8* %5, i32 4096)
%97 = icmp eq i64 %96, 0
br i1 %97, label %98, label %76
98: ; preds = %93, %68, %81
%99 = phi i32 [ 1, %81 ], [ 0, %68 ], [ 0, %93 ]
%100 = phi i32 [ %92, %81 ], [ %66, %68 ], [ %66, %93 ]
%101 = tail call i32 @close(i32 %100)
br label %102
102: ; preds = %98, %74, %53, %41, %36, %34
%103 = phi i32 [ 1, %36 ], [ 1, %34 ], [ 1, %41 ], [ 1, %53 ], [ 1, %74 ], [ %99, %98 ]
ret i32 %103
}