#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 /*<<< orphan*/ f1(char *, char *);
int /*<<< orphan*/ f2(char *, char *);
int /*<<< orphan*/ f3(char *, char *);
int /*<<< orphan*/ f4(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char name[1024];
  sprintf(name, "%s.v1", "pgrmOut.txt");
  fprintf(stdout,
          "Reading %s. Writing %s. Wrong Reading Approach with fgetc/fputc.\n",
          "pgrmIn.txt", name);
  f1("pgrmIn.txt", name);
  sprintf(name, "%s.v2", "pgrmOut.txt");
  fprintf(stdout,
          "Reading %s. Writing %s. Wrong Reading Approach with fgets/fputs.\n",
          "pgrmIn.txt", name);
  f2("pgrmIn.txt", name);
  sprintf(name, "%s.v3", "pgrmOut.txt");
  fprintf(
      stdout,
      "Reading %s. Writing %s. Wrong Reading Approach with fscan/fprintf.\n",
      "pgrmIn.txt", name);
  f3("pgrmIn.txt", name);
  sprintf(name, "%s.v4", "pgrmOut.txt");
  fprintf(
      stdout,
      "Reading %s. Writing %s. Correct Reading Approach with fscanf/fgets.\n",
      "pgrmIn.txt", name);
  f4("pgrmIn.txt", name);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x410(%rbp),%rdi
lea    0xe79(%rip),%rsi
lea    0xe78(%rip),%rdx
call   1070 <sprintf@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rcx
lea    0xe68(%rip),%rsi
lea    0xea3(%rip),%rdx
call   1050 <fprintf@plt>
lea    -0x410(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1060 <f1@plt>
lea    -0x410(%rbp),%rdi
lea    0xe88(%rip),%rsi
lea    0xe28(%rip),%rdx
call   1070 <sprintf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rcx
lea    0xe6b(%rip),%rsi
lea    0xe53(%rip),%rdx
call   1050 <fprintf@plt>
lea    -0x410(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1030 <f2@plt>
lea    -0x410(%rbp),%rdi
lea    0xe80(%rip),%rsi
lea    0xdd8(%rip),%rdx
call   1070 <sprintf@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rcx
lea    0xe63(%rip),%rsi
lea    0xe03(%rip),%rdx
call   1050 <fprintf@plt>
lea    -0x410(%rbp),%rsi
lea    0xdf0(%rip),%rdi
call   1040 <f3@plt>
lea    -0x410(%rbp),%rdi
lea    0xe7a(%rip),%rsi
lea    0xd88(%rip),%rdx
call   1070 <sprintf@plt>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rcx
lea    0xe5d(%rip),%rsi
lea    0xdb3(%rip),%rdx
call   1050 <fprintf@plt>
lea    -0x410(%rbp),%rsi
lea    0xda0(%rip),%rdi
call   1080 <f4@plt>
mov    $0x1,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xe8b(%rip),%rsi
lea    0xe8a(%rip),%r15
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15,%rdx
call   1070 <sprintf@plt>
mov    0x2e4f(%rip),%r12
mov    (%r12),%edi
lea    0xe76(%rip),%rsi
lea    0xeb1(%rip),%r14
mov    %r14,%rdx
mov    %rbx,%rcx
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <f1@plt>
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1070 <sprintf@plt>
mov    (%r12),%edi
lea    0xe8f(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <f2@plt>
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1070 <sprintf@plt>
mov    (%r12),%edi
lea    0xea4(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <f3@plt>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1070 <sprintf@plt>
mov    (%r12),%edi
lea    0xebb(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1050 <fprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <f4@plt>
mov    $0x1,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s.v1\00"
@.str.1 = [12 x i8] c"pgrmOut.txt\00"
@stdout = global i32 0
@.str.2 = [66 x i8] c"Reading %s. Writing %s. Wrong Reading Approach with fgetc/fputc.\0A\00"
@.str.3 = [11 x i8] c"pgrmIn.txt\00"
@.str.4 = [6 x i8] c"%s.v2\00"
@.str.5 = [66 x i8] c"Reading %s. Writing %s. Wrong Reading Approach with fgets/fputs.\0A\00"
@.str.6 = [6 x i8] c"%s.v3\00"
@.str.7 = [68 x i8] c"Reading %s. Writing %s. Wrong Reading Approach with fscan/fprintf.\0A\00"
@.str.8 = [6 x i8] c"%s.v4\00"
@.str.9 = [69 x i8] c"Reading %s. Writing %s. Correct Reading Approach with fscanf/fgets.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%8 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @stdout
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = call i32 @f1(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @stdout
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%20 = call i32 @f2(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%22 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @stdout
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%27 = call i32 @f3(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%29 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @stdout
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%32 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%34 = call i32 @f4(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %33)
ret i32 1
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s.v1\00"
@.str.1 = [12 x i8] c"pgrmOut.txt\00"
@stdout = global i32 0
@.str.2 = [66 x i8] c"Reading %s. Writing %s. Wrong Reading Approach with fgetc/fputc.\0A\00"
@.str.3 = [11 x i8] c"pgrmIn.txt\00"
@.str.4 = [6 x i8] c"%s.v2\00"
@.str.5 = [66 x i8] c"Reading %s. Writing %s. Wrong Reading Approach with fgets/fputs.\0A\00"
@.str.6 = [6 x i8] c"%s.v3\00"
@.str.7 = [68 x i8] c"Reading %s. Writing %s. Wrong Reading Approach with fscan/fprintf.\0A\00"
@.str.8 = [6 x i8] c"%s.v4\00"
@.str.9 = [69 x i8] c"Reading %s. Writing %s. Correct Reading Approach with fscanf/fgets.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @stdout
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%8 = call i32 @f1(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%9 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%12 = call i32 @f2(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%13 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @stdout
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%16 = call i32 @f3(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%17 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @stdout
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%20 = call i32 @f4(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret i32 1
}