#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*/ feof(int /*<<< orphan*/ *);
long fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, long);
long strlen(char *);
void writeFile(FILE *source, FILE *destination, char *key) {
  long taille, h;
  int i, c;
  i = 0;
  taille = strlen(key);
  printf("key size [%ld]bits", taille);
  h = fgetc(source);
  while (!feof(source)) {
    c = h ^ key[i];
    fputc(c, destination);
    i++;
    if (i == taille) {
      i = 0;
    }
    h = fgetc(source);
  }
}


x86 assembly (clang, -O0):
<writeFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b3 <writeFile+0x63>
jmp    1206 <writeFile+0xb6>
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
movsbq (%rcx,%rdx,1),%rcx
xor    %rcx,%rax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <fputc@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x20(%rbp),%rax
jne    11f4 <writeFile+0xa4>
movl   $0x0,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %rax,-0x28(%rbp)
jmp    1195 <writeFile+0x45>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeFile>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r13
mov    %rdx,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
lea    0xe8a(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %r13,%rdi
call   1050 <fgetc@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11dc <writeFile+0x8c>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movslq %ebp,%rbp
movsbl (%r15,%rbp,1),%eax
xor    %eax,%ebx
mov    %ebx,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
add    $0x1,%ebp
movslq %ebp,%rbp
cmp    %rbp,%r12
mov    $0x0,%eax
cmove  %eax,%ebp
mov    %r13,%rdi
call   1050 <fgetc@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11a0 <writeFile+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"key size [%ld]bits\00"
define void @writeFile(i32* %0, i32* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
store i32 0, i32* %9
%11 = load i8*, i8** %6
%12 = call i64 @strlen(i8* %11)
store i64 %12, i64* %7
%13 = load i64, i64* %7
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %13)
%15 = load i32*, i32** %4
%16 = call i64 @fgetc(i32* %15)
store i64 %16, i64* %8
br label %17
17: ; preds = %42, %3
%18 = load i32*, i32** %4
%19 = call i32 @feof(i32* %18)
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
br i1 %21, label %22, label %45
22: ; preds = %17
%23 = load i64, i64* %8
%24 = load i8*, i8** %6
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i64
%30 = xor i64 %23, %29
%31 = trunc i64 %30 to i32
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = load i32*, i32** %5
%34 = call i32 @fputc(i32 %32, i32* %33)
%35 = load i32, i32* %9
%36 = add nsw i32 %35, 1
store i32 %36, i32* %9
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = load i64, i64* %7
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %42
41: ; preds = %22
store i32 0, i32* %9
br label %42
42: ; preds = %41, %22
%43 = load i32*, i32** %4
%44 = call i64 @fgetc(i32* %43)
store i64 %44, i64* %8
br label %17
45: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"key size [%ld]bits\00"
define void @writeFile(i32* nocapture %0, i32* nocapture %1, i8* nocapture %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %4)
%6 = tail call i64 @fgetc(i32* %0)
%7 = tail call i32 @feof(i32* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %26
9: ; preds = %3, %9
%10 = phi i64 [ %23, %9 ], [ %6, %3 ]
%11 = phi i32 [ %22, %9 ], [ 0, %3 ]
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %2, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i64
%16 = xor i64 %10, %15
%17 = trunc i64 %16 to i32
%18 = tail call i32 @fputc(i32 %17, i32* %1)
%19 = add nsw i32 %11, 1
%20 = sext i32 %19 to i64
%21 = icmp eq i64 %4, %20
%22 = select i1 %21, i32 0, i32 %19
%23 = tail call i64 @fgetc(i32* %0)
%24 = tail call i32 @feof(i32* %0)
%25 = icmp eq i32 %24, 0
br i1 %25, label %9, label %26
26: ; preds = %9, %3
ret void
}