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

/* Variables and functions */
int /*<<< orphan*/ code(char *, size_t);
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 main03() {
  FILE *p = fopen("D:\\temp\\a.wmv", "rb");
  FILE *p1 = fopen("D:\\temp\\b.wmv", "wb");
  char buf[1024 * 4];
  while (!feof(p)) {
    memset(buf, 0, sizeof(buf));
    size_t res = fread(buf, sizeof(char), sizeof(buf), p);
    code(buf, res);
    fwrite(buf, sizeof(char), res, p1);
  }
  fclose(p);
  fclose(p1);
  printf("end\n");
  return 0;
}


x86 assembly (clang, -O0):
<main03>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
lea    0xe6e(%rip),%rdi
lea    0xe75(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x8(%rbp)
lea    0xe68(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d7 <main03+0x57>
jmp    123f <main03+0xbf>
lea    -0x1010(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,-0x1018(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x1018(%rbp),%rsi
call   10a0 <code@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x1018(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1090 <fwrite@plt>
jmp    11b9 <main03+0x39>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xdca(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main03>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1008,%rsp
lea    0xe6b(%rip),%rdi
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0xe66(%rip),%rdi
lea    0xe6d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    1221 <main03+0xa1>
mov    %rsp,%r12
nopl   0x0(%rax)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rax,%rsi
call   10a0 <code@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1090 <fwrite@plt>
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11d0 <main03+0x50>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
lea    0xdea(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x1008,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"D:\\temp\\a.wmv\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [14 x i8] c"D:\\temp\\b.wmv\00"
@.str.3 = [3 x i8] c"wb\00"
@str = [4 x i8] c"end\00"
define i32 @main03() {
%1 = alloca [4096 x i8]
%2 = 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))
%3 = 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))
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%5 = call i32 @feof(i32* %2)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0, %7
%8 = call i32 @memset(i8* %4, i32 0, i32 4096)
%9 = call i64 @fread(i8* %4, i32 1, i32 4096, i32* %2)
%10 = call i32 @code(i8* %4, i64 %9)
%11 = call i32 @fwrite(i8* %4, i32 1, i64 %9, i32* %3)
%12 = call i32 @feof(i32* %2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %7, label %14
14: ; preds = %7, %0
%15 = call i32 @fclose(i32* %2)
%16 = call i32 @fclose(i32* %3)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
ret i32 0
}