#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, ...);
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);
  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);
  errno = 0;
  ret = open(".", O_WRONLY);
  printf("open 3: ret = %d, errno = %d %s\n", ret, errno, strerrno(errno));
  if (ret >= 0)
    close(ret);
  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);
  errno = 0;
  ret = open("nowrt.fileio.test", O_CREAT | O_RDONLY, S_IRUSR);
  if (ret >= 0) {
    close(ret);
    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
    printf("open 5: ret = %d, errno = %d\n", ret, errno);
}


x86 assembly (clang, -O0):
<test_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e61(%rip),%rax
movl   $0x0,(%rax)
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
mov    0x2e8b(%rip),%rax
or     (%rax),%esi
mov    0x2e6a(%rip),%rax
or     (%rax),%esi
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
mov    0x2e28(%rip),%rax
or     (%rax),%edx
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    0x2e13(%rip),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%edi
lea    0xf42(%rip),%rcx
lea    0xe71(%rip),%rax
cmp    $0x0,%edi
cmovge %rax,%rcx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     11d7 <test_open+0x97>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    0x2dd2(%rip),%rax
movl   $0x0,(%rax)
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
mov    0x2dc4(%rip),%rax
or     (%rax),%esi
mov    0x2d9b(%rip),%rax
or     (%rax),%esi
mov    0x2dc2(%rip),%rax
mov    (%rax),%edx
mov    0x2d99(%rip),%rax
or     (%rax),%edx
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
call   1030 <strerrno@plt>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    %rax,%rcx
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     126b <test_open+0x12b>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    0x2d3e(%rip),%rax
movl   $0x0,(%rax)
mov    0x2d19(%rip),%rax
mov    (%rax),%esi
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
call   1030 <strerrno@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    %rax,%rcx
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     12db <test_open+0x19b>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    0x2cce(%rip),%rax
movl   $0x0,(%rax)
mov    0x2ce1(%rip),%rax
mov    (%rax),%esi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2ca1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2c95(%rip),%rax
mov    (%rax),%edi
call   1030 <strerrno@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %rax,%rcx
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     134b <test_open+0x20b>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    0x2c5e(%rip),%rax
movl   $0x0,(%rax)
mov    0x2c99(%rip),%rax
mov    (%rax),%esi
mov    0x2c68(%rip),%rax
or     (%rax),%esi
mov    0x2c37(%rip),%rax
mov    (%rax),%edx
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     140b <test_open+0x2cb>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
mov    0x2c13(%rip),%rax
movl   $0x0,(%rax)
mov    0x2bee(%rip),%rax
mov    (%rax),%esi
lea    0xce8(%rip),%rdi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2be6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
call   1030 <strerrno@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    %rax,%rcx
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1406 <test_open+0x2c6>
mov    -0x8(%rbp),%edi
call   1050 <close@plt>
jmp    1425 <test_open+0x2e5>
mov    -0x8(%rbp),%esi
mov    0x2b9b(%rip),%rax
mov    (%rax),%edx
lea    0xcb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@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    0x2e5e(%rip),%r14
movl   $0x0,(%r14)
mov    0x2e98(%rip),%r15
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
or     (%r15),%esi
mov    0x2e65(%rip),%rax
or     (%rax),%esi
mov    0x2e4c(%rip),%rbp
mov    0x2e25(%rip),%r12
mov    (%r12),%edx
or     0x0(%rbp),%edx
lea    0xed9(%rip),%rdi
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%ebx
mov    (%r14),%edx
test   %eax,%eax
lea    0xe7b(%rip),%rax
lea    0xf3e(%rip),%rcx
cmovns %rax,%rcx
lea    0xe48(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     11cc <test_open+0x8c>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
or     (%r15),%esi
mov    0x2db9(%rip),%r13
or     0x0(%r13),%esi
movl   $0x0,(%r14)
mov    (%r12),%edx
or     0x0(%rbp),%edx
lea    0xe72(%rip),%rdi
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%ebx
mov    (%r14),%ebp
mov    %ebp,%edi
call   1030 <strerrno@plt>
lea    0xe12(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     122b <test_open+0xeb>
mov    %ebx,%edi
call   1050 <close@plt>
movl   $0x0,(%r14)
mov    0x0(%r13),%esi
lea    0xe08(%rip),%rdi
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%ebx
mov    (%r14),%ebp
mov    %ebp,%edi
call   1030 <strerrno@plt>
lea    0xdf0(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     1270 <test_open+0x130>
mov    %ebx,%edi
call   1050 <close@plt>
movl   $0x0,(%r14)
mov    0x2d52(%rip),%r15
mov    (%r15),%esi
lea    0xde0(%rip),%rdi
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%ebx
mov    (%r14),%ebp
mov    %ebp,%edi
call   1030 <strerrno@plt>
lea    0xdd8(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     12bb <test_open+0x17b>
mov    %ebx,%edi
call   1050 <close@plt>
movl   $0x0,(%r14)
mov    (%r15),%esi
mov    0x2d2c(%rip),%rax
or     (%rax),%esi
mov    (%r12),%edx
lea    0xdc2(%rip),%rdi
xor    %eax,%eax
call   1060 <open@plt>
test   %eax,%eax
js     1332 <test_open+0x1f2>
mov    %eax,%edi
call   1050 <close@plt>
movl   $0x0,(%r14)
mov    0x0(%r13),%esi
lea    0xd9e(%rip),%rdi
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%ebx
mov    (%r14),%ebp
mov    %ebp,%edi
call   1030 <strerrno@plt>
lea    0xd96(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
js     1345 <test_open+0x205>
mov    %ebx,%edi
call   1050 <close@plt>
jmp    1345 <test_open+0x205>
mov    (%r14),%edx
lea    0xd92(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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
store i32 0, i32* @errno
%25 = load i32, i32* @O_CREAT
%26 = load i32, i32* @O_EXCL
%27 = or i32 %25, %26
%28 = load i32, i32* @O_WRONLY
%29 = or i32 %27, %28
%30 = load i32, i32* @S_IWUSR
%31 = load i32, i32* @S_IRUSR
%32 = or i32 %30, %31
%33 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %32)
store i32 %33, i32* %2
%34 = load i32, i32* %2
%35 = load i32, i32* @errno
%36 = load i32, i32* @errno
%37 = call i8* @strerrno(i32 %36)
%38 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %34, i32 %35, i8* %37)
%39 = load i32, i32* %2
%40 = icmp sge i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %24
%42 = load i32, i32* %2
%43 = call i32 @close(i32 %42)
br label %44
44: ; preds = %41, %24
store i32 0, i32* @errno
%45 = load i32, i32* @O_WRONLY
%46 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %45)
store i32 %46, i32* %2
%47 = load i32, i32* %2
%48 = load i32, i32* @errno
%49 = load i32, i32* @errno
%50 = call i8* @strerrno(i32 %49)
%51 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %47, i32 %48, i8* %50)
%52 = load i32, i32* %2
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %44
%55 = load i32, i32* %2
%56 = call i32 @close(i32 %55)
br label %57
57: ; preds = %54, %44
store i32 0, i32* @errno
%58 = load i32, i32* @O_RDONLY
%59 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %58)
store i32 %59, i32* %2
%60 = load i32, i32* %2
%61 = load i32, i32* @errno
%62 = load i32, i32* @errno
%63 = call i8* @strerrno(i32 %62)
%64 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %60, i32 %61, i8* %63)
%65 = load i32, i32* %2
%66 = icmp sge i32 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %57
%68 = load i32, i32* %2
%69 = call i32 @close(i32 %68)
br label %70
70: ; preds = %67, %57
store i32 0, i32* @errno
%71 = load i32, i32* @O_CREAT
%72 = load i32, i32* @O_RDONLY
%73 = or i32 %71, %72
%74 = load i32, i32* @S_IRUSR
%75 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %73, i32 %74)
store i32 %75, i32* %2
%76 = load i32, i32* %2
%77 = icmp sge i32 %76, 0
br i1 %77, label %78, label %94
78: ; preds = %70
%79 = load i32, i32* %2
%80 = call i32 @close(i32 %79)
store i32 0, i32* @errno
%81 = load i32, i32* @O_WRONLY
%82 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %81)
store i32 %82, i32* %2
%83 = load i32, i32* %2
%84 = load i32, i32* @errno
%85 = load i32, i32* @errno
%86 = call i8* @strerrno(i32 %85)
%87 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %83, i32 %84, i8* %86)
%88 = load i32, i32* %2
%89 = icmp sge i32 %88, 0
br i1 %89, label %90, label %93
90: ; preds = %78
%91 = load i32, i32* %2
%92 = call i32 @close(i32 %91)
br label %93
93: ; preds = %90, %78
br label %98
94: ; preds = %70
%95 = load i32, i32* %2
%96 = load i32, i32* @errno
%97 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %95, i32 %96)
br label %98
98: ; preds = %94, %93
%99 = load i32, i32* %1
ret i32 %99
}

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
store i32 0, i32* @errno
%17 = load i32, i32* @O_CREAT
%18 = load i32, i32* @O_EXCL
%19 = or i32 %18, %17
%20 = load i32, i32* @O_WRONLY
%21 = or i32 %19, %20
%22 = load i32, i32* @S_IWUSR
%23 = load i32, i32* @S_IRUSR
%24 = or i32 %23, %22
%25 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %24)
%26 = load i32, i32* @errno
%27 = tail call i8* @strerrno(i32 %26)
%28 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %25, i32 %26, i8* %27)
%29 = icmp sgt i32 %25, -1
br i1 %29, label %30, label %32
30: ; preds = %16
%31 = tail call i32 @close(i32 %25)
br label %32
32: ; preds = %30, %16
store i32 0, i32* @errno
%33 = load i32, i32* @O_WRONLY
%34 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%35 = load i32, i32* @errno
%36 = tail call i8* @strerrno(i32 %35)
%37 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %34, i32 %35, i8* %36)
%38 = icmp sgt i32 %34, -1
br i1 %38, label %39, label %41
39: ; preds = %32
%40 = tail call i32 @close(i32 %34)
br label %41
41: ; preds = %39, %32
store i32 0, i32* @errno
%42 = load i32, i32* @O_RDONLY
%43 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @errno
%45 = tail call i8* @strerrno(i32 %44)
%46 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i32 %43, i32 %44, i8* %45)
%47 = icmp sgt i32 %43, -1
br i1 %47, label %48, label %50
48: ; preds = %41
%49 = tail call i32 @close(i32 %43)
br label %50
50: ; preds = %48, %41
store i32 0, i32* @errno
%51 = load i32, i32* @O_CREAT
%52 = load i32, i32* @O_RDONLY
%53 = or i32 %52, %51
%54 = load i32, i32* @S_IRUSR
%55 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %53, i32 %54)
%56 = icmp sgt i32 %55, -1
br i1 %56, label %57, label %67
57: ; preds = %50
%58 = tail call i32 @close(i32 %55)
store i32 0, i32* @errno
%59 = load i32, i32* @O_WRONLY
%60 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i32 %59)
%61 = load i32, i32* @errno
%62 = tail call i8* @strerrno(i32 %61)
%63 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %60, i32 %61, i8* %62)
%64 = icmp sgt i32 %60, -1
br i1 %64, label %65, label %70
65: ; preds = %57
%66 = tail call i32 @close(i32 %60)
br label %70
67: ; preds = %50
%68 = load i32, i32* @errno
%69 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %55, i32 %68)
br label %70
70: ; preds = %57, %65, %67
ret i32 undef
}