#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_EXCL;
int O_RDONLY;
int O_RDWR;
int O_TRUNC;
int O_WRONLY;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int errno;
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, int, int, ...);
int /*<<< orphan*/ stop();
char *strerrno(int);
int test_open() {
  int ret;
  errno = 0;
  ret = open("foo.fileio.test", O_CREAT | O_TRUNC | O_RDWR, S_IWUSR | S_IRUSR);
  printf("open 1: ret = %d, errno = %d %s\n", ret, errno, ret >= 0 ? "OK" : "");
  if (ret >= 0)
    close(ret);
  stop();
  errno = 0;
  ret = open("foo.fileio.test", O_CREAT | O_EXCL | O_WRONLY, S_IWUSR | S_IRUSR);
  printf("open 2: ret = %d, errno = %d %s\n", ret, errno, strerrno(errno));
  if (ret >= 0)
    close(ret);
  stop();
  errno = 0;
  ret = open(".", O_WRONLY);
  printf("open 3: ret = %d, errno = %d %s\n", ret, errno, strerrno(errno));
  if (ret >= 0)
    close(ret);
  stop();
  errno = 0;
  ret = open("nofoo.fileio.test", O_RDONLY);
  printf("open 4: ret = %d, errno = %d %s\n", ret, errno, strerrno(errno));
  if (ret >= 0)
    close(ret);
  stop();
  errno = 0;
  ret = open("nowrt.fileio.test", O_CREAT | O_RDONLY, S_IRUSR);
  if (ret >= 0) {
    close(ret);
    stop();
    errno = 0;
    ret = open("nowrt.fileio.test", O_WRONLY);
    printf("open 5: ret = %d, errno = %d %s\n", ret, errno, strerrno(errno));
    if (ret >= 0)
      close(ret);
  } else {
    stop();
    printf("open 5: ret = %d, errno = %d\n", ret, errno);
  }
  stop();
}


