#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 /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ exit(int);
scalar_t__ feof(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
char fputc(char, int /*<<< orphan*/ *);
char fputs(char *, int /*<<< orphan*/ *);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
scalar_t__ fwrite(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int main() {
  const char *f = "test.txt";
  const char *s = "file_writer.c";
  char buf[100], ch, *buff;
  FILE *file, *source;
  if ((file = fopen(f, "a+r")) == NULL) {
    perror("fopen file error");
    exit(-1);
  } else {
    printf("fopen file success!!\n");
  }
  if ((source = fopen(s, "r")) == NULL) {
    perror("fopen file error");
    exit(-1);
  }
  printf("----------------------------s------------------------------\n");
  while (fgets(buf, 100, source) != NULL) {
    if (fputs(buf, file) == EOF) {
      perror("fputs error ...");
      exit(-1);
    }
  }
  printf("----------------------------c------------------------------\n");
  while ((ch = fgetc(file)) != EOF) {
    if (feof(file))
      printf("file read is over! ");
    if (ferror(file))
      printf(" read fail!");
    if (fputc(ch, file) == EOF) {
      perror("writer error ....");
    }
  }
  fseek(file, 0, SEEK_END);
  int lSize = ftell(file);
  rewind(file);
  buff = (char *)malloc(sizeof(char) * lSize);
  while (fread(buff, 1, lSize, file)) {
    printf("%s", buff);
    if (feof(file)) {
      printf("file over\n");
      break;
    }
    if (ferror(file)) {
      printf(" read fail!");
      break;
    }
    if (fwrite(buff, 1, lSize, file) == 0) {
      perror("fwrite error");
      exit(-1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xde7(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xde5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xde4(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x98(%rbp)
cmp    $0x0,%rax
jne    125f <main+0x5f>
lea    0xdcb(%rip),%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
lea    0xdc6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xda1(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0xa0(%rbp)
cmp    $0x0,%rax
jne    12a4 <main+0xa4>
lea    0xd86(%rip),%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0xa0(%rbp),%rdx
mov    $0x64,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     1311 <main+0x111>
lea    -0x80(%rbp),%rdi
mov    -0x98(%rbp),%rsi
call   1070 <fputs@plt>
movsbl %al,%eax
mov    0x2cf5(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    130c <main+0x10c>
lea    0xd82(%rip),%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
jmp    12b2 <main+0xb2>
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x98(%rbp),%rdi
call   1080 <fgetc@plt>
mov    %al,-0x81(%rbp)
movsbl %al,%eax
mov    0x2ca5(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     13c9 <main+0x1c9>
mov    -0x98(%rbp),%rdi
call   10c0 <feof@plt>
cmp    $0x0,%rax
je     136a <main+0x16a>
lea    0xd69(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x98(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     138e <main+0x18e>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x81(%rbp),%al
mov    -0x98(%rbp),%rsi
movsbl %al,%edi
call   1090 <fputc@plt>
movsbl %al,%eax
mov    0x2c33(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    13c4 <main+0x1c4>
lea    0xd2d(%rip),%rdi
call   1100 <perror@plt>
jmp    131f <main+0x11f>
mov    -0x98(%rbp),%rdi
mov    0x2c11(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10e0 <fseek@plt>
mov    -0x98(%rbp),%rdi
call   10b0 <ftell@plt>
mov    %eax,-0xa4(%rbp)
mov    -0x98(%rbp),%rdi
call   1060 <rewind@plt>
movslq -0xa4(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rdi
mov    -0xa4(%rbp),%edx
mov    -0x98(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
cmp    $0x0,%rax
je     14e9 <main+0x2e9>
mov    -0x90(%rbp),%rsi
lea    0xcb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x98(%rbp),%rdi
call   10c0 <feof@plt>
cmp    $0x0,%rax
je     147d <main+0x27d>
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14e9 <main+0x2e9>
mov    -0x98(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     14a6 <main+0x2a6>
lea    0xc46(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14e9 <main+0x2e9>
mov    -0x90(%rbp),%rdi
mov    -0xa4(%rbp),%edx
mov    -0x98(%rbp),%rcx
mov    $0x1,%esi
call   1120 <fwrite@plt>
cmp    $0x0,%rax
jne    14e4 <main+0x2e4>
lea    0xc37(%rip),%rdi
call   1100 <perror@plt>
mov    $0xffffffff,%edi
call   1110 <exit@plt>
jmp    1417 <main+0x217>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xddb(%rip),%rdi
lea    0xdeb(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
je     143c <main+0x22c>
mov    %rax,%rbp
lea    0xe3a(%rip),%rdi
call   1030 <puts@plt>
lea    0xdb9(%rip),%rdi
lea    0xdc2(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
je     143c <main+0x22c>
mov    %rax,%r14
lea    0xe24(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rbx
mov    0x2d62(%rip),%r13
xchg   %ax,%ax
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     12b2 <main+0xa2>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1080 <fputs@plt>
cmp    0x0(%r13),%al
jne    1280 <main+0x70>
lea    0xd7f(%rip),%rdi
jmp    137a <main+0x16a>
lea    0xe16(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1090 <fgetc@plt>
cmp    0x0(%r13),%al
jne    1389 <main+0x179>
mov    0x2d11(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    %rbp,%rdi
call   10c0 <ftell@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1070 <rewind@plt>
mov    %r14d,%edi
call   10e0 <malloc@plt>
mov    %rax,%rbx
lea    0xd66(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rbp,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     142b <main+0x21b>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
call   10d0 <feof@plt>
test   %rax,%rax
jne    140f <main+0x1ff>
mov    %rbp,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
jne    141d <main+0x20d>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %rbp,%rcx
call   1130 <fwrite@plt>
test   %rax,%rax
jne    1310 <main+0x100>
lea    0xcf7(%rip),%rdi
call   1110 <perror@plt>
mov    $0xffffffff,%edi
call   1120 <exit@plt>
mov    %eax,%ebx
lea    0xcca(%rip),%r14
lea    0xcb7(%rip),%r15
lea    0xc9c(%rip),%r12
jmp    13d5 <main+0x1c5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %bl,%edi
mov    %rbp,%rsi
call   10a0 <fputc@plt>
cmp    0x0(%r13),%al
je     1405 <main+0x1f5>
mov    %rbp,%rdi
call   1090 <fgetc@plt>
mov    %eax,%ebx
cmp    0x0(%r13),%al
je     12d0 <main+0xc0>
mov    %rbp,%rdi
call   10d0 <feof@plt>
test   %rax,%rax
je     13ec <main+0x1dc>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
call   1040 <ferror@plt>
test   %rax,%rax
je     13b0 <main+0x1a0>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    13b0 <main+0x1a0>
mov    %r14,%rdi
call   1110 <perror@plt>
jmp    13c1 <main+0x1b1>
lea    0xcf5(%rip),%rdi
call   1030 <puts@plt>
jmp    142b <main+0x21b>
lea    0xc2c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbd8(%rip),%rdi
jmp    137a <main+0x16a>

LLVM IR (-O0):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [14 x i8] c"file_writer.c\00"
@.str.2 = [4 x i8] c"a+r\00"
@.str.3 = [17 x i8] c"fopen file error\00"
@.str.4 = [22 x i8] c"fopen file success!!\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [61 x i8] c"----------------------------s------------------------------\0A\00"
@EOF = global i8 0
@.str.7 = [16 x i8] c"fputs error ...\00"
@.str.8 = [61 x i8] c"----------------------------c------------------------------\0A\00"
@.str.9 = [20 x i8] c"file read is over! \00"
@.str.10 = [12 x i8] c" read fail!\00"
@.str.11 = [18 x i8] c"writer error ....\00"
@SEEK_END = global i32 0
@.str.12 = [3 x i8] c"%s\00"
@.str.13 = [11 x i8] c"file over\0A\00"
@.str.14 = [13 x i8] c"fwrite error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [100 x i8]
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %1
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %3
%10 = load i8*, i8** %2
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32* %11, i32** %7
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @exit(i32 -1)
unreachable
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %18
18: ; preds = %16
%19 = load i8*, i8** %3
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %20, i32** %8
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %18
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.6, i64 0, i64 0))
br label %27
27: ; preds = %43, %25
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%29 = load i32*, i32** %8
%30 = call i32* @fgets(i8* %28, i32 100, i32* %29)
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %44
32: ; preds = %27
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%34 = load i32*, i32** %7
%35 = call signext i8 @fputs(i8* %33, i32* %34)
%36 = sext i8 %35 to i32
%37 = load i8, i8* @EOF
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %36, %38
br i1 %39, label %40, label %43
40: ; preds = %32
%41 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%42 = call i32 @exit(i32 -1)
unreachable
43: ; preds = %32
br label %27
44: ; preds = %27
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0))
br label %46
46: ; preds = %75, %44
%47 = load i32*, i32** %7
%48 = call signext i8 @fgetc(i32* %47)
store i8 %48, i8* %5
%49 = sext i8 %48 to i32
%50 = load i8, i8* @EOF
%51 = sext i8 %50 to i32
%52 = icmp ne i32 %49, %51
br i1 %52, label %53, label %76
53: ; preds = %46
%54 = load i32*, i32** %7
%55 = call i64 @feof(i32* %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %59
59: ; preds = %57, %53
%60 = load i32*, i32** %7
%61 = call i64 @ferror(i32* %60)
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %65
65: ; preds = %63, %59
%66 = load i8, i8* %5
%67 = load i32*, i32** %7
%68 = call signext i8 @fputc(i8 signext %66, i32* %67)
%69 = sext i8 %68 to i32
%70 = load i8, i8* @EOF
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %69, %71
br i1 %72, label %73, label %75
73: ; preds = %65
%74 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %75
75: ; preds = %73, %65
br label %46
76: ; preds = %46
%77 = load i32*, i32** %7
%78 = load i32, i32* @SEEK_END
%79 = call i32 @fseek(i32* %77, i32 0, i32 %78)
%80 = load i32*, i32** %7
%81 = call i32 @ftell(i32* %80)
store i32 %81, i32* %9
%82 = load i32*, i32** %7
%83 = call i32 @rewind(i32* %82)
%84 = load i32, i32* %9
%85 = sext i32 %84 to i64
%86 = mul i64 1, %85
%87 = trunc i64 %86 to i32
%88 = call i64 @malloc(i32 %87)
%89 = inttoptr i64 %88 to i8*
store i8* %89, i8** %6
br label %90
90: ; preds = %119, %76
%91 = load i8*, i8** %6
%92 = load i32, i32* %9
%93 = load i32*, i32** %7
%94 = call i64 @fread(i8* %91, i32 1, i32 %92, i32* %93)
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %120
96: ; preds = %90
%97 = load i8*, i8** %6
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %97)
%99 = load i32*, i32** %7
%100 = call i64 @feof(i32* %99)
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %96
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.13, i64 0, i64 0))
br label %120
104: ; preds = %96
%105 = load i32*, i32** %7
%106 = call i64 @ferror(i32* %105)
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %110
108: ; preds = %104
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %120
110: ; preds = %104
%111 = load i8*, i8** %6
%112 = load i32, i32* %9
%113 = load i32*, i32** %7
%114 = call i64 @fwrite(i8* %111, i32 1, i32 %112, i32* %113)
%115 = icmp eq i64 %114, 0
br i1 %115, label %116, label %119
116: ; preds = %110
%117 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%118 = call i32 @exit(i32 -1)
unreachable
119: ; preds = %110
br label %90
120: ; preds = %108, %102, %90
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"test.txt\00"
@.str.1 = [14 x i8] c"file_writer.c\00"
@.str.2 = [4 x i8] c"a+r\00"
@.str.3 = [17 x i8] c"fopen file error\00"
@.str.5 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.7 = [16 x i8] c"fputs error ...\00"
@.str.9 = [20 x i8] c"file read is over! \00"
@.str.10 = [12 x i8] c" read fail!\00"
@.str.11 = [18 x i8] c"writer error ....\00"
@SEEK_END = global i32 0
@.str.12 = [3 x i8] c"%s\00"
@.str.14 = [13 x i8] c"fwrite error\00"
@str = [21 x i8] c"fopen file success!!\00"
@str.15 = [60 x i8] c"----------------------------s------------------------------\00"
@str.16 = [60 x i8] c"----------------------------c------------------------------\00"
@str.17 = [10 x i8] c"file over\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %8
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.15, i64 0, i64 0))
br label %17
17: ; preds = %20, %15
%18 = call i32* @fgets(i8* %2, i32 100, i32* %10)
%19 = icmp eq i32* %18, null
br i1 %19, label %27, label %20
20: ; preds = %17
%21 = call signext i8 @fputs(i8* %2, i32* %3)
%22 = load i8, i8* @EOF
%23 = icmp eq i8 %21, %22
br i1 %23, label %24, label %17
24: ; preds = %20
%25 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%26 = call i32 @exit(i32 -1)
unreachable
27: ; preds = %17
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.16, i64 0, i64 0))
%29 = call signext i8 @fgetc(i32* %3)
%30 = load i8, i8* @EOF
%31 = icmp eq i8 %29, %30
br i1 %31, label %53, label %32
32: ; preds = %27, %49
%33 = phi i8 [ %50, %49 ], [ %29, %27 ]
%34 = call i64 @feof(i32* %3)
%35 = icmp eq i64 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0))
br label %38
38: ; preds = %36, %32
%39 = call i64 @ferror(i32* %3)
%40 = icmp eq i64 %39, 0
br i1 %40, label %43, label %41
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %43
43: ; preds = %41, %38
%44 = call signext i8 @fputc(i8 signext %33, i32* %3)
%45 = load i8, i8* @EOF
%46 = icmp eq i8 %44, %45
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = call signext i8 @fgetc(i32* %3)
%51 = load i8, i8* @EOF
%52 = icmp eq i8 %50, %51
br i1 %52, label %53, label %32
53: ; preds = %49, %27
%54 = load i32, i32* @SEEK_END
%55 = call i32 @fseek(i32* %3, i32 0, i32 %54)
%56 = call i32 @ftell(i32* %3)
%57 = call i32 @rewind(i32* %3)
%58 = call i64 @malloc(i32 %56)
%59 = inttoptr i64 %58 to i8*
br label %60
60: ; preds = %74, %53
%61 = call i64 @fread(i8* %59, i32 1, i32 %56, i32* %3)
%62 = icmp eq i64 %61, 0
br i1 %62, label %80, label %63
63: ; preds = %60
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* %59)
%65 = call i64 @feof(i32* %3)
%66 = icmp eq i64 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %63
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.17, i64 0, i64 0))
br label %80
69: ; preds = %63
%70 = call i64 @ferror(i32* %3)
%71 = icmp eq i64 %70, 0
br i1 %71, label %74, label %72
72: ; preds = %69
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %80
74: ; preds = %69
%75 = call i64 @fwrite(i8* %59, i32 1, i32 %56, i32* %3)
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %60
77: ; preds = %74
%78 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.14, i64 0, i64 0))
%79 = call i32 @exit(i32 -1)
unreachable
80: ; preds = %60, %72, %67
ret i32 0
}