#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 clock_t;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int clock();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  clock_t c1 = clock();
  FILE *p = fopen("D:\\temp\\b.wmv", "rb");
  FILE *p1 = fopen("D:\\temp\\c.wmv", "wb");
  char buf[1024 * 4];
  while (!feof(p)) {
    memset(buf, 0, sizeof(buf));
    size_t res = fread(buf, sizeof(char), sizeof(buf), p);
    fwrite(buf, sizeof(char), res, p1);
  }
  fclose(p);
  fclose(p1);
  clock_t c2 = clock();
  printf("end , %u\n", c2 - c1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <clock@plt>
mov    %eax,-0x8(%rbp)
lea    0xe5d(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe57(%rip),%rdi
lea    0xe5e(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11e8 <main+0x68>
jmp    123d <main+0xbd>
lea    -0x1020(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1070 <memset@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,-0x1028(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x1028(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   10a0 <fwrite@plt>
jmp    11ca <main+0x4a>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x0,%al
call   1040 <clock@plt>
mov    %eax,-0x102c(%rbp)
mov    -0x102c(%rbp),%esi
sub    -0x8(%rbp),%esi
lea    0xdb6(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1008,%rsp
xor    %eax,%eax
call   1040 <clock@plt>
mov    %eax,%r14d
lea    0xe62(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
lea    0xe5d(%rip),%rdi
lea    0xe64(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1223 <main+0xa3>
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1070 <memset@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
mov    %r15,%rcx
call   10a0 <fwrite@plt>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     11e0 <main+0x60>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r14d,%eax
lea    0xdde(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"D:\\temp\\b.wmv\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [14 x i8] c"D:\\temp\\c.wmv\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [10 x i8] c"end , %u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [4096 x i8]
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (...) @clock()
store i32 %8, i32* %2
%9 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %3
%10 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %10, i32** %4
br label %11
11: ; preds = %16, %0
%12 = load i32*, i32** %3
%13 = call i32 @feof(i32* %12)
%14 = icmp ne i32 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %26
16: ; preds = %11
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i32 0, i32 4096)
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%20 = load i32*, i32** %3
%21 = call i64 @fread(i8* %19, i32 1, i32 4096, i32* %20)
store i64 %21, i64* %6
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%23 = load i64, i64* %6
%24 = load i32*, i32** %4
%25 = call i32 @fwrite(i8* %22, i32 1, i64 %23, i32* %24)
br label %11
26: ; preds = %11
%27 = load i32*, i32** %3
%28 = call i32 @fclose(i32* %27)
%29 = load i32*, i32** %4
%30 = call i32 @fclose(i32* %29)
%31 = call i32 (...) @clock()
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = load i32, i32* %2
%34 = sub nsw i32 %32, %33
%35 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"D:\\temp\\b.wmv\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [14 x i8] c"D:\\temp\\c.wmv\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [10 x i8] c"end , %u\0A\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = tail call i32 (...) @clock()
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%6 = call i32 @feof(i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %0, %8
%9 = call i32 @memset(i8* %5, i32 0, i32 4096)
%10 = call i64 @fread(i8* %5, i32 1, i32 4096, i32* %3)
%11 = call i32 @fwrite(i8* %5, i32 1, i64 %10, i32* %4)
%12 = call i32 @feof(i32* %3)
%13 = icmp eq i32 %12, 0
br i1 %13, label %8, label %14
14: ; preds = %8, %0
%15 = call i32 @fclose(i32* %3)
%16 = call i32 @fclose(i32* %4)
%17 = call i32 (...) @clock()
%18 = sub nsw i32 %17, %2
%19 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %18)
ret i32 0
}