#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 */
typedef int ssize_t;
typedef int off_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int FOPEN_MAX;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int R_OK;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
int STDERR_FILENO;
int STDIN_FILENO;
int STDOUT_FILENO;
int S_IRUSR;
int S_IWUSR;
int W_OK;
scalar_t__ access(char *, int);
int close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fdatasync(int);
int /*<<< orphan*/ fsync(int);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ sync();
scalar_t__ unlink(char *);
int write(int, char *, int);
int main() {
  printf("%d,%d,%d,%d\n", STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO,
         FOPEN_MAX);
  int fd = open("file.txt", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
  if (fd == -1) {
    printf("failed open. %s\n", strerror(errno));
    return 1;
  }
  if (access("file.txt", R_OK | W_OK) < 0) {
    printf("failed access.\n");
    return 1;
  }
  if (unlink("file.txt") < 0) {
    printf("failed unlink. %s\n", strerror(errno));
    return 1;
  }
  off_t currpos = lseek(fd, 0, SEEK_CUR);
  printf("currpos: %d\n", currpos);
  char buf[32] = "hello, linux!";
  ssize_t write_bytes = write(fd, buf, sizeof(buf));
  if (write_bytes == -1) {
    printf("failed write. %s\n", strerror(errno));
    return 1;
  }
  sync();
  fsync(fd);
  fdatasync(fd);
  memset(buf, 0, sizeof(buf));
  lseek(fd, 0, SEEK_SET);
  ssize_t read_bytes = read(fd, buf, write_bytes);
  if (read_bytes == -1 || read_bytes != write_bytes) {
    printf("failed read. %s\n", strerror(errno));
    return 1;
  }
  printf("%s\n", buf);
  int ret = close(fd);
  if (ret == -1) {
    printf("failed close. %s\n", strerror(errno));
    return 1;
  }
  printf("done!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
mov    0x2df1(%rip),%rax
mov    (%rax),%edx
mov    0x2d98(%rip),%rax
mov    (%rax),%ecx
mov    0x2daf(%rip),%rax
mov    (%rax),%r8d
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%esi
mov    0x2dd6(%rip),%rax
or     (%rax),%esi
mov    0x2dc5(%rip),%rax
or     (%rax),%esi
mov    0x2d54(%rip),%rax
mov    (%rax),%edx
mov    0x2d7b(%rip),%rax
or     (%rax),%edx
lea    0xdc7(%rip),%rdi
call   10d0 <open@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1283 <main+0xb3>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    %rax,%rsi
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1496 <main+0x2c6>
mov    0x2cf6(%rip),%rax
mov    (%rax),%esi
mov    0x2d2d(%rip),%rax
or     (%rax),%esi
lea    0xd71(%rip),%rdi
call   10e0 <access@plt>
cmp    $0x0,%rax
jge    12c5 <main+0xf5>
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1496 <main+0x2c6>
lea    0xd41(%rip),%rdi
call   1040 <unlink@plt>
cmp    $0x0,%rax
jge    1306 <main+0x136>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    %rax,%rsi
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1496 <main+0x2c6>
mov    -0x8(%rbp),%edi
mov    0x2cb8(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <lseek@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0xd6c(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xd69(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xd66(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xd63(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x20,%edx
call   1050 <write@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    13a2 <main+0x1d2>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    %rax,%rsi
lea    0xcc8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1496 <main+0x2c6>
mov    $0x0,%al
call   10b0 <sync@plt>
mov    -0x8(%rbp),%edi
call   10c0 <fsync@plt>
mov    -0x8(%rbp),%edi
call   1030 <fdatasync@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    -0x8(%rbp),%edi
mov    0x2bc5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1070 <lseek@plt>
mov    -0x8(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   10a0 <read@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
je     1404 <main+0x234>
mov    -0x38(%rbp),%eax
cmp    -0x34(%rbp),%eax
je     142f <main+0x25f>
mov    0x2b95(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    %rax,%rsi
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1496 <main+0x2c6>
lea    -0x30(%rbp),%rsi
lea    0xc3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
call   1090 <close@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1481 <main+0x2b1>
mov    0x2b43(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    %rax,%rsi
lea    0xc0c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1496 <main+0x2c6>
lea    0xc04(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2d89(%rip),%rax
mov    (%rax),%esi
mov    0x2de8(%rip),%rax
mov    (%rax),%edx
mov    0x2d8f(%rip),%rax
mov    (%rax),%ecx
mov    0x2da6(%rip),%rax
mov    (%rax),%r8d
lea    0xdec(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2dae(%rip),%rax
mov    0x2dcf(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2dbc(%rip),%rax
or     (%rax),%esi
mov    0x2d4b(%rip),%rax
mov    0x2d74(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0xdbe(%rip),%rdi
call   10e0 <open@plt>
cmp    $0xffffffff,%eax
je     1363 <main+0x183>
mov    %eax,%ebx
mov    0x2d1a(%rip),%rax
mov    0x2d53(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xd95(%rip),%rdi
call   10f0 <access@plt>
test   %rax,%rax
js     137a <main+0x19a>
lea    0xd80(%rip),%rdi
call   1040 <unlink@plt>
test   %rax,%rax
js     1388 <main+0x1a8>
mov    0x2d26(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
lea    0xd86(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
movaps 0xdec(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xdd0(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x20,%edx
call   1060 <write@plt>
cmp    $0xffffffff,%eax
je     139f <main+0x1bf>
mov    %eax,%ebp
xor    %eax,%eax
call   10c0 <sync@plt>
mov    %ebx,%edi
call   10d0 <fsync@plt>
mov    %ebx,%edi
call   1030 <fdatasync@plt>
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1090 <memset@plt>
mov    0x2c7c(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   10b0 <read@plt>
cmp    $0xffffffff,%eax
je     13b6 <main+0x1d6>
cmp    %ebp,%eax
jne    13b6 <main+0x1d6>
mov    %rsp,%rdi
call   1050 <puts@plt>
mov    %ebx,%edi
call   10a0 <close@plt>
cmp    $0xffffffff,%eax
je     13cd <main+0x1ed>
lea    0xd25(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
jmp    13f1 <main+0x211>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc9e(%rip),%rdi
jmp    13e2 <main+0x202>
lea    0xd01(%rip),%rdi
call   1050 <puts@plt>
jmp    13ec <main+0x20c>
mov    0x2c11(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc8a(%rip),%rdi
jmp    13e2 <main+0x202>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc93(%rip),%rdi
jmp    13e2 <main+0x202>
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc8e(%rip),%rdi
jmp    13e2 <main+0x202>
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc88(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%d,%d,%d,%d\0A\00"
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@FOPEN_MAX = global i32 0
@.str.1 = [9 x i8] c"file.txt\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.2 = [17 x i8] c"failed open. %s\0A\00"
@errno = global i32 0
@R_OK = global i32 0
@W_OK = global i32 0
@.str.3 = [16 x i8] c"failed access.\0A\00"
@.str.4 = [19 x i8] c"failed unlink. %s\0A\00"
@SEEK_CUR = global i32 0
@.str.5 = [13 x i8] c"currpos: %d\0A\00"
@__const.main.buf = [32 x i8] c"hello, linux!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.6 = [18 x i8] c"failed write. %s\0A\00"
@SEEK_SET = global i32 0
@.str.7 = [17 x i8] c"failed read. %s\0A\00"
@.str.8 = [4 x i8] c"%s\0A\00"
@.str.9 = [18 x i8] c"failed close. %s\0A\00"
@.str.10 = [7 x i8] c"done!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [32 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = load i32, i32* @STDIN_FILENO
%9 = load i32, i32* @STDOUT_FILENO
%10 = load i32, i32* @STDERR_FILENO
%11 = load i32, i32* @FOPEN_MAX
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9, i32 %10, i32 %11)
%13 = load i32, i32* @O_RDWR
%14 = load i32, i32* @O_CREAT
%15 = or i32 %13, %14
%16 = load i32, i32* @O_TRUNC
%17 = or i32 %15, %16
%18 = load i32, i32* @S_IRUSR
%19 = load i32, i32* @S_IWUSR
%20 = or i32 %18, %19
%21 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %20)
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %28
24: ; preds = %0
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %26)
store i32 1, i32* %1
br label %97
28: ; preds = %0
%29 = load i32, i32* @R_OK
%30 = load i32, i32* @W_OK
%31 = or i32 %29, %30
%32 = call i64 @access(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %97
36: ; preds = %28
%37 = call i64 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i32, i32* @errno
%41 = call i8* @strerror(i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %41)
store i32 1, i32* %1
br label %97
43: ; preds = %36
%44 = load i32, i32* %2
%45 = load i32, i32* @SEEK_CUR
%46 = call i32 @lseek(i32 %44, i32 0, i32 %45)
store i32 %46, i32* %3
%47 = load i32, i32* %3
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %47)
%49 = bitcast [32 x i8]* %4 to i8*
%50 = load i32, i32* %2
%51 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%52 = call i32 @write(i32 %50, i8* %51, i32 32)
store i32 %52, i32* %5
%53 = load i32, i32* %5
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %59
55: ; preds = %43
%56 = load i32, i32* @errno
%57 = call i8* @strerror(i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %57)
store i32 1, i32* %1
br label %97
59: ; preds = %43
%60 = call i32 (...) @sync()
%61 = load i32, i32* %2
%62 = call i32 @fsync(i32 %61)
%63 = load i32, i32* %2
%64 = call i32 @fdatasync(i32 %63)
%65 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%66 = call i32 @memset(i8* %65, i32 0, i32 32)
%67 = load i32, i32* %2
%68 = load i32, i32* @SEEK_SET
%69 = call i32 @lseek(i32 %67, i32 0, i32 %68)
%70 = load i32, i32* %2
%71 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%72 = load i32, i32* %5
%73 = call i32 @read(i32 %70, i8* %71, i32 %72)
store i32 %73, i32* %6
%74 = load i32, i32* %6
%75 = icmp eq i32 %74, -1
br i1 %75, label %80, label %76
76: ; preds = %59
%77 = load i32, i32* %6
%78 = load i32, i32* %5
%79 = icmp ne i32 %77, %78
br i1 %79, label %80, label %84
80: ; preds = %76, %59
%81 = load i32, i32* @errno
%82 = call i8* @strerror(i32 %81)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %82)
store i32 1, i32* %1
br label %97
84: ; preds = %76
%85 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %85)
%87 = load i32, i32* %2
%88 = call i32 @close(i32 %87)
store i32 %88, i32* %7
%89 = load i32, i32* %7
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %95
91: ; preds = %84
%92 = load i32, i32* @errno
%93 = call i8* @strerror(i32 %92)
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %93)
store i32 1, i32* %1
br label %97
95: ; preds = %84
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %1
br label %97
97: ; preds = %95, %91, %80, %55, %39, %34, %24
%98 = load i32, i32* %1
ret i32 %98
}

LLVM IR (-O2):
@.str = [13 x i8] c"%d,%d,%d,%d\0A\00"
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
@STDERR_FILENO = global i32 0
@FOPEN_MAX = global i32 0
@.str.1 = [9 x i8] c"file.txt\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.2 = [17 x i8] c"failed open. %s\0A\00"
@errno = global i32 0
@R_OK = global i32 0
@W_OK = global i32 0
@.str.4 = [19 x i8] c"failed unlink. %s\0A\00"
@SEEK_CUR = global i32 0
@.str.5 = [13 x i8] c"currpos: %d\0A\00"
@__const.main.buf = [32 x i8] c"hello, linux!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.6 = [18 x i8] c"failed write. %s\0A\00"
@SEEK_SET = global i32 0
@.str.7 = [17 x i8] c"failed read. %s\0A\00"
@.str.9 = [18 x i8] c"failed close. %s\0A\00"
@str = [6 x i8] c"done!\00"
@str.11 = [15 x i8] c"failed access.\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = load i32, i32* @STDIN_FILENO
%3 = load i32, i32* @STDOUT_FILENO
%4 = load i32, i32* @STDERR_FILENO
%5 = load i32, i32* @FOPEN_MAX
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3, i32 %4, i32 %5)
%7 = load i32, i32* @O_RDWR
%8 = load i32, i32* @O_CREAT
%9 = or i32 %8, %7
%10 = load i32, i32* @O_TRUNC
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IRUSR
%13 = load i32, i32* @S_IWUSR
%14 = or i32 %13, %12
%15 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %0
%18 = load i32, i32* @errno
%19 = tail call i8* @strerror(i32 %18)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %74
21: ; preds = %0
%22 = load i32, i32* @R_OK
%23 = load i32, i32* @W_OK
%24 = or i32 %23, %22
%25 = tail call i64 @access(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.11, i64 0, i64 0))
br label %74
29: ; preds = %21
%30 = tail call i64 @unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load i32, i32* @errno
%34 = tail call i8* @strerror(i32 %33)
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %34)
br label %74
36: ; preds = %29
%37 = load i32, i32* @SEEK_CUR
%38 = tail call i32 @lseek(i32 %15, i32 0, i32 %37)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%41 = call i32 @write(i32 %15, i8* %40, i32 32)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %47
43: ; preds = %36
%44 = load i32, i32* @errno
%45 = tail call i8* @strerror(i32 %44)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %45)
br label %72
47: ; preds = %36
%48 = tail call i32 (...) @sync()
%49 = tail call i32 @fsync(i32 %15)
%50 = tail call i32 @fdatasync(i32 %15)
%51 = call i32 @memset(i8* %40, i32 0, i32 32)
%52 = load i32, i32* @SEEK_SET
%53 = call i32 @lseek(i32 %15, i32 0, i32 %52)
%54 = call i32 @read(i32 %15, i8* %40, i32 %41)
%55 = icmp ne i32 %54, -1
%56 = icmp eq i32 %54, %41
%57 = and i1 %55, %56
br i1 %57, label %62, label %58
58: ; preds = %47
%59 = load i32, i32* @errno
%60 = call i8* @strerror(i32 %59)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %60)
br label %72
62: ; preds = %47
%63 = call i32 @puts(i8* %40)
%64 = call i32 @close(i32 %15)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = load i32, i32* @errno
%68 = call i8* @strerror(i32 %67)
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %68)
br label %72
70: ; preds = %62
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %72
72: ; preds = %58, %70, %66, %43
%73 = phi i32 [ 1, %43 ], [ 1, %58 ], [ 1, %66 ], [ 0, %70 ]
br label %74
74: ; preds = %72, %32, %27, %17
%75 = phi i32 [ 1, %17 ], [ 1, %27 ], [ 1, %32 ], [ %73, %72 ]
ret i32 %75
}