#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 */
scalar_t__ EOF;
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned char);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, unsigned char *);
int main() {
  unsigned char bytes;
  FILE *pFile, *newFile;
  pFile = fopen("fotoIn.jpg", "rb");
  newFile = fopen("fotoOut.jpg", "w");
  while (fscanf(pFile, "%c", &bytes) != EOF)
    fprintf(newFile, "%c", bytes);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xebe(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xeb1(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea4(%rip),%rsi
lea    -0x5(%rbp),%rdx
call   1030 <fscanf@plt>
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%rax
je     11aa <main+0x7a>
mov    -0x18(%rbp),%rdi
lea    0xe80(%rip),%rsi
movzbl -0x5(%rbp),%edx
call   1040 <fprintf@plt>
jmp    116d <main+0x3d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
lea    0xec0(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
lea    0xeb4(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xeac(%rip),%rsi
lea    0xf(%rsp),%rdx
mov    %r14,%rdi
call   1030 <fscanf@plt>
mov    0x2e64(%rip),%r13
cmp    0x0(%r13),%rax
je     11c1 <main+0x91>
lea    0xe8b(%rip),%r15
lea    0xf(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
movsbl 0xf(%rsp),%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <fscanf@plt>
cmp    0x0(%r13),%rax
jne    11a0 <main+0x70>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"fotoIn.jpg\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [12 x i8] c"fotoOut.jpg\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%c\00"
@EOF = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32*
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 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** %3
%6 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 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 = %12, %0
%8 = load i32*, i32** %3
%9 = call i64 @fscanf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32*, i32** %4
%14 = load i8, i8* %2
%15 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %14)
br label %7
16: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"fotoIn.jpg\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [12 x i8] c"fotoOut.jpg\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%c\00"
@EOF = global i64 0
define i32 @main() {
%1 = alloca i8
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 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 ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%4 = call i64 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %14, label %7
7: ; preds = %0, %7
%8 = load i8, i8* %1
%9 = sext i8 %8 to i32
%10 = call i32 @fputc(i32 %9, i32* %3)
%11 = call i64 @fscanf(i32* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %7
14: ; preds = %7, %0
ret i32 0
}