#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 dup(int);
int /*<<< orphan*/ getchar();
int getpid();
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ write_buffer(int, char *);
int main(void) {
  printf("Process %d started\n", getpid());
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  int fd1 = open("rick.txt", O_RDWR | O_CREAT, 0644);
  if (fd1 < 0) {
    printf("Error opening file for fd1\n");
    return -1;
  }
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  printf("File opened with fd1=%d\n", fd1);
  write_buffer(fd1, "Never gonna give you up.\n");
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  write_buffer(fd1, "Never gonna let you down.\n");
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  int fd2 = dup(fd1);
  printf("Duplicate fd1 into fd2=%d\n", fd2);
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  write_buffer(fd2, "Never gonna run around\n");
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  write_buffer(fd1, ".. and desert you.\n");
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  int fd3 = open("rick.txt", O_RDWR | O_CREAT, 0644);
  if (fd3 < 0) {
    printf("Error opening file for fd3\n");
    return -1;
  }
  printf("File opened with fd3=%d\n", fd3);
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  write_buffer(fd3, "LAMA");
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  write_buffer(fd1, "Never gonna give\n");
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  write_buffer(fd2, "Never gonna give\n");
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  write_buffer(fd3, " out of nowhere!");
  do {
    printf("Taking a break. Press Enter to continue.\n");
    getchar();
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
mov    0x2e4d(%rip),%rax
or     (%rax),%esi
lea    0xe8a(%rip),%rdi
mov    $0x1a4,%edx
call   1080 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11e5 <main+0x85>
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13d8 <main+0x278>
jmp    11ea <main+0x8a>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x8(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
lea    0xe62(%rip),%rsi
call   1040 <write_buffer@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x8(%rbp),%edi
lea    0xe58(%rip),%rsi
call   1040 <write_buffer@plt>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x8(%rbp),%edi
call   1060 <dup@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0xc(%rbp),%edi
lea    0xe39(%rip),%rsi
call   1040 <write_buffer@plt>
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x8(%rbp),%edi
lea    0xe2d(%rip),%rsi
call   1040 <write_buffer@plt>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%esi
mov    0x2d17(%rip),%rax
or     (%rax),%esi
lea    0xd54(%rip),%rdi
mov    $0x1a4,%edx
call   1080 <open@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    131b <main+0x1bb>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13d8 <main+0x278>
mov    -0x10(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xce1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x10(%rbp),%edi
lea    0xde2(%rip),%rsi
call   1040 <write_buffer@plt>
lea    0xcbd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x8(%rbp),%edi
lea    0xdc3(%rip),%rsi
call   1040 <write_buffer@plt>
lea    0xc99(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0xc(%rbp),%edi
lea    0xd9f(%rip),%rsi
call   1040 <write_buffer@plt>
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    -0x10(%rbp),%edi
lea    0xd8d(%rip),%rsi
call   1040 <write_buffer@plt>
lea    0xc51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe77(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf5a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    0x2e34(%rip),%r12
mov    0x2e45(%rip),%r13
mov    0x0(%r13),%esi
or     (%r12),%esi
lea    0xe52(%rip),%rdi
mov    $0x1a4,%edx
call   1090 <open@plt>
test   %eax,%eax
js     135c <main+0x1ec>
mov    %eax,%ebp
lea    0xf16(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <getchar@plt>
lea    0xe27(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe30(%rip),%rsi
mov    %ebp,%edi
call   1050 <write_buffer@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
lea    0xe2d(%rip),%rsi
mov    %ebp,%edi
call   1050 <write_buffer@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    %ebp,%edi
call   1070 <dup@plt>
mov    %eax,%r15d
lea    0xe21(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
lea    0xe1d(%rip),%rsi
mov    %r15d,%edi
call   1050 <write_buffer@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
lea    0xe17(%rip),%rsi
mov    %ebp,%edi
call   1050 <write_buffer@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    0x0(%r13),%esi
or     (%r12),%esi
lea    0xd68(%rip),%rdi
mov    $0x1a4,%edx
call   1090 <open@plt>
test   %eax,%eax
js     1365 <main+0x1f5>
mov    %eax,%ebx
lea    0xdeb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe1c(%rip),%r12
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
lea    0xdde(%rip),%rsi
mov    %ebx,%edi
call   1050 <write_buffer@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
lea    0xdc6(%rip),%r13
mov    %ebp,%edi
mov    %r13,%rsi
call   1050 <write_buffer@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
mov    %r15d,%edi
mov    %r13,%rsi
call   1050 <write_buffer@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
lea    0xd9e(%rip),%rsi
mov    %ebx,%edi
call   1050 <write_buffer@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
jmp    1377 <main+0x207>
lea    0xdd4(%rip),%rdi
jmp    136c <main+0x1fc>
lea    0xdb0(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Process %d started\0A\00"
@.str.1 = [42 x i8] c"Taking a break. Press Enter to continue.\0A\00"
@.str.2 = [9 x i8] c"rick.txt\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@.str.3 = [28 x i8] c"Error opening file for fd1\0A\00"
@.str.4 = [25 x i8] c"File opened with fd1=%d\0A\00"
@.str.5 = [26 x i8] c"Never gonna give you up.\0A\00"
@.str.6 = [27 x i8] c"Never gonna let you down.\0A\00"
@.str.7 = [27 x i8] c"Duplicate fd1 into fd2=%d\0A\00"
@.str.8 = [24 x i8] c"Never gonna run around\0A\00"
@.str.9 = [20 x i8] c".. and desert you.\0A\00"
@.str.10 = [28 x i8] c"Error opening file for fd3\0A\00"
@.str.11 = [25 x i8] c"File opened with fd3=%d\0A\00"
@.str.12 = [5 x i8] c"LAMA\00"
@.str.13 = [18 x i8] c"Never gonna give\0A\00"
@.str.14 = [17 x i8] c" out of nowhere!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @getpid()
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (...) @getchar()
br label %10
10: ; preds = %7
%11 = load i32, i32* @O_RDWR
%12 = load i32, i32* @O_CREAT
%13 = or i32 %11, %12
%14 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 420)
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %10
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %97
19: ; preds = %10
br label %20
20: ; preds = %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (...) @getchar()
br label %23
23: ; preds = %20
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %2
%27 = call i32 @write_buffer(i32 %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %28
28: ; preds = %23
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 (...) @getchar()
br label %31
31: ; preds = %28
%32 = load i32, i32* %2
%33 = call i32 @write_buffer(i32 %32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
br label %34
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 (...) @getchar()
br label %37
37: ; preds = %34
%38 = load i32, i32* %2
%39 = call i32 @dup(i32 %38)
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %37
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 (...) @getchar()
br label %45
45: ; preds = %42
%46 = load i32, i32* %3
%47 = call i32 @write_buffer(i32 %46, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %48
48: ; preds = %45
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%50 = call i32 (...) @getchar()
br label %51
51: ; preds = %48
%52 = load i32, i32* %2
%53 = call i32 @write_buffer(i32 %52, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %54
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%56 = call i32 (...) @getchar()
br label %57
57: ; preds = %54
%58 = load i32, i32* @O_RDWR
%59 = load i32, i32* @O_CREAT
%60 = or i32 %58, %59
%61 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %60, i32 420)
store i32 %61, i32* %4
%62 = load i32, i32* %4
%63 = icmp slt i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %57
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.10, i64 0, i64 0))
store i32 -1, i32* %1
br label %97
66: ; preds = %57
%67 = load i32, i32* %4
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i32 %67)
br label %69
69: ; preds = %66
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%71 = call i32 (...) @getchar()
br label %72
72: ; preds = %69
%73 = load i32, i32* %4
%74 = call i32 @write_buffer(i32 %73, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
br label %75
75: ; preds = %72
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%77 = call i32 (...) @getchar()
br label %78
78: ; preds = %75
%79 = load i32, i32* %2
%80 = call i32 @write_buffer(i32 %79, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
br label %81
81: ; preds = %78
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%83 = call i32 (...) @getchar()
br label %84
84: ; preds = %81
%85 = load i32, i32* %3
%86 = call i32 @write_buffer(i32 %85, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
br label %87
87: ; preds = %84
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%89 = call i32 (...) @getchar()
br label %90
90: ; preds = %87
%91 = load i32, i32* %4
%92 = call i32 @write_buffer(i32 %91, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
br label %93
93: ; preds = %90
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%95 = call i32 (...) @getchar()
br label %96
96: ; preds = %93
store i32 0, i32* %1
br label %97
97: ; preds = %96, %64, %17
%98 = load i32, i32* %1
ret i32 %98
}

LLVM IR (-O2):
@.str = [20 x i8] c"Process %d started\0A\00"
@.str.2 = [9 x i8] c"rick.txt\00"
@O_RDWR = global i32 0
@O_CREAT = global i32 0
@.str.4 = [25 x i8] c"File opened with fd1=%d\0A\00"
@.str.5 = [26 x i8] c"Never gonna give you up.\0A\00"
@.str.6 = [27 x i8] c"Never gonna let you down.\0A\00"
@.str.7 = [27 x i8] c"Duplicate fd1 into fd2=%d\0A\00"
@.str.8 = [24 x i8] c"Never gonna run around\0A\00"
@.str.9 = [20 x i8] c".. and desert you.\0A\00"
@.str.11 = [25 x i8] c"File opened with fd3=%d\0A\00"
@.str.12 = [5 x i8] c"LAMA\00"
@.str.13 = [18 x i8] c"Never gonna give\0A\00"
@.str.14 = [17 x i8] c" out of nowhere!\00"
@str.25 = [41 x i8] c"Taking a break. Press Enter to continue.\00"
@str.26 = [27 x i8] c"Error opening file for fd3\00"
@str.27 = [27 x i8] c"Error opening file for fd1\00"
define i32 @main() {
%1 = tail call i32 (...) @getpid()
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%4 = tail call i32 (...) @getchar()
%5 = load i32, i32* @O_RDWR
%6 = load i32, i32* @O_CREAT
%7 = or i32 %6, %5
%8 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 420)
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.27, i64 0, i64 0))
br label %55
12: ; preds = %0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%14 = tail call i32 (...) @getchar()
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %8)
%16 = tail call i32 @write_buffer(i32 %8, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%18 = tail call i32 (...) @getchar()
%19 = tail call i32 @write_buffer(i32 %8, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%21 = tail call i32 (...) @getchar()
%22 = tail call i32 @dup(i32 %8)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %22)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%25 = tail call i32 (...) @getchar()
%26 = tail call i32 @write_buffer(i32 %22, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%28 = tail call i32 (...) @getchar()
%29 = tail call i32 @write_buffer(i32 %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%31 = tail call i32 (...) @getchar()
%32 = load i32, i32* @O_RDWR
%33 = load i32, i32* @O_CREAT
%34 = or i32 %33, %32
%35 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 420)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %12
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.26, i64 0, i64 0))
br label %55
39: ; preds = %12
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.11, i64 0, i64 0), i32 %35)
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%42 = tail call i32 (...) @getchar()
%43 = tail call i32 @write_buffer(i32 %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%45 = tail call i32 (...) @getchar()
%46 = tail call i32 @write_buffer(i32 %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%48 = tail call i32 (...) @getchar()
%49 = tail call i32 @write_buffer(i32 %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%51 = tail call i32 (...) @getchar()
%52 = tail call i32 @write_buffer(i32 %35, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.25, i64 0, i64 0))
%54 = tail call i32 (...) @getchar()
br label %55
55: ; preds = %37, %39, %10
%56 = phi i32 [ -1, %10 ], [ -1, %37 ], [ 0, %39 ]
ret i32 %56
}