#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 *fd, *fs;
  int files = 0;
  char file_dest[81];
  char file_src[81];
  int ch;
  puts("Enter name of destination(target) file:");
  s_gets(file_dest, 81);
  if ((fd = fopen(file_dest, "a+")) == NULL) {
    fprintf(stderr, "Can't open %s\n", file_dest);
    exit(EXIT_FAILURE);
  }
  if (setvbuf(fd, 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_dest) == 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, fd);
    if (ferror(fs) != 0) {
      fprintf(stderr, "Error in reading file %s\n", file_src);
    }
    if (ferror(fd) != 0) {
      fprintf(stderr, "Error in writing file %s\n", file_dest);
    }
    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(fd);
  printf("%s content: \n", file_dest);
  while ((ch = getc(fd)) != EOF) {
    putchar(ch);
  }
  puts("Done displaying.");
  fclose(fd);
  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    0xdfa(%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    0xdd6(%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    0xd9d(%rip),%rdi
call   10b0 <fputs@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    0xd9f(%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    1467 <main+0x277>
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    0xd5b(%rip),%rdi
call   10b0 <fputs@plt>
jmp    13c7 <main+0x1d7>
lea    -0xd0(%rbp),%rdi
lea    0xd60(%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    0xcb7(%rip),%rsi
call   10d0 <fprintf@plt>
jmp    13c2 <main+0x1d2>
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    0xcf9(%rip),%rdi
call   10b0 <fputs@plt>
jmp    12bc <main+0xcc>
jmp    13c2 <main+0x1d2>
jmp    13c7 <main+0x1d7>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <append@plt>
mov    -0x18(%rbp),%rdi
call   1060 <ferror@plt>
cmp    $0x0,%rax
je     1403 <main+0x213>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
lea    -0xd0(%rbp),%rdx
lea    0xcc9(%rip),%rsi
call   10d0 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <ferror@plt>
cmp    $0x0,%rax
je     142f <main+0x23f>
mov    0x2bbb(%rip),%rax
mov    (%rax),%edi
lea    -0x70(%rbp),%rdx
lea    0xcb7(%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    0xcac(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    0xcb1(%rip),%rdi
call   1050 <puts@plt>
jmp    12bc <main+0xcc>
mov    -0x1c(%rbp),%esi
lea    0xcbe(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <rewind@plt>
lea    -0x70(%rbp),%rsi
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1110 <getc@plt>
mov    %eax,-0xd4(%rbp)
mov    0x2b3f(%rip),%rcx
cmp    (%rcx),%eax
je     14c1 <main+0x2d1>
mov    -0xd4(%rbp),%edi
call   1030 <putchar@plt>
jmp    1493 <main+0x2a3>
lea    0xc99(%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    $0xb8,%rsp
lea    0xdf8(%rip),%rdi
call   1050 <puts@plt>
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x51,%esi
call   1080 <s_gets@plt>
lea    0xe02(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     142b <main+0x23b>
mov    %rax,%r15
mov    0x2d87(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%ecx
call   10e0 <setvbuf@plt>
test   %rax,%rax
jne    1447 <main+0x257>
lea    0xdf1(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%rdi
mov    $0x51,%esi
call   1080 <s_gets@plt>
test   %rax,%rax
je     13b1 <main+0x1c1>
cmpb   $0x0,(%rsp)
je     13b1 <main+0x1c1>
mov    %rsp,%rbx
lea    0x60(%rsp),%r12
mov    0x2d3f(%rip),%rbp
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     1314 <main+0x124>
mov    %rbx,%rdi
lea    0xdf0(%rip),%rsi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1325 <main+0x135>
mov    %rax,%r13
mov    0x2cfa(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x1000,%ecx
call   10e0 <setvbuf@plt>
test   %rax,%rax
je     133a <main+0x14a>
mov    0x0(%rbp),%esi
lea    0xdbe(%rip),%rdi
call   10b0 <fputs@plt>
mov    %rbx,%rdi
mov    $0x51,%esi
call   1080 <s_gets@plt>
test   %rax,%rax
je     13b1 <main+0x1c1>
cmpb   $0x0,(%rsp)
jne    12a0 <main+0xb0>
jmp    13b1 <main+0x1c1>
mov    0x0(%rbp),%esi
lea    0xd6f(%rip),%rdi
call   10b0 <fputs@plt>
jmp    133a <main+0x14a>
mov    0x0(%rbp),%edi
lea    0xcfc(%rip),%rsi
mov    %rbx,%rdx
call   10d0 <fprintf@plt>
xor    %r13d,%r13d
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <append@plt>
mov    %r13,%rdi
call   1060 <ferror@plt>
test   %rax,%rax
je     1364 <main+0x174>
mov    0x0(%rbp),%edi
lea    0xd6b(%rip),%rsi
mov    %rbx,%rdx
call   10d0 <fprintf@plt>
mov    %r15,%rdi
call   1060 <ferror@plt>
test   %rax,%rax
je     1383 <main+0x193>
mov    0x0(%rbp),%edi
lea    0xd66(%rip),%rsi
mov    %r12,%rdx
call   10d0 <fprintf@plt>
mov    %r13,%rdi
call   1070 <fclose@plt>
add    $0x1,%r14d
lea    0xd65(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
lea    0xd67(%rip),%rdi
call   1050 <puts@plt>
jmp    12f3 <main+0x103>
lea    0xd77(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   10a0 <rewind@plt>
lea    0xd82(%rip),%rdi
lea    0x60(%rsp),%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %r15,%rdi
call   1110 <getc@plt>
mov    0x2bfc(%rip),%rbx
cmp    (%rbx),%eax
je     1403 <main+0x213>
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %r15,%rdi
call   1110 <getc@plt>
cmp    (%rbx),%eax
jne    13f0 <main+0x200>
lea    0xd57(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ba6(%rip),%rax
mov    (%rax),%edi
lea    0xbf0(%rip),%rsi
lea    0x60(%rsp),%rdx
call   10d0 <fprintf@plt>
jmp    145c <main+0x26c>
mov    0x2b8a(%rip),%rax
mov    (%rax),%esi
lea    0xbe3(%rip),%rdi
call   10b0 <fputs@plt>
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"Enter name of destination(target) 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 = [55 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 = [26 x i8] c"Error in reading file %s\0A\00"
@.str.9 = [26 x i8] c"Error in writing file %s\0A\00"
@.str.10 = [19 x i8] c"File %s appended.\0A\00"
@.str.11 = [33 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 content: \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 ([40 x i8], [40 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 ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %88, %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 %69
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 %68
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
br label %68
68: ; preds = %67, %55
br label %69
69: ; preds = %68, %48
%70 = load i32*, i32** %3
%71 = load i32*, i32** %2
%72 = call i32 @append(i32* %70, i32* %71)
%73 = load i32*, i32** %3
%74 = call i64 @ferror(i32* %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %69
%77 = load i32, i32* @stderr
%78 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%79 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %78)
br label %80
80: ; preds = %76, %69
%81 = load i32*, i32** %2
%82 = call i64 @ferror(i32* %81)
%83 = icmp ne i64 %82, 0
br i1 %83, label %84, label %88
84: ; preds = %80
%85 = load i32, i32* @stderr
%86 = getelementptr inbounds [81 x i8], [81 x i8]* %5, i64 0, i64 0
%87 = call i32 @fprintf(i32 %85, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %86)
br label %88
88: ; preds = %84, %80
%89 = load i32*, i32** %3
%90 = call i32 @fclose(i32* %89)
%91 = load i32, i32* %4
%92 = add nsw i32 %91, 1
store i32 %92, i32* %4
%93 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %93)
%95 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
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 = [40 x i8] c"Enter name of destination(target) 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 = [55 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 = [26 x i8] c"Error in reading file %s\0A\00"
@.str.9 = [26 x i8] c"Error in writing file %s\0A\00"
@.str.10 = [19 x i8] c"File %s appended.\0A\00"
@.str.11 = [33 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 content: \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 ([40 x i8], [40 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 ([55 x i8], [55 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 %84
30: ; preds = %23, %74
%31 = phi i32* [ %61, %74 ], [ undef, %23 ]
%32 = phi i32 [ %76, %74 ], [ 0, %23 ]
%33 = call i64 @strcmp(i8* %4, i8* %3)
%34 = icmp eq i64 %33, 0
br i1 %34, label %38, label %42
35: ; preds = %52
%36 = call i64 @strcmp(i8* %4, i8* %3)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35, %30
%39 = phi i32* [ %31, %30 ], [ %43, %35 ]
%40 = load i32, i32* @stderr
%41 = call i32 @fputs(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %40)
br label %60
42: ; preds = %30, %35
%43 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %60
48: ; preds = %42
%49 = load i32, i32* @_IOFBF
%50 = call i64 @setvbuf(i32* %43, i32* null, i32 %49, i32 4096)
%51 = icmp eq i64 %50, 0
br i1 %51, label %60, label %52
52: ; preds = %48
%53 = load i32, i32* @stderr
%54 = call i32 @fputs(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %53)
%55 = call i64 @s_gets(i8* %4, i32 81)
%56 = icmp ne i64 %55, 0
%57 = load i8, i8* %4
%58 = icmp ne i8 %57, 0
%59 = select i1 %56, i1 %58, i1 false
br i1 %59, label %35, label %84
60: ; preds = %48, %45, %38
%61 = phi i32* [ %39, %38 ], [ null, %45 ], [ %43, %48 ]
%62 = call i32 @append(i32* %61, i32* %7)
%63 = call i64 @ferror(i32* %61)
%64 = icmp eq i64 %63, 0
br i1 %64, label %68, label %65
65: ; preds = %60
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0), i8* %4)
br label %68
68: ; preds = %65, %60
%69 = call i64 @ferror(i32* %7)
%70 = icmp eq i64 %69, 0
br i1 %70, label %74, label %71
71: ; preds = %68
%72 = load i32, i32* @stderr
%73 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i8* %3)
br label %74
74: ; preds = %71, %68
%75 = call i32 @fclose(i32* %61)
%76 = add nuw nsw i32 %32, 1
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.10, i64 0, i64 0), i8* %4)
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0))
%79 = call i64 @s_gets(i8* %4, i32 81)
%80 = icmp ne i64 %79, 0
%81 = load i8, i8* %4
%82 = icmp ne i8 %81, 0
%83 = select i1 %80, i1 %82, i1 false
br i1 %83, label %30, label %84
84: ; preds = %74, %52, %23
%85 = phi i32 [ 0, %23 ], [ %32, %52 ], [ %76, %74 ]
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0), i32 %85)
%87 = call i32 @rewind(i32* %7)
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i8* %3)
%89 = call i32 @getc(i32* %7)
%90 = load i32, i32* @EOF
%91 = icmp eq i32 %89, %90
br i1 %91, label %98, label %92
92: ; preds = %84, %92
%93 = phi i32 [ %95, %92 ], [ %89, %84 ]
%94 = call i32 @putchar(i32 %93)
%95 = call i32 @getc(i32* %7)
%96 = load i32, i32* @EOF
%97 = icmp eq i32 %95, %96
br i1 %97, label %98, label %92
98: ; preds = %92, %84
%99 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0))
%100 = call i32 @fclose(i32* %7)
ret i32 0
}