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

/* Variables and functions */
int O_CREAT;
int O_DIRECT;
int O_SYNC;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ fdatasync(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
char *getenv(char *);
int getopt(int, char **, char *);
int open(char *, int, int);
int *optarg;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void *strtol(int *, int /*<<< orphan*/ *, int /*<<< orphan*/);
size_t write(int, void *, size_t);
int main(int argc, char **argv) {
  char *tmpdir;
  char *ofile = NULL;
  int oflag = 0;
  size_t bsize = 512;
  void *buffer;
  int nwrites = 1000;
  int ofd;
  int info = 0;
  int c;
  char outpath[128];
  while (-1 != (c = getopt(argc, argv, "o:m:b:n:i"))) {
    switch (c) {
    case 'o': {
      ofile = optarg;
      break;
    }
    case 'm': {
      switch (*optarg) {
      case 'b':
        oflag = 0;
        break;
      case 's':
        oflag = O_SYNC;
        break;
      case 'd':
        oflag = O_DIRECT;
        break;
      default:
        fprintf(stderr, "? -m %c\n", *optarg);
        return -1;
      }
      break;
    }
    case 'b': {
      bsize = strtol(optarg, NULL, 0);
      break;
    }
    case 'n': {
      nwrites = strtol(optarg, NULL, 0);
      break;
    }
    case 'i': {
      info = 1;
      break;
    }
    default:
      return -1;
    }
  }
  if (ofile)
    strcpy(outpath, ofile);
  else {
    tmpdir = getenv("TMPDIR");
    if (!tmpdir)
      tmpdir = "/var/tmp";
    strcpy(outpath, tmpdir);
    strcat(outpath, "/dirio.out");
  }
  oflag |= O_WRONLY | O_CREAT | O_TRUNC;
  ofd = open(outpath, oflag, 0644);
  if (-1 == ofd) {
    char msg[256];
    sprintf(msg, "open(%s,0x%x,0644)", outpath, oflag);
    perror(msg);
    return -1;
  }
  if (oflag & O_DIRECT) {
  } else {
  }
  for (c = 0; c < nwrites; ++c) {
    if (bsize != (write(ofd, buffer, bsize))) {
      char msg[80];
      sprintf(msg, "%d th write(%d,buffer,%d),%d", c + 1, ofd, bsize, errno);
      perror(msg);
      break;
    }
  }
  if (0 == (oflag & (O_DIRECT | O_SYNC)))
    fdatasync(ofd);
  close(ofd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x200,-0x30(%rbp)
movl   $0x3e8,-0x3c(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe2c(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,%ecx
mov    %ecx,-0x48(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     1365 <main+0x1a5>
mov    -0x48(%rbp),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x228(%rbp)
sub    $0xd,%eax
ja     1354 <main+0x194>
mov    -0x228(%rbp),%rax
lea    0xdb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d97(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1360 <main+0x1a0>
mov    0x2d84(%rip),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x22c(%rbp)
sub    $0x62,%eax
je     12ad <main+0xed>
jmp    1285 <main+0xc5>
mov    -0x22c(%rbp),%eax
sub    $0x64,%eax
je     12ca <main+0x10a>
jmp    1299 <main+0xd9>
mov    -0x22c(%rbp),%eax
sub    $0x73,%eax
je     12b9 <main+0xf9>
jmp    12db <main+0x11b>
movl   $0x0,-0x24(%rbp)
jmp    1308 <main+0x148>
mov    0x2d10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1308 <main+0x148>
mov    0x2cf7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    1308 <main+0x148>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
mov    0x2d05(%rip),%rax
mov    (%rax),%rax
mov    (%rax),%edx
lea    0xd4b(%rip),%rsi
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1533 <main+0x373>
jmp    1360 <main+0x1a0>
mov    0x2cdc(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %rax,-0x30(%rbp)
jmp    1360 <main+0x1a0>
mov    0x2cbe(%rip),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,-0x3c(%rbp)
jmp    1360 <main+0x1a0>
movl   $0x1,-0x44(%rbp)
jmp    1360 <main+0x1a0>
movl   $0xffffffff,-0x4(%rbp)
jmp    1533 <main+0x373>
jmp    11fe <main+0x3e>
cmpq   $0x0,-0x20(%rbp)
je     1385 <main+0x1c5>
lea    -0xd0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcpy@plt>
jmp    13ce <main+0x20e>
lea    0xcbf(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    13ab <main+0x1eb>
lea    0xcab(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
lea    -0xd0(%rbp),%rdi
lea    0xc92(%rip),%rsi
call   10d0 <strcat@plt>
mov    0x2bcb(%rip),%rax
mov    (%rax),%eax
mov    0x2c1a(%rip),%rcx
or     (%rcx),%eax
mov    0x2c01(%rip),%rcx
or     (%rcx),%eax
or     -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x1a4,%edx
call   10a0 <open@plt>
mov    %eax,-0x40(%rbp)
mov    $0xffffffff,%eax
cmp    -0x40(%rbp),%eax
jne    144b <main+0x28b>
lea    -0x1d0(%rbp),%rdi
lea    -0xd0(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    0xc3a(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
lea    -0x1d0(%rbp),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1533 <main+0x373>
mov    -0x24(%rbp),%eax
mov    0x2b73(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1465 <main+0x2a5>
jmp    146a <main+0x2aa>
jmp    146a <main+0x2aa>
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    14fb <main+0x33b>
mov    -0x30(%rbp),%rax
mov    %rax,-0x238(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1060 <write@plt>
mov    %rax,%rcx
mov    -0x238(%rbp),%rax
cmp    %rcx,%rax
je     14e8 <main+0x328>
lea    -0x220(%rbp),%rdi
mov    -0x48(%rbp),%edx
add    $0x1,%edx
mov    -0x40(%rbp),%ecx
mov    -0x30(%rbp),%r8
mov    0x2aea(%rip),%rax
mov    (%rax),%r9d
lea    0xba9(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
lea    -0x220(%rbp),%rdi
call   10b0 <perror@plt>
jmp    14fb <main+0x33b>
jmp    14ed <main+0x32d>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1471 <main+0x2b1>
mov    -0x24(%rbp),%ecx
mov    0x2ac3(%rip),%rax
mov    (%rax),%eax
mov    0x2ac2(%rip),%rdx
or     (%rdx),%eax
and    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    1524 <main+0x364>
mov    -0x40(%rbp),%edi
call   1040 <fdatasync@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x198,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x3e8,%r15d
mov    $0x200,%r12d
xor    %eax,%eax
mov    %rax,(%rsp)
lea    0xe49(%rip),%r13
lea    0xe0a(%rip),%r14
xor    %eax,%eax
mov    %rax,0x8(%rsp)
nopl   (%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   10c0 <getopt@plt>
cmp    $0x69,%eax
je     1200 <main+0x40>
lea    -0x62(%rax),%ecx
cmp    $0xd,%ecx
ja     12af <main+0xef>
movslq (%r14,%rcx,4),%rax
add    %r14,%rax
jmp    *%rax
mov    0x2dc2(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %rax,%r12
jmp    1200 <main+0x40>
mov    0x2daa(%rip),%rax
mov    (%rax),%rax
mov    (%rax),%edx
mov    $0x0,%eax
mov    %rax,(%rsp)
cmp    $0x62,%edx
je     1200 <main+0x40>
cmp    $0x64,%edx
je     128b <main+0xcb>
cmp    $0x73,%edx
jne    13fd <main+0x23d>
mov    0x2d62(%rip),%rax
jmp    1292 <main+0xd2>
mov    0x2d79(%rip),%rax
mov    (%rax),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %rax,%r15
jmp    1200 <main+0x40>
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %rax,(%rsp)
jmp    1200 <main+0x40>
nopl   (%rax)
mov    0x2d49(%rip),%rax
mov    (%rax),%rax
jmp    11f8 <main+0x38>
cmp    $0xffffffff,%eax
jne    1412 <main+0x252>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     12ce <main+0x10e>
lea    0x10(%rsp),%rdi
call   1050 <strcpy@plt>
jmp    1304 <main+0x144>
lea    0xd76(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xd6e(%rip),%rsi
cmovne %rax,%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strcpy@plt>
lea    0xd5f(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
mov    (%rsp),%r14
mov    0x2c91(%rip),%rax
mov    0x2ce2(%rip),%rcx
mov    0x2ccb(%rip),%rdx
or     (%rax),%r14d
or     (%rcx),%r14d
or     (%rdx),%r14d
lea    0x10(%rsp),%rdi
mov    %r14d,%esi
mov    $0x1a4,%edx
call   10a0 <open@plt>
cmp    $0xffffffff,%eax
je     139b <main+0x1db>
mov    %eax,%ebx
test   %r15d,%r15d
jle    1372 <main+0x1b2>
neg    %r15d
mov    $0x1,%ebp
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r12,%rdx
call   1060 <write@plt>
cmp    %rax,%r12
jne    13c6 <main+0x206>
lea    (%r15,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    1350 <main+0x190>
mov    0x2c57(%rip),%rax
mov    (%rax),%eax
mov    0x2c46(%rip),%rcx
or     (%rcx),%eax
test   %r14d,%eax
jne    1390 <main+0x1d0>
mov    %ebx,%edi
call   1040 <fdatasync@plt>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %eax,%eax
jmp    1417 <main+0x257>
lea    0xcc4(%rip),%rsi
lea    0x90(%rsp),%rbx
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14d,%ecx
xor    %eax,%eax
call   10e0 <sprintf@plt>
mov    %rbx,%rdi
call   10b0 <perror@plt>
jmp    1412 <main+0x252>
mov    0x2be3(%rip),%rax
mov    (%rax),%r9d
lea    0xca2(%rip),%rsi
lea    0x90(%rsp),%r15
mov    %r15,%rdi
mov    %ebp,%edx
mov    %ebx,%ecx
mov    %r12,%r8
xor    %eax,%eax
call   10e0 <sprintf@plt>
mov    %r15,%rdi
call   10b0 <perror@plt>
jmp    1372 <main+0x1b2>
mov    0x2bb4(%rip),%rax
mov    (%rax),%edi
lea    0xc35(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"o:m:b:n:i\00"
@optarg = global i32* null
@O_SYNC = global i32 0
@O_DIRECT = global i32 0
@stderr = global i32 0
@.str.1 = [9 x i8] c"? -m %c\0A\00"
@.str.2 = [7 x i8] c"TMPDIR\00"
@.str.3 = [9 x i8] c"/var/tmp\00"
@.str.4 = [11 x i8] c"/dirio.out\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.5 = [19 x i8] c"open(%s,0x%x,0644)\00"
@.str.6 = [29 x i8] c"%d th write(%d,buffer,%d),%d\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca [128 x i8]
%16 = alloca [256 x i8]
%17 = alloca [80 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %7
store i32 0, i32* %8
store i64 512, i64* %9
store i32 1000, i32* %11
store i32 0, i32* %13
br label %18
18: ; preds = %52, %2
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @getopt(i32 %19, i8** %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %21, i32* %14
%22 = icmp ne i32 -1, %21
br i1 %22, label %23, label %53
23: ; preds = %18
%24 = load i32, i32* %14
switch i32 %24, label %51 [
i32 111, label %25
i32 109, label %28
i32 98, label %42
i32 110, label %46
i32 105, label %50
]
25: ; preds = %23
%26 = load i32*, i32** @optarg
%27 = bitcast i32* %26 to i8*
store i8* %27, i8** %7
br label %52
28: ; preds = %23
%29 = load i32*, i32** @optarg
%30 = load i32, i32* %29
switch i32 %30, label %36 [
i32 98, label %31
i32 115, label %32
i32 100, label %34
]
31: ; preds = %28
store i32 0, i32* %8
br label %41
32: ; preds = %28
%33 = load i32, i32* @O_SYNC
store i32 %33, i32* %8
br label %41
34: ; preds = %28
%35 = load i32, i32* @O_DIRECT
store i32 %35, i32* %8
br label %41
36: ; preds = %28
%37 = load i32, i32* @stderr
%38 = load i32*, i32** @optarg
%39 = load i32, i32* %38
%40 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %39)
store i32 -1, i32* %3
br label %137
41: ; preds = %34, %32, %31
br label %52
42: ; preds = %23
%43 = load i32*, i32** @optarg
%44 = call i8* @strtol(i32* %43, i32* null, i32 0)
%45 = ptrtoint i8* %44 to i64
store i64 %45, i64* %9
br label %52
46: ; preds = %23
%47 = load i32*, i32** @optarg
%48 = call i8* @strtol(i32* %47, i32* null, i32 0)
%49 = ptrtoint i8* %48 to i32
store i32 %49, i32* %11
br label %52
50: ; preds = %23
store i32 1, i32* %13
br label %52
51: ; preds = %23
store i32 -1, i32* %3
br label %137
52: ; preds = %50, %46, %42, %41, %25
br label %18
53: ; preds = %18
%54 = load i8*, i8** %7
%55 = icmp ne i8* %54, null
br i1 %55, label %56, label %60
56: ; preds = %53
%57 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%58 = load i8*, i8** %7
%59 = call i32 @strcpy(i8* %57, i8* %58)
br label %71
60: ; preds = %53
%61 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i8* %61, i8** %6
%62 = load i8*, i8** %6
%63 = icmp ne i8* %62, null
br i1 %63, label %65, label %64
64: ; preds = %60
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8** %6
br label %65
65: ; preds = %64, %60
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%67 = load i8*, i8** %6
%68 = call i32 @strcpy(i8* %66, i8* %67)
%69 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%70 = call i32 @strcat(i8* %69, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %71
71: ; preds = %65, %56
%72 = load i32, i32* @O_WRONLY
%73 = load i32, i32* @O_CREAT
%74 = or i32 %72, %73
%75 = load i32, i32* @O_TRUNC
%76 = or i32 %74, %75
%77 = load i32, i32* %8
%78 = or i32 %77, %76
store i32 %78, i32* %8
%79 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%80 = load i32, i32* %8
%81 = call i32 @open(i8* %79, i32 %80, i32 420)
store i32 %81, i32* %12
%82 = load i32, i32* %12
%83 = icmp eq i32 -1, %82
br i1 %83, label %84, label %91
84: ; preds = %71
%85 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%86 = getelementptr inbounds [128 x i8], [128 x i8]* %15, i64 0, i64 0
%87 = load i32, i32* %8
%88 = call i32 (i8*, i8*, ...) @sprintf(i8* %85, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %86, i32 %87)
%89 = getelementptr inbounds [256 x i8], [256 x i8]* %16, i64 0, i64 0
%90 = call i32 @perror(i8* %89)
store i32 -1, i32* %3
br label %137
91: ; preds = %71
%92 = load i32, i32* %8
%93 = load i32, i32* @O_DIRECT
%94 = and i32 %92, %93
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %97
96: ; preds = %91
br label %98
97: ; preds = %91
br label %98
98: ; preds = %97, %96
store i32 0, i32* %14
br label %99
99: ; preds = %121, %98
%100 = load i32, i32* %14
%101 = load i32, i32* %11
%102 = icmp slt i32 %100, %101
br i1 %102, label %103, label %124
103: ; preds = %99
%104 = load i64, i64* %9
%105 = load i32, i32* %12
%106 = load i8*, i8** %10
%107 = load i64, i64* %9
%108 = call i64 @write(i32 %105, i8* %106, i64 %107)
%109 = icmp ne i64 %104, %108
br i1 %109, label %110, label %120
110: ; preds = %103
%111 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%112 = load i32, i32* %14
%113 = add nsw i32 %112, 1
%114 = load i32, i32* %12
%115 = load i64, i64* %9
%116 = load i32, i32* @errno
%117 = call i32 (i8*, i8*, ...) @sprintf(i8* %111, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %113, i32 %114, i64 %115, i32 %116)
%118 = getelementptr inbounds [80 x i8], [80 x i8]* %17, i64 0, i64 0
%119 = call i32 @perror(i8* %118)
br label %124
120: ; preds = %103
br label %121
121: ; preds = %120
%122 = load i32, i32* %14
%123 = add nsw i32 %122, 1
store i32 %123, i32* %14
br label %99
124: ; preds = %110, %99
%125 = load i32, i32* %8
%126 = load i32, i32* @O_DIRECT
%127 = load i32, i32* @O_SYNC
%128 = or i32 %126, %127
%129 = and i32 %125, %128
%130 = icmp eq i32 0, %129
br i1 %130, label %131, label %134
131: ; preds = %124
%132 = load i32, i32* %12
%133 = call i32 @fdatasync(i32 %132)
br label %134
134: ; preds = %131, %124
%135 = load i32, i32* %12
%136 = call i32 @close(i32 %135)
store i32 0, i32* %3
br label %137
137: ; preds = %134, %84, %51, %36
%138 = load i32, i32* %3
ret i32 %138
}

LLVM IR (-O2):
@.str = [10 x i8] c"o:m:b:n:i\00"
@optarg = global i32* null
@O_SYNC = global i32 0
@O_DIRECT = global i32 0
@stderr = global i32 0
@.str.1 = [9 x i8] c"? -m %c\0A\00"
@.str.2 = [7 x i8] c"TMPDIR\00"
@.str.3 = [9 x i8] c"/var/tmp\00"
@.str.4 = [11 x i8] c"/dirio.out\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.5 = [19 x i8] c"open(%s,0x%x,0644)\00"
@.str.6 = [29 x i8] c"%d th write(%d,buffer,%d),%d\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [128 x i8]
%4 = alloca [256 x i8]
%5 = alloca [80 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
br label %7
7: ; preds = %32, %2
%8 = phi i32 [ 0, %2 ], [ %33, %32 ]
%9 = phi i64 [ 512, %2 ], [ %13, %32 ]
%10 = phi i8* [ null, %2 ], [ %17, %32 ]
%11 = phi i32 [ 1000, %2 ], [ %20, %32 ]
br label %12
12: ; preds = %7, %37
%13 = phi i64 [ %9, %7 ], [ %40, %37 ]
%14 = phi i8* [ %10, %7 ], [ %17, %37 ]
%15 = phi i32 [ %11, %7 ], [ %20, %37 ]
br label %16
16: ; preds = %12, %23
%17 = phi i8* [ %14, %12 ], [ %24, %23 ]
%18 = phi i32 [ %15, %12 ], [ %20, %23 ]
br label %19
19: ; preds = %16, %41
%20 = phi i32 [ %18, %16 ], [ %45, %41 ]
br label %21
21: ; preds = %19, %21
%22 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
switch i32 %22, label %94 [
i32 -1, label %46
i32 111, label %23
i32 109, label %25
i32 98, label %37
i32 110, label %41
i32 105, label %21
]
23: ; preds = %21
%24 = load i8*, i8** bitcast (i32** @optarg to i8**)
br label %16
25: ; preds = %21
%26 = load i32*, i32** @optarg
%27 = load i32, i32* %26
switch i32 %27, label %34 [
i32 98, label %32
i32 115, label %28
i32 100, label %30
]
28: ; preds = %25
%29 = load i32, i32* @O_SYNC
br label %32
30: ; preds = %25
%31 = load i32, i32* @O_DIRECT
br label %32
32: ; preds = %30, %28, %25
%33 = phi i32 [ 0, %25 ], [ %29, %28 ], [ %31, %30 ]
br label %7
34: ; preds = %25
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %94
37: ; preds = %21
%38 = load i32*, i32** @optarg
%39 = tail call i8* @strtol(i32* nocapture %38, i32* null, i32 0)
%40 = ptrtoint i8* %39 to i64
br label %12
41: ; preds = %21
%42 = load i32*, i32** @optarg
%43 = tail call i8* @strtol(i32* nocapture %42, i32* null, i32 0)
%44 = ptrtoint i8* %43 to i64
%45 = trunc i64 %44 to i32
br label %19
46: ; preds = %21
%47 = icmp eq i8* %17, null
br i1 %47, label %50, label %48
48: ; preds = %46
%49 = call i32 @strcpy(i8* %6, i8* %17)
br label %56
50: ; preds = %46
%51 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%52 = icmp eq i8* %51, null
%53 = select i1 %52, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %51
%54 = call i32 @strcpy(i8* %6, i8* %53)
%55 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %50, %48
%57 = load i32, i32* @O_WRONLY
%58 = load i32, i32* @O_CREAT
%59 = load i32, i32* @O_TRUNC
%60 = or i32 %57, %8
%61 = or i32 %60, %58
%62 = or i32 %61, %59
%63 = call i32 @open(i8* %6, i32 %62, i32 420)
%64 = icmp eq i32 %63, -1
br i1 %64, label %67, label %65
65: ; preds = %56
%66 = icmp sgt i32 %20, 0
br i1 %66, label %71, label %84
67: ; preds = %56
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%69 = call i32 (i8*, i8*, ...) @sprintf(i8* %68, i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %6, i32 %62)
%70 = call i32 @perror(i8* %68)
br label %94
71: ; preds = %65, %81
%72 = phi i32 [ %82, %81 ], [ 0, %65 ]
%73 = call i64 @write(i32 %63, i8* undef, i64 %13)
%74 = icmp eq i64 %13, %73
br i1 %74, label %81, label %75
75: ; preds = %71
%76 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%77 = add nuw nsw i32 %72, 1
%78 = load i32, i32* @errno
%79 = call i32 (i8*, i8*, ...) @sprintf(i8* %76, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %77, i32 %63, i64 %13, i32 %78)
%80 = call i32 @perror(i8* %76)
br label %84
81: ; preds = %71
%82 = add nuw nsw i32 %72, 1
%83 = icmp eq i32 %82, %20
br i1 %83, label %84, label %71
84: ; preds = %81, %65, %75
%85 = load i32, i32* @O_DIRECT
%86 = load i32, i32* @O_SYNC
%87 = or i32 %86, %85
%88 = and i32 %87, %62
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %84
%91 = call i32 @fdatasync(i32 %63)
br label %92
92: ; preds = %90, %84
%93 = call i32 @close(i32 %63)
br label %94
94: ; preds = %21, %92, %67, %34
%95 = phi i32 [ -1, %34 ], [ -1, %67 ], [ 0, %92 ], [ -1, %21 ]
ret i32 %95
}