x86 assembly (clang, -O0):
<test_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e51(%rip),%rax
movl   $0x0,(%rax)
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
mov    0x2e7b(%rip),%rax
or     (%rax),%esi
mov    0x2e5a(%rip),%rax
or     (%rax),%esi
mov    0x2e41(%rip),%rax
mov    (%rax),%edx
mov    0x2e18(%rip),%rax
or     (%rax),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    0x2e03(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%edi
lea    0xf32(%rip),%rcx
lea    0xe61(%rip),%rax
cmp    $0x0,%edi
cmovge %rax,%rcx
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     11e7 <test_open+0x97>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    $0x0,%al
call   1050 <stop@plt>
mov    0x2dbb(%rip),%rax
movl   $0x0,(%rax)
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
mov    0x2dad(%rip),%rax
or     (%rax),%esi
mov    0x2d84(%rip),%rax
or     (%rax),%esi
mov    0x2dab(%rip),%rax
mov    (%rax),%edx
mov    0x2d82(%rip),%rax
or     (%rax),%edx
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
call   1030 <strerrno@plt>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    %rax,%rcx
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1282 <test_open+0x132>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    $0x0,%al
call   1050 <stop@plt>
mov    0x2d20(%rip),%rax
movl   $0x0,(%rax)
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2cf3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
call   1030 <strerrno@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    %rax,%rcx
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     12f9 <test_open+0x1a9>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    $0x0,%al
call   1050 <stop@plt>
mov    0x2ca9(%rip),%rax
movl   $0x0,(%rax)
mov    0x2cbc(%rip),%rax
mov    (%rax),%esi
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2c7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
call   1030 <strerrno@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %rax,%rcx
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1370 <test_open+0x220>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    $0x0,%al
call   1050 <stop@plt>
mov    0x2c32(%rip),%rax
movl   $0x0,(%rax)
mov    0x2c6d(%rip),%rax
mov    (%rax),%esi
mov    0x2c3c(%rip),%rax
or     (%rax),%esi
mov    0x2c0b(%rip),%rax
mov    (%rax),%edx
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     143e <test_open+0x2ee>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
mov    $0x0,%al
call   1050 <stop@plt>
mov    0x2be0(%rip),%rax
movl   $0x0,(%rax)
mov    0x2bbb(%rip),%rax
mov    (%rax),%esi
lea    0xcb5(%rip),%rdi
mov    $0x0,%al
call   1070 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2bb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2ba7(%rip),%rax
mov    (%rax),%edi
call   1030 <strerrno@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    %rax,%rcx
lea    0xc8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1439 <test_open+0x2e9>
mov    -0x8(%rbp),%edi
call   1060 <close@plt>
jmp    145f <test_open+0x30f>
mov    $0x0,%al
call   1050 <stop@plt>
mov    -0x8(%rbp),%esi
mov    0x2b61(%rip),%rax
mov    (%rax),%edx
lea    0xc76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <stop@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_open>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e4e(%rip),%r14
movl   $0x0,(%r14)
mov    0x2e88(%rip),%r15
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
or     (%r15),%esi
mov    0x2e55(%rip),%rax
or     (%rax),%esi
mov    0x2e3c(%rip),%rbp
mov    0x2e15(%rip),%r12
mov    (%r12),%edx
or     0x0(%rbp),%edx
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%ebx
mov    (%r14),%edx
test   %eax,%eax
lea    0xe6b(%rip),%rax
lea    0xf2e(%rip),%rcx
cmovns %rax,%rcx
lea    0xe38(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     11dc <test_open+0x8c>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
call   1050 <stop@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
or     (%r15),%esi
mov    0x2da2(%rip),%r13
or     0x0(%r13),%esi
movl   $0x0,(%r14)
mov    (%r12),%edx
or     0x0(%rbp),%edx
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%ebx
mov    (%r14),%ebp
mov    %ebp,%edi
call   1030 <strerrno@plt>
lea    0xdfb(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     1242 <test_open+0xf2>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
call   1050 <stop@plt>
movl   $0x0,(%r14)
mov    0x0(%r13),%esi
lea    0xdea(%rip),%rdi
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%ebx
mov    (%r14),%ebp
mov    %ebp,%edi
call   1030 <strerrno@plt>
lea    0xdd2(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     128e <test_open+0x13e>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
call   1050 <stop@plt>
movl   $0x0,(%r14)
mov    0x2d2d(%rip),%r15
mov    (%r15),%esi
lea    0xdbb(%rip),%rdi
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%ebx
mov    (%r14),%ebp
mov    %ebp,%edi
call   1030 <strerrno@plt>
lea    0xdb3(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     12e0 <test_open+0x190>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
call   1050 <stop@plt>
movl   $0x0,(%r14)
mov    (%r15),%esi
mov    0x2d00(%rip),%rax
or     (%rax),%esi
mov    (%r12),%edx
lea    0xd96(%rip),%rdi
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1367 <test_open+0x217>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
call   1050 <stop@plt>
movl   $0x0,(%r14)
mov    0x0(%r13),%esi
lea    0xd69(%rip),%rdi
xor    %eax,%eax
call   1070 <open@plt>
mov    %eax,%ebx
mov    (%r14),%ebp
mov    %ebp,%edi
call   1030 <strerrno@plt>
lea    0xd61(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     1381 <test_open+0x231>
mov    %ebx,%edi
call   1060 <close@plt>
jmp    1381 <test_open+0x231>
xor    %eax,%eax
call   1050 <stop@plt>
mov    (%r14),%edx
lea    0xd56(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <stop@plt>

LLVM IR (-O0):
@errno = global i32 0
@.str = [16 x i8] c"foo.fileio.test\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@S_IWUSR = global i32 0
@S_IRUSR = global i32 0
@.str.1 = [33 x i8] c"open 1: ret = %d, errno = %d %s\0A\00"
@.str.2 = [3 x i8] c"OK\00"
@.str.3 = [1 x i8] zeroinitializer
@O_EXCL = global i32 0
@O_WRONLY = global i32 0
@.str.4 = [33 x i8] c"open 2: ret = %d, errno = %d %s\0A\00"
@.str.5 = [2 x i8] c".\00"
@.str.6 = [33 x i8] c"open 3: ret = %d, errno = %d %s\0A\00"
@.str.7 = [18 x i8] c"nofoo.fileio.test\00"
@O_RDONLY = global i32 0
@.str.8 = [33 x i8] c"open 4: ret = %d, errno = %d %s\0A\00"
@.str.9 = [18 x i8] c"nowrt.fileio.test\00"
@.str.10 = [33 x i8] c"open 5: ret = %d, errno = %d %s\0A\00"
@.str.11 = [30 x i8] c"open 5: ret = %d, errno = %d\0A\00"
define i32 @test_open() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* @errno
%3 = load i32, i32* @O_CREAT
%4 = load i32, i32* @O_TRUNC
%5 = or i32 %3, %4
%6 = load i32, i32* @O_RDWR
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IWUSR
%9 = load i32, i32* @S_IRUSR
%10 = or i32 %8, %9
%11 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = load i32, i32* @errno
%14 = load i32, i32* %2
%15 = icmp sge i32 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%18 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13, i8* %17)
%19 = load i32, i32* %2
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %0
%22 = load i32, i32* %2
%23 = call i32 @close(i32 %22)
br label %24
24: ; preds = %21, %0
%25 = call i32 (...) @stop()
store i32 0, i32* @errno
%26 = load i32, i32* @O_CREAT
%27 = load i32, i32* @O_EXCL
%28 = or i32 %26, %27
%29 = load i32, i32* @O_WRONLY
%30 = or i32 %28, %29
%31 = load i32, i32* @S_IWUSR
%32 = load i32, i32* @S_IRUSR
%33 = or i32 %31, %32
%34 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %30, i32 %33)
store i32 %34, i32* %2
%35 = load i32, i32* %2
%36 = load i32, i32* @errno
%37 = load i32, i32* @errno
%38 = call i8* @strerrno(i32 %37)
%39 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %36, i8* %38)
%40 = load i32, i32* %2
%41 = icmp sge i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %24
%43 = load i32, i32* %2
%44 = call i32 @close(i32 %43)
br label %45
45: ; preds = %42, %24
%46 = call i32 (...) @stop()
store i32 0, i32* @errno
%47 = load i32, i32* @O_WRONLY
%48 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %47)
store i32 %48, i32* %2
%49 = load i32, i32* %2
%50 = load i32, i32* @errno
%51 = load i32, i32* @errno
%52 = call i8* @strerrno(i32 %51)
%53 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %49, i32 %50, i8* %52)
%54 = load i32, i32* %2
%55 = icmp sge i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %45
%57 = load i32, i32* %2
%58 = call i32 @close(i32 %57)
br label %59
59: ; preds = %56, %45
%60 = call i32 (...) @stop()
store i32 0, i32* @errno
%61 = load i32, i32* @O_RDONLY
%62 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %61)
store i32 %62, i32* %2
%63 = load i32, i32* %2
%64 = load i32, i32* @errno
%65 = load i32, i32* @errno
%66 = call i8* @strerrno(i32 %65)
%67 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %63, i32 %64, i8* %66)
%68 = load i32, i32* %2
%69 = icmp sge i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %59
%71 = load i32, i32* %2
%72 = call i32 @close(i32 %71)
br label %73
73: ; preds = %70, %59
%74 = call i32 (...) @stop()
store i32 0, i32* @errno
%75 = load i32, i32* @O_CREAT
%76 = load i32, i32* @O_RDONLY
%77 = or i32 %75, %76
%78 = load i32, i32* @S_IRUSR
%79 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %77, i32 %78)
store i32 %79, i32* %2
%80 = load i32, i32* %2
%81 = icmp sge i32 %80, 0
br i1 %81, label %82, label %99
82: ; preds = %73
%83 = load i32, i32* %2
%84 = call i32 @close(i32 %83)
%85 = call i32 (...) @stop()
store i32 0, i32* @errno
%86 = load i32, i32* @O_WRONLY
%87 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %86)
store i32 %87, i32* %2
%88 = load i32, i32* %2
%89 = load i32, i32* @errno
%90 = load i32, i32* @errno
%91 = call i8* @strerrno(i32 %90)
%92 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %88, i32 %89, i8* %91)
%93 = load i32, i32* %2
%94 = icmp sge i32 %93, 0
br i1 %94, label %95, label %98
95: ; preds = %82
%96 = load i32, i32* %2
%97 = call i32 @close(i32 %96)
br label %98
98: ; preds = %95, %82
br label %104
99: ; preds = %73
%100 = call i32 (...) @stop()
%101 = load i32, i32* %2
%102 = load i32, i32* @errno
%103 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %101, i32 %102)
br label %104
104: ; preds = %99, %98
%105 = call i32 (...) @stop()
%106 = load i32, i32* %1
ret i32 %106
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [16 x i8] c"foo.fileio.test\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@S_IWUSR = global i32 0
@S_IRUSR = global i32 0
@.str.1 = [33 x i8] c"open 1: ret = %d, errno = %d %s\0A\00"
@.str.2 = [3 x i8] c"OK\00"
@.str.3 = [1 x i8] zeroinitializer
@O_EXCL = global i32 0
@O_WRONLY = global i32 0
@.str.4 = [33 x i8] c"open 2: ret = %d, errno = %d %s\0A\00"
@.str.5 = [2 x i8] c".\00"
@.str.6 = [33 x i8] c"open 3: ret = %d, errno = %d %s\0A\00"
@.str.7 = [18 x i8] c"nofoo.fileio.test\00"
@O_RDONLY = global i32 0
@.str.8 = [33 x i8] c"open 4: ret = %d, errno = %d %s\0A\00"
@.str.9 = [18 x i8] c"nowrt.fileio.test\00"
@.str.10 = [33 x i8] c"open 5: ret = %d, errno = %d %s\0A\00"
@.str.11 = [30 x i8] c"open 5: ret = %d, errno = %d\0A\00"
define i32 @test_open() {
store i32 0, i32* @errno
%1 = load i32, i32* @O_CREAT
%2 = load i32, i32* @O_TRUNC
%3 = or i32 %2, %1
%4 = load i32, i32* @O_RDWR
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IWUSR
%7 = load i32, i32* @S_IRUSR
%8 = or i32 %7, %6
%9 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %8)
%10 = load i32, i32* @errno
%11 = icmp sgt i32 %9, -1
%12 = select i1 %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0)
%13 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %10, i8* %12)
br i1 %11, label %14, label %16
14: ; preds = %0
%15 = tail call i32 @close(i32 %9)
br label %16
16: ; preds = %14, %0
%17 = tail call i32 (...) @stop()
store i32 0, i32* @errno
%18 = load i32, i32* @O_CREAT
%19 = load i32, i32* @O_EXCL
%20 = or i32 %19, %18
%21 = load i32, i32* @O_WRONLY
%22 = or i32 %20, %21
%23 = load i32, i32* @S_IWUSR
%24 = load i32, i32* @S_IRUSR
%25 = or i32 %24, %23
%26 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %25)
%27 = load i32, i32* @errno
%28 = tail call i8* @strerrno(i32 %27)
%29 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %26, i32 %27, i8* %28)
%30 = icmp sgt i32 %26, -1
br i1 %30, label %31, label %33
31: ; preds = %16
%32 = tail call i32 @close(i32 %26)
br label %33
33: ; preds = %31, %16
%34 = tail call i32 (...) @stop()
store i32 0, i32* @errno
%35 = load i32, i32* @O_WRONLY
%36 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @errno
%38 = tail call i8* @strerrno(i32 %37)
%39 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %36, i32 %37, i8* %38)
%40 = icmp sgt i32 %36, -1
br i1 %40, label %41, label %43
41: ; preds = %33
%42 = tail call i32 @close(i32 %36)
br label %43
43: ; preds = %41, %33
%44 = tail call i32 (...) @stop()
store i32 0, i32* @errno
%45 = load i32, i32* @O_RDONLY
%46 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %45)
%47 = load i32, i32* @errno
%48 = tail call i8* @strerrno(i32 %47)
%49 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %46, i32 %47, i8* %48)
%50 = icmp sgt i32 %46, -1
br i1 %50, label %51, label %53
51: ; preds = %43
%52 = tail call i32 @close(i32 %46)
br label %53
53: ; preds = %51, %43
%54 = tail call i32 (...) @stop()
store i32 0, i32* @errno
%55 = load i32, i32* @O_CREAT
%56 = load i32, i32* @O_RDONLY
%57 = or i32 %56, %55
%58 = load i32, i32* @S_IRUSR
%59 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %57, i32 %58)
%60 = icmp sgt i32 %59, -1
br i1 %60, label %61, label %72
61: ; preds = %53
%62 = tail call i32 @close(i32 %59)
%63 = tail call i32 (...) @stop()
store i32 0, i32* @errno
%64 = load i32, i32* @O_WRONLY
%65 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %64)
%66 = load i32, i32* @errno
%67 = tail call i8* @strerrno(i32 %66)
%68 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %65, i32 %66, i8* %67)
%69 = icmp sgt i32 %65, -1
br i1 %69, label %70, label %76
70: ; preds = %61
%71 = tail call i32 @close(i32 %65)
br label %76
72: ; preds = %53
%73 = tail call i32 (...) @stop()
%74 = load i32, i32* @errno
%75 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %59, i32 %74)
br label %76
76: ; preds = %61, %70, %72
%77 = tail call i32 (...) @stop()
ret i32 undef
}