#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_RDWR;
int O_TRUNC;
int /*<<< orphan*/ SEEK_SET;
int S_IRUSR;
int S_IWUSR;
int close(int);
int dup(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int write(int, char *, int);
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "Usage: %s file\n", argv[0]);
    return 1;
  }
  int fd1 = open(argv[1], O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
  if (fd1 == -1) {
    fprintf(stderr, "open: %s\n", strerror(errno));
    return 1;
  }
  int fd2 = dup(fd1);
  if (fd2 == -1) {
    fprintf(stderr, "dup: %s\n", strerror(errno));
    return 1;
  }
  int fd3 = open(argv[1], O_RDWR);
  if (fd3 == -1) {
    fprintf(stderr, "open: %s\n", strerror(errno));
    return 1;
  }
  if (write(fd1, "Hello,", 6) != 6) {
    fprintf(stderr, "write: %s\n", strerror(errno));
    return 1;
  }
  if (write(fd2, " world", 6) != 6) {
    fprintf(stderr, "write: %s\n", strerror(errno));
    return 1;
  }
  if (lseek(fd2, 0, SEEK_SET) == -1) {
    fprintf(stderr, "lseek: %s\n", strerror(errno));
    return 1;
  }
  if (write(fd1, "HELLO,", 6) != 6) {
    fprintf(stderr, "write: %s\n", strerror(errno));
    return 1;
  }
  if (write(fd3, "Gidday", 6) != 6) {
    fprintf(stderr, "write: %s\n", strerror(errno));
    return 1;
  }
  if (close(fd3) == -1) {
    fprintf(stderr, "close: %s\n", strerror(errno));
  }
  if (close(fd2) == -1) {
    fprintf(stderr, "close: %s\n", strerror(errno));
  }
  if (close(fd1) == -1) {
    fprintf(stderr, "close: %s\n", strerror(errno));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11b8 <main+0x48>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe59(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1549 <main+0x3d9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e11(%rip),%rax
mov    (%rax),%esi
mov    0x2e28(%rip),%rax
or     (%rax),%esi
mov    0x2e17(%rip),%rax
or     (%rax),%esi
mov    0x2dc6(%rip),%rax
mov    (%rax),%edx
mov    0x2de5(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1239 <main+0xc9>
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xde8(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1549 <main+0x3d9>
mov    -0x14(%rbp),%edi
call   1040 <dup@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    1286 <main+0x116>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xda5(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1549 <main+0x3d9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d43(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1080 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12e3 <main+0x173>
mov    0x2d0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rdx
lea    0xd3e(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1549 <main+0x3d9>
mov    -0x14(%rbp),%edi
lea    0xd36(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x6,%eax
je     1338 <main+0x1c8>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xd03(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1549 <main+0x3d9>
mov    -0x18(%rbp),%edi
lea    0xcf3(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x6,%eax
je     138d <main+0x21d>
mov    0x2c64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2c50(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x30(%rbp),%edi
mov    %rax,%rdx
lea    0xcae(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1549 <main+0x3d9>
mov    -0x18(%rbp),%edi
mov    0x2c19(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
jne    13e1 <main+0x271>
mov    0x2c10(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2bfc(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xc6c(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1549 <main+0x3d9>
mov    -0x14(%rbp),%edi
lea    0xc5c(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x6,%eax
je     1436 <main+0x2c6>
mov    0x2bbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2ba7(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x38(%rbp),%edi
mov    %rax,%rdx
lea    0xc05(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1549 <main+0x3d9>
mov    -0x1c(%rbp),%edi
lea    0xc0e(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x6,%eax
je     148b <main+0x31b>
mov    0x2b66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2b52(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    %rax,%rdx
lea    0xbb0(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1549 <main+0x3d9>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    14c8 <main+0x358>
mov    0x2b1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2b09(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x40(%rbp),%edi
mov    %rax,%rdx
lea    0xb92(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    1505 <main+0x395>
mov    0x2ae0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    0x2acc(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xb55(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    1542 <main+0x3d2>
mov    0x2aa3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2a8f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rdx
lea    0xb18(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbp
cmp    $0x2,%edi
jne    132e <main+0x1be>
mov    0x8(%rbp),%rdi
mov    0x2e49(%rip),%rbx
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
or     (%rbx),%esi
mov    0x2e4f(%rip),%rax
or     (%rax),%esi
mov    0x2dfe(%rip),%rax
mov    0x2e1f(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
xor    %eax,%eax
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     1344 <main+0x1d4>
mov    %eax,%r12d
mov    %eax,%edi
call   1040 <dup@plt>
cmp    $0xffffffff,%eax
je     1364 <main+0x1f4>
mov    %eax,%r15d
mov    0x8(%rbp),%rdi
mov    (%rbx),%esi
xor    %eax,%eax
call   1080 <open@plt>
cmp    $0xffffffff,%eax
je     1344 <main+0x1d4>
mov    %eax,%r14d
lea    0xe28(%rip),%rsi
mov    %r12d,%edi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x6,%eax
jne    1384 <main+0x214>
lea    0xe1d(%rip),%rsi
mov    %r15d,%edi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x6,%eax
jne    1384 <main+0x214>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edx
mov    %r15d,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
je     13bc <main+0x24c>
lea    0xdf6(%rip),%rsi
mov    %r12d,%edi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x6,%eax
jne    1384 <main+0x214>
lea    0xde0(%rip),%rsi
mov    %r14d,%edi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0x6,%eax
jne    1384 <main+0x214>
mov    %r14d,%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    12b9 <main+0x149>
mov    0x2d28(%rip),%rax
mov    (%rax),%ebp
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xda6(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    %r15d,%edi
call   1060 <close@plt>
cmp    $0xffffffff,%eax
jne    12ee <main+0x17e>
mov    0x2cf3(%rip),%rax
mov    (%rax),%ebp
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xd71(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    %r12d,%edi
call   1060 <close@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
jne    13b1 <main+0x241>
mov    0x2cb8(%rip),%rax
mov    (%rax),%ebp
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xd36(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
jmp    13b1 <main+0x241>
mov    0x2c8b(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xcbe(%rip),%rsi
jmp    13a7 <main+0x237>
mov    0x2c75(%rip),%rax
mov    (%rax),%ebx
mov    0x2c64(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xcae(%rip),%rsi
jmp    13a2 <main+0x232>
mov    0x2c55(%rip),%rax
mov    (%rax),%ebx
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xc98(%rip),%rsi
jmp    13a2 <main+0x232>
mov    0x2c35(%rip),%rax
mov    (%rax),%ebx
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xc88(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bfd(%rip),%rax
mov    (%rax),%ebx
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xc62(%rip),%rsi
jmp    13a2 <main+0x232>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"Usage: %s file\0A\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.1 = [10 x i8] c"open: %s\0A\00"
@errno = global i32 0
@.str.2 = [9 x i8] c"dup: %s\0A\00"
@.str.3 = [7 x i8] c"Hello,\00"
@.str.4 = [11 x i8] c"write: %s\0A\00"
@.str.5 = [7 x i8] c" world\00"
@SEEK_SET = global i32 0
@.str.6 = [11 x i8] c"lseek: %s\0A\00"
@.str.7 = [7 x i8] c"HELLO,\00"
@.str.8 = [7 x i8] c"Gidday\00"
@.str.9 = [11 x i8] c"close: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 1, i32* %3
br label %134
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDWR
%22 = load i32, i32* @O_CREAT
%23 = or i32 %21, %22
%24 = load i32, i32* @O_TRUNC
%25 = or i32 %23, %24
%26 = load i32, i32* @S_IRUSR
%27 = load i32, i32* @S_IWUSR
%28 = or i32 %26, %27
%29 = call i32 (i8*, i32, ...) @open(i8* %20, i32 %25, i32 %28)
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %37
32: ; preds = %17
%33 = load i32, i32* @stderr
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %35)
store i32 1, i32* %3
br label %134
37: ; preds = %17
%38 = load i32, i32* %6
%39 = call i32 @dup(i32 %38)
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %47
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = load i32, i32* @errno
%45 = call i8* @strerror(i32 %44)
%46 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %45)
store i32 1, i32* %3
br label %134
47: ; preds = %37
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = load i32, i32* @O_RDWR
%52 = call i32 (i8*, i32, ...) @open(i8* %50, i32 %51)
store i32 %52, i32* %8
%53 = load i32, i32* %8
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %60
55: ; preds = %47
%56 = load i32, i32* @stderr
%57 = load i32, i32* @errno
%58 = call i8* @strerror(i32 %57)
%59 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %58)
store i32 1, i32* %3
br label %134
60: ; preds = %47
%61 = load i32, i32* %6
%62 = call i32 @write(i32 %61, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%63 = icmp ne i32 %62, 6
br i1 %63, label %64, label %69
64: ; preds = %60
%65 = load i32, i32* @stderr
%66 = load i32, i32* @errno
%67 = call i8* @strerror(i32 %66)
%68 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %67)
store i32 1, i32* %3
br label %134
69: ; preds = %60
%70 = load i32, i32* %7
%71 = call i32 @write(i32 %70, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%72 = icmp ne i32 %71, 6
br i1 %72, label %73, label %78
73: ; preds = %69
%74 = load i32, i32* @stderr
%75 = load i32, i32* @errno
%76 = call i8* @strerror(i32 %75)
%77 = call i32 @fprintf(i32 %74, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %76)
store i32 1, i32* %3
br label %134
78: ; preds = %69
%79 = load i32, i32* %7
%80 = load i32, i32* @SEEK_SET
%81 = call i32 @lseek(i32 %79, i32 0, i32 %80)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %88
83: ; preds = %78
%84 = load i32, i32* @stderr
%85 = load i32, i32* @errno
%86 = call i8* @strerror(i32 %85)
%87 = call i32 @fprintf(i32 %84, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %86)
store i32 1, i32* %3
br label %134
88: ; preds = %78
%89 = load i32, i32* %6
%90 = call i32 @write(i32 %89, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%91 = icmp ne i32 %90, 6
br i1 %91, label %92, label %97
92: ; preds = %88
%93 = load i32, i32* @stderr
%94 = load i32, i32* @errno
%95 = call i8* @strerror(i32 %94)
%96 = call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %95)
store i32 1, i32* %3
br label %134
97: ; preds = %88
%98 = load i32, i32* %8
%99 = call i32 @write(i32 %98, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 6)
%100 = icmp ne i32 %99, 6
br i1 %100, label %101, label %106
101: ; preds = %97
%102 = load i32, i32* @stderr
%103 = load i32, i32* @errno
%104 = call i8* @strerror(i32 %103)
%105 = call i32 @fprintf(i32 %102, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %104)
store i32 1, i32* %3
br label %134
106: ; preds = %97
%107 = load i32, i32* %8
%108 = call i32 @close(i32 %107)
%109 = icmp eq i32 %108, -1
br i1 %109, label %110, label %115
110: ; preds = %106
%111 = load i32, i32* @stderr
%112 = load i32, i32* @errno
%113 = call i8* @strerror(i32 %112)
%114 = call i32 @fprintf(i32 %111, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %113)
br label %115
115: ; preds = %110, %106
%116 = load i32, i32* %7
%117 = call i32 @close(i32 %116)
%118 = icmp eq i32 %117, -1
br i1 %118, label %119, label %124
119: ; preds = %115
%120 = load i32, i32* @stderr
%121 = load i32, i32* @errno
%122 = call i8* @strerror(i32 %121)
%123 = call i32 @fprintf(i32 %120, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %122)
br label %124
124: ; preds = %119, %115
%125 = load i32, i32* %6
%126 = call i32 @close(i32 %125)
%127 = icmp eq i32 %126, -1
br i1 %127, label %128, label %133
128: ; preds = %124
%129 = load i32, i32* @stderr
%130 = load i32, i32* @errno
%131 = call i8* @strerror(i32 %130)
%132 = call i32 @fprintf(i32 %129, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %131)
br label %133
133: ; preds = %128, %124
store i32 0, i32* %3
br label %134
134: ; preds = %133, %101, %92, %83, %73, %64, %55, %42, %32, %11
%135 = load i32, i32* %3
ret i32 %135
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"Usage: %s file\0A\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.1 = [10 x i8] c"open: %s\0A\00"
@errno = global i32 0
@.str.2 = [9 x i8] c"dup: %s\0A\00"
@.str.3 = [7 x i8] c"Hello,\00"
@.str.4 = [11 x i8] c"write: %s\0A\00"
@.str.5 = [7 x i8] c" world\00"
@SEEK_SET = global i32 0
@.str.6 = [11 x i8] c"lseek: %s\0A\00"
@.str.7 = [7 x i8] c"HELLO,\00"
@.str.8 = [7 x i8] c"Gidday\00"
@.str.9 = [11 x i8] c"close: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %109
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i32, i32* @O_RDWR
%12 = load i32, i32* @O_CREAT
%13 = or i32 %12, %11
%14 = load i32, i32* @O_TRUNC
%15 = or i32 %13, %14
%16 = load i32, i32* @S_IRUSR
%17 = load i32, i32* @S_IWUSR
%18 = or i32 %17, %16
%19 = tail call i32 (i8*, i32, ...) @open(i8* %10, i32 %15, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %26
21: ; preds = %8
%22 = load i32, i32* @stderr
%23 = load i32, i32* @errno
%24 = tail call i8* @strerror(i32 %23)
%25 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %109
26: ; preds = %8
%27 = tail call i32 @dup(i32 %19)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* @stderr
%31 = load i32, i32* @errno
%32 = tail call i8* @strerror(i32 %31)
%33 = tail call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %109
34: ; preds = %26
%35 = load i8*, i8** %9
%36 = load i32, i32* @O_RDWR
%37 = tail call i32 (i8*, i32, ...) @open(i8* %35, i32 %36)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %44
39: ; preds = %34
%40 = load i32, i32* @stderr
%41 = load i32, i32* @errno
%42 = tail call i8* @strerror(i32 %41)
%43 = tail call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %42)
br label %109
44: ; preds = %34
%45 = tail call i32 @write(i32 %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%46 = icmp eq i32 %45, 6
br i1 %46, label %52, label %47
47: ; preds = %44
%48 = load i32, i32* @stderr
%49 = load i32, i32* @errno
%50 = tail call i8* @strerror(i32 %49)
%51 = tail call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %50)
br label %109
52: ; preds = %44
%53 = tail call i32 @write(i32 %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%54 = icmp eq i32 %53, 6
br i1 %54, label %60, label %55
55: ; preds = %52
%56 = load i32, i32* @stderr
%57 = load i32, i32* @errno
%58 = tail call i8* @strerror(i32 %57)
%59 = tail call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %58)
br label %109
60: ; preds = %52
%61 = load i32, i32* @SEEK_SET
%62 = tail call i32 @lseek(i32 %27, i32 0, i32 %61)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %69
64: ; preds = %60
%65 = load i32, i32* @stderr
%66 = load i32, i32* @errno
%67 = tail call i8* @strerror(i32 %66)
%68 = tail call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %67)
br label %109
69: ; preds = %60
%70 = tail call i32 @write(i32 %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i32 6)
%71 = icmp eq i32 %70, 6
br i1 %71, label %77, label %72
72: ; preds = %69
%73 = load i32, i32* @stderr
%74 = load i32, i32* @errno
%75 = tail call i8* @strerror(i32 %74)
%76 = tail call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %75)
br label %109
77: ; preds = %69
%78 = tail call i32 @write(i32 %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 6)
%79 = icmp eq i32 %78, 6
br i1 %79, label %85, label %80
80: ; preds = %77
%81 = load i32, i32* @stderr
%82 = load i32, i32* @errno
%83 = tail call i8* @strerror(i32 %82)
%84 = tail call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %83)
br label %109
85: ; preds = %77
%86 = tail call i32 @close(i32 %37)
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %93
88: ; preds = %85
%89 = load i32, i32* @stderr
%90 = load i32, i32* @errno
%91 = tail call i8* @strerror(i32 %90)
%92 = tail call i32 @fprintf(i32 %89, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %91)
br label %93
93: ; preds = %88, %85
%94 = tail call i32 @close(i32 %27)
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %101
96: ; preds = %93
%97 = load i32, i32* @stderr
%98 = load i32, i32* @errno
%99 = tail call i8* @strerror(i32 %98)
%100 = tail call i32 @fprintf(i32 %97, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %99)
br label %101
101: ; preds = %96, %93
%102 = tail call i32 @close(i32 %19)
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %109
104: ; preds = %101
%105 = load i32, i32* @stderr
%106 = load i32, i32* @errno
%107 = tail call i8* @strerror(i32 %106)
%108 = tail call i32 @fprintf(i32 %105, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* %107)
br label %109
109: ; preds = %21, %39, %47, %55, %64, %72, %80, %104, %101, %29, %4
%110 = phi i32 [ 1, %4 ], [ 1, %21 ], [ 1, %29 ], [ 1, %39 ], [ 1, %47 ], [ 1, %55 ], [ 1, %64 ], [ 1, %72 ], [ 1, %80 ], [ 0, %104 ], [ 0, %101 ]
ret i32 %110
}