#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 */
int EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ _IOFBF;
int /*<<< orphan*/ append(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
scalar_t__ s_gets(char *, int);
scalar_t__ setvbuf(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                   int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(void) {
  FILE *fa, *fs;
  int files = 0;
  char file_app[81];
  char file_src[81];
  int ch;
  puts("Enter name of destination file:");
  s_gets(file_app, 81);
  if ((fa = fopen(file_app, "a+")) == NULL) {
    fprintf(stderr, "Can't open %s\n", file_app);
    exit(EXIT_FAILURE);
  }
  if (setvbuf(fa, NULL, _IOFBF, 4096) != 0) {
    fputs("Can't create output buffer\n", stderr);
    exit(EXIT_FAILURE);
  }
  puts("Enter name of first source file (empty line to quit):");
  while (s_gets(file_src, 81) && file_src[0] != '\0') {
    if (strcmp(file_src, file_app) == 0)
      fputs("Can't append file to itself\n", stderr);
    else if ((fs = fopen(file_src, "r")) == NULL)
      fprintf(stderr, "Can't open %s\n", file_src);
    else {
      if (setvbuf(fs, NULL, _IOFBF, 4096) != 0) {
        fputs("Can't create input buffer\n", stderr);
        continue;
      }
      append(fs, fa);
      if (ferror(fs) != 0)
        fprintf(stderr, "ERROR reading file %s.\n", file_src);
      if (ferror(fa) != 0)
        fprintf(stderr, "ERROR writing file %s.\n", file_app);
      fclose(fs);
      files++;
      printf("File %s appended.\n", file_src);
      puts("Next file (empty line to quit):");
    }
  }
  printf("Done appending. %d files appended.\n", files);
  rewind(fa);
  printf("%s contents:\n", file_app);
  while ((ch = getc(fa)) != EOF)
    putchar(ch);
  puts("Done displaying.");
  fclose(fa);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xdf0(%rip),%rdi
call   1050 <puts@plt>
lea    -0x70(%rbp),%rdi
mov    $0x51,%esi
call   1080 <s_gets@plt>
lea    -0x70(%rbp),%rdi
lea    0xdf2(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1268 <main+0x78>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rdx
lea    0xdce(%rip),%rsi
call   10d0 <fprintf@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    0x2d55(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1000,%ecx
call   10e0 <setvbuf@plt>
cmp    $0x0,%rax
je     12b0 <main+0xc0>
mov    0x2d44(%rip),%rax
mov    (%rax),%esi
lea    0xd95(%rip),%rdi
call   10b0 <fputs@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    0xd97(%rip),%rdi
call   1050 <puts@plt>
lea    -0xd0(%rbp),%rdi
mov    $0x51,%esi
call   1080 <s_gets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0xd5(%rbp)
je     12f5 <main+0x105>
movsbl -0xd0(%rbp),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xd5(%rbp)
mov    -0xd5(%rbp),%al
test   $0x1,%al
jne    1308 <main+0x118>
jmp    1462 <main+0x272>
lea    -0xd0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    133c <main+0x14c>
mov    0x2caf(%rip),%rax
mov    (%rax),%esi
lea    0xd52(%rip),%rdi
call   10b0 <fputs@plt>
jmp    145d <main+0x26d>
lea    -0xd0(%rbp),%rdi
lea    0xd57(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    137e <main+0x18e>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
lea    -0xd0(%rbp),%rdx
lea    0xcaf(%rip),%rsi
call   10d0 <fprintf@plt>
jmp    1458 <main+0x268>
mov    -0x18(%rbp),%rdi
mov    0x2c3f(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1000,%ecx
call   10e0 <setvbuf@plt>
cmp    $0x0,%rax
je     13bd <main+0x1cd>
mov    0x2c2e(%rip),%rax
mov    (%rax),%esi
lea    0xcf0(%rip),%rdi
call   10b0 <fputs@plt>
jmp    12bc <main+0xcc>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <append@plt>
mov    -0x18(%rbp),%rdi
call   1060 <ferror@plt>
cmp    $0x0,%rax
je     13f9 <main+0x209>
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
lea    -0xd0(%rbp),%rdx
lea    0xcca(%rip),%rsi
call   10d0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ferror@plt>
cmp    $0x0,%rax
je     1425 <main+0x235>
mov    0x2bc5(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rdx
lea    0xcb6(%rip),%rsi
call   10d0 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
lea    -0xd0(%rbp),%rsi
lea    0xca9(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    0xcae(%rip),%rdi
call   1050 <puts@plt>
jmp    145d <main+0x26d>
jmp    12bc <main+0xcc>
mov    -0x1c(%rbp),%esi
lea    0xcb5(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <rewind@plt>
lea    -0x70(%rbp),%rsi
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1110 <getc@plt>
mov    %eax,-0xd4(%rbp)
mov    0x2b44(%rip),%rcx
cmp    (%rcx),%eax
je     14bc <main+0x2cc>
mov    -0xd4(%rbp),%edi
call   1030 <putchar@plt>
jmp    148e <main+0x29e>
lea    0xc90(%rip),%rdi
call   1050 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
lea    0xdf8(%rip),%rdi
call   1050 <puts@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x51,%esi
call   1080 <s_gets@plt>
lea    0xdfa(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     144b <main+0x25b>
mov    %rax,%r15
mov    0x2d87(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%ecx
call   10e0 <setvbuf@plt>
test   %rax,%rax
jne    1467 <main+0x277>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0xde5(%rip),%rdi
call   1050 <puts@plt>
lea    0x10(%rsp),%rdi
mov    $0x51,%esi
call   1080 <s_gets@plt>
test   %rax,%rax
je     13c6 <main+0x1d6>
cmpb   $0x0,0x10(%rsp)
je     13c6 <main+0x1d6>
lea    0x10(%rsp),%rbx
lea    0x70(%rsp),%r12
mov    0x2d36(%rip),%r13
lea    0xdf8(%rip),%rbp
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1322 <main+0x132>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     132f <main+0x13f>
mov    %rax,%r14
mov    0x2cee(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1000,%ecx
call   10e0 <setvbuf@plt>
test   %rax,%rax
je     1344 <main+0x154>
mov    0x0(%r13),%esi
lea    0xda8(%rip),%rdi
call   10b0 <fputs@plt>
mov    %rbx,%rdi
mov    $0x51,%esi
call   1080 <s_gets@plt>
test   %rax,%rax
je     13c6 <main+0x1d6>
cmpb   $0x0,0x10(%rsp)
jne    12b0 <main+0xc0>
jmp    13c6 <main+0x1d6>
mov    0x0(%r13),%esi
lea    0xd57(%rip),%rdi
jmp    12fb <main+0x10b>
mov    0x0(%r13),%edi
lea    0xce9(%rip),%rsi
mov    %rbx,%rdx
call   10d0 <fprintf@plt>
jmp    1300 <main+0x110>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <append@plt>
mov    %r14,%rdi
call   1060 <ferror@plt>
test   %rax,%rax
je     136f <main+0x17f>
mov    0x0(%r13),%edi
lea    0xd57(%rip),%rsi
mov    %rbx,%rdx
call   10d0 <fprintf@plt>
mov    %r15,%rdi
call   1060 <ferror@plt>
test   %rax,%rax
je     138f <main+0x19f>
mov    0x0(%r13),%edi
lea    0xd4f(%rip),%rsi
mov    %r12,%rdx
call   10d0 <fprintf@plt>
mov    %r14,%rdi
call   1070 <fclose@plt>
mov    0x8(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x8(%rsp)
lea    0xd43(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd45(%rip),%rdi
call   1050 <puts@plt>
jmp    1300 <main+0x110>
lea    0xd54(%rip),%rdi
mov    0x8(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   10a0 <rewind@plt>
lea    0xd5d(%rip),%rdi
lea    0x70(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   1110 <getc@plt>
mov    0x2be5(%rip),%rbx
cmp    (%rbx),%eax
je     1423 <main+0x233>
nopw   0x0(%rax,%rax,1)
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1110 <getc@plt>
cmp    (%rbx),%eax
jne    1410 <main+0x220>
lea    0xd29(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b86(%rip),%rax
mov    (%rax),%edi
lea    0xbc8(%rip),%rsi
lea    0x70(%rsp),%rdx
call   10d0 <fprintf@plt>
jmp    147c <main+0x28c>
mov    0x2b6a(%rip),%rax
mov    (%rax),%esi
lea    0xbbb(%rip),%rdi
call   10b0 <fputs@plt>
mov    0x2b4d(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"Enter name of destination file:\00"
@.str.1 = [3 x i8] c"a+\00"
@stderr = global i32 0
@.str.2 = [15 x i8] c"Can't open %s\0A\00"
@EXIT_FAILURE = global i32 0
@_IOFBF = global i32 0
@.str.3 = [28 x i8] c"Can't create output buffer\0A\00"
@.str.4 = [54 x i8] c"Enter name of first source file (empty line to quit):\00"
@.str.5 = [29 x i8] c"Can't append file to itself\0A\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [27 x i8] c"Can't create input buffer\0A\00"
@.str.8 = [24 x i8] c"ERROR reading file %s.\0A\00"
@.str.9 = [24 x i8] c"ERROR writing file %s.\0A\00"
@.str.10 = [19 x i8] c"File %s appended.\0A\00"
@.str.11 = [32 x i8] c"Next file (empty line to quit):\00"
@.str.12 = [36 x i8] c"Done appending. %d files appended.\0A\00"
@.str.13 = [14 x i8] c"%s contents:\0A\00"
@EOF = global i32 0
@.str.14 = [17 x i8] c"Done displaying.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [81 x i8]
%6 = alloca [81 x i8]
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%8 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%10 = call i64 @s_gets(i8* %9, i32 81)
%11 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %2
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %20
14: ; preds = %0
%15 = load i32, i32* @stderr
%16 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%17 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %0
%21 = load i32*, i32** %2
%22 = load i32, i32* @_IOFBF
%23 = call i64 @setvbuf(i32* %21, i32* null, i32 %22, i32 4096)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = call i32 @fputs(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %20
%31 = call i32 @puts(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %95, %64, %30
%33 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%34 = call i64 @s_gets(i8* %33, i32 81)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br label %41
41: ; preds = %36, %32
%42 = phi i1 [ false, %32 ], [ %40, %36 ]
br i1 %42, label %43, label %96
43: ; preds = %41
%44 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%45 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%46 = call i64 @strcmp(i8* %44, i8* %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = load i32, i32* @stderr
%50 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %49)
br label %95
51: ; preds = %43
%52 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %53, i32** %3
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = load i32, i32* @stderr
%57 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%58 = call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %57)
br label %94
59: ; preds = %51
%60 = load i32*, i32** %3
%61 = load i32, i32* @_IOFBF
%62 = call i64 @setvbuf(i32* %60, i32* null, i32 %61, i32 4096)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %59
%65 = load i32, i32* @stderr
%66 = call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %65)
br label %32
67: ; preds = %59
%68 = load i32*, i32** %3
%69 = load i32*, i32** %2
%70 = call i32 @append(i32* %68, i32* %69)
%71 = load i32*, i32** %3
%72 = call i64 @ferror(i32* %71)
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %67
%75 = load i32, i32* @stderr
%76 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%77 = call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %76)
br label %78
78: ; preds = %74, %67
%79 = load i32*, i32** %2
%80 = call i64 @ferror(i32* %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %78
%83 = load i32, i32* @stderr
%84 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%85 = call i32 @fprintf(i32 %83, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %82, %78
%87 = load i32*, i32** %3
%88 = call i32 @fclose(i32* %87)
%89 = load i32, i32* %4
%90 = add nsw i32 %89, 1
store i32 %90, i32* %4
%91 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %91)
%93 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0))
br label %94
94: ; preds = %86, %55
br label %95
95: ; preds = %94, %48
br label %32
96: ; preds = %41
%97 = load i32, i32* %4
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i32 %97)
%99 = load i32*, i32** %2
%100 = call i32 @rewind(i32* %99)
%101 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i8* %101)
br label %103
103: ; preds = %108, %96
%104 = load i32*, i32** %2
%105 = call i32 @getc(i32* %104)
store i32 %105, i32* %7
%106 = load i32, i32* @EOF
%107 = icmp ne i32 %105, %106
br i1 %107, label %108, label %111
108: ; preds = %103
%109 = load i32, i32* %7
%110 = call i32 @putchar(i32 %109)
br label %103
111: ; preds = %103
%112 = call i32 @puts(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
%113 = load i32*, i32** %2
%114 = call i32 @fclose(i32* %113)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"Enter name of destination file:\00"
@.str.1 = [3 x i8] c"a+\00"
@stderr = global i32 0
@.str.2 = [15 x i8] c"Can't open %s\0A\00"
@EXIT_FAILURE = global i32 0
@_IOFBF = global i32 0
@.str.3 = [28 x i8] c"Can't create output buffer\0A\00"
@.str.4 = [54 x i8] c"Enter name of first source file (empty line to quit):\00"
@.str.5 = [29 x i8] c"Can't append file to itself\0A\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [27 x i8] c"Can't create input buffer\0A\00"
@.str.8 = [24 x i8] c"ERROR reading file %s.\0A\00"
@.str.9 = [24 x i8] c"ERROR writing file %s.\0A\00"
@.str.10 = [19 x i8] c"File %s appended.\0A\00"
@.str.11 = [32 x i8] c"Next file (empty line to quit):\00"
@.str.12 = [36 x i8] c"Done appending. %d files appended.\0A\00"
@.str.13 = [14 x i8] c"%s contents:\0A\00"
@EOF = global i32 0
@.str.14 = [17 x i8] c"Done displaying.\00"
define i32 @main() {
%1 = alloca [81 x i8]
%2 = alloca [81 x i8]
%3 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%6 = call i64 @s_gets(i8* %3, i32 81)
%7 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = load i32, i32* @_IOFBF
%16 = call i64 @setvbuf(i32* %7, i32* null, i32 %15, i32 4096)
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %14
%19 = load i32, i32* @stderr
%20 = call i32 @fputs(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %14
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%25 = call i64 @s_gets(i8* %4, i32 81)
%26 = icmp ne i64 %25, 0
%27 = load i8, i8* %4
%28 = icmp ne i8 %27, 0
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %30, label %81
30: ; preds = %23, %74
%31 = phi i32 [ %75, %74 ], [ 0, %23 ]
br label %32
32: ; preds = %30, %48
%33 = call i64 @strcmp(i8* %4, i8* %3)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %36)
br label %74
38: ; preds = %32
%39 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %44
41: ; preds = %38
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %74
44: ; preds = %38
%45 = load i32, i32* @_IOFBF
%46 = call i64 @setvbuf(i32* %39, i32* null, i32 %45, i32 4096)
%47 = icmp eq i64 %46, 0
br i1 %47, label %56, label %48
48: ; preds = %44
%49 = load i32, i32* @stderr
%50 = call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %49)
%51 = call i64 @s_gets(i8* %4, i32 81)
%52 = icmp ne i64 %51, 0
%53 = load i8, i8* %4
%54 = icmp ne i8 %53, 0
%55 = select i1 %52, i1 %54, i1 false
br i1 %55, label %32, label %81
56: ; preds = %44
%57 = call i32 @append(i32* %39, i32* %7)
%58 = call i64 @ferror(i32* %39)
%59 = icmp eq i64 %58, 0
br i1 %59, label %63, label %60
60: ; preds = %56
%61 = load i32, i32* @stderr
%62 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %63
63: ; preds = %60, %56
%64 = call i64 @ferror(i32* %7)
%65 = icmp eq i64 %64, 0
br i1 %65, label %69, label %66
66: ; preds = %63
%67 = load i32, i32* @stderr
%68 = call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %3)
br label %69
69: ; preds = %66, %63
%70 = call i32 @fclose(i32* %39)
%71 = add nsw i32 %31, 1
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %4)
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0))
br label %74
74: ; preds = %41, %69, %35
%75 = phi i32 [ %31, %35 ], [ %31, %41 ], [ %71, %69 ]
%76 = call i64 @s_gets(i8* %4, i32 81)
%77 = icmp ne i64 %76, 0
%78 = load i8, i8* %4
%79 = icmp ne i8 %78, 0
%80 = select i1 %77, i1 %79, i1 false
br i1 %80, label %30, label %81
81: ; preds = %74, %48, %23
%82 = phi i32 [ 0, %23 ], [ %31, %48 ], [ %75, %74 ]
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i32 %82)
%84 = call i32 @rewind(i32* %7)
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i8* %3)
%86 = call i32 @getc(i32* %7)
%87 = load i32, i32* @EOF
%88 = icmp eq i32 %86, %87
br i1 %88, label %95, label %89
89: ; preds = %81, %89
%90 = phi i32 [ %92, %89 ], [ %86, %81 ]
%91 = call i32 @putchar(i32 %90)
%92 = call i32 @getc(i32* %7)
%93 = load i32, i32* @EOF
%94 = icmp eq i32 %92, %93
br i1 %94, label %95, label %89
95: ; preds = %89, %81
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
%97 = call i32 @fclose(i32* %7)
ret i32 0
}