#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/ *);
int main() {
  int c = 0;
  FILE *pfin = NULL;
  FILE *pfout = NULL;
  pfin = fopen("1m_data.file", "r");
  pfout = fopen("1m_data.file.copy", "w");
  while (fread(&c, sizeof(char), 1, pfin)) {
    fwrite(&c, sizeof(char), 1, pfout);
  }
  fclose(pfin);
  fclose(pfout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe93(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe8b(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
lea    -0x8(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x0,%rax
je     11cb <main+0x8b>
mov    -0x18(%rbp),%rcx
lea    -0x8(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <fwrite@plt>
jmp    1194 <main+0x54>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xea8(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
lea    0xea1(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %rax,%rax
je     11c7 <main+0x87>
lea    0xc(%rsp),%r15
xchg   %ax,%ax
movsbl 0xc(%rsp),%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %rax,%rax
jne    11a0 <main+0x60>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"1m_data.file\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"1m_data.file.copy\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %2
store i32* null, i32** %3
store i32* null, i32** %4
%5 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
%6 = call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %6, i32** %4
br label %7
7: ; preds = %11, %0
%8 = load i32*, i32** %3
%9 = call i64 @fread(i32* %2, i32 1, i32 1, i32* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32*, i32** %4
%13 = call i32 @fwrite(i32* %2, i32 1, i32 1, i32* %12)
br label %7
14: ; preds = %7
%15 = load i32*, i32** %3
%16 = call i32 @fclose(i32* %15)
%17 = load i32*, i32** %4
%18 = call i32 @fclose(i32* %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"1m_data.file\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"1m_data.file.copy\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%5 = call i64 @fread(i32* %1, i32 1, i32 1, i32* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0, %7
%8 = load i8, i8* %2
%9 = sext i8 %8 to i32
%10 = tail call i32 @fputc(i32 %9, i32* %4)
%11 = call i64 @fread(i32* %1, i32 1, i32 1, i32* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %7
13: ; preds = %7, %0
%14 = tail call i32 @fclose(i32* %3)
%15 = tail call i32 @fclose(i32* %4)
ret i32 0
}