#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 EOF;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  FILE *f_in, *f_out;
  char *ent = argv[1], *sor = argv[2];
  int c;
  if (NULL == (f_in = fopen(ent, "r"))) {
    printf("I");
    return (EXIT_FAILURE);
  }
  if (NULL != (f_out = fopen(sor, "r"))) {
    printf("fichier %s existant, copie impossible", sor);
    return (EXIT_FAILURE);
  }
  if (NULL == (f_out = fopen(sor, "w"))) {
    printf("I");
    return (EXIT_FAILURE);
  }
  printf("double du fichier %s : ", ent);
  fprintf(f_out, "double du fichier %s : ", ent);
  while ((c = fgetc(f_in)) != EOF) {
    fputc(c, f_out);
    printf("%c", c);
  }
  fclose(f_in);
  fclose(f_out);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11cf <main+0x6f>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d6 <main+0x176>
mov    -0x30(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
je     1214 <main+0xb4>
mov    -0x30(%rbp),%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d6 <main+0x176>
mov    -0x30(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    1255 <main+0xf5>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12d6 <main+0x176>
mov    -0x28(%rbp),%rsi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xdb6(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x34(%rbp)
mov    0x2d5a(%rip),%rcx
cmp    (%rcx),%eax
je     12b8 <main+0x158>
mov    -0x34(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1060 <fputc@plt>
mov    -0x34(%rbp),%esi
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    127b <main+0x11b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2cff(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%r15
mov    0x10(%rsi),%r14
lea    0xe7a(%rip),%rsi
mov    %r15,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1259 <main+0xe9>
mov    %rax,%rbx
lea    0xe5f(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     11c4 <main+0x54>
lea    0xe4d(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1263 <main+0xf3>
lea    0xe5d(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     1259 <main+0xe9>
mov    %rax,%r14
lea    0xe44(%rip),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    0x2dd8(%rip),%r15
cmp    (%r15),%eax
je     1240 <main+0xd0>
mov    %eax,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
call   1070 <fputc@plt>
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
call   1060 <fgetc@plt>
mov    %eax,%ebp
cmp    (%r15),%eax
jne    1220 <main+0xb0>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    0x2d79(%rip),%rax
jmp    126a <main+0xfa>
mov    $0x49,%edi
call   1030 <putchar@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"I\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [38 x i8] c"fichier %s existant, copie impossible\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [24 x i8] c"double du fichier %s : \00"
@EOF = global i32 0
@.str.5 = [3 x i8] c"%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
store i8* %13, i8** %8
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
store i8* %16, i8** %9
%17 = load i8*, i8** %8
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %18, i32** %6
%19 = icmp eq i32* null, %18
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %3
br label %61
23: ; preds = %2
%24 = load i8*, i8** %9
%25 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %7
%26 = icmp ne i32* null, %25
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i8*, i8** %9
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %61
31: ; preds = %23
%32 = load i8*, i8** %9
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %33, i32** %7
%34 = icmp eq i32* null, %33
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
store i32 %37, i32* %3
br label %61
38: ; preds = %31
%39 = load i8*, i8** %8
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %39)
%41 = load i32*, i32** %7
%42 = load i8*, i8** %8
%43 = call i32 @fprintf(i32* %41, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %49, %38
%45 = load i32*, i32** %6
%46 = call i32 @fgetc(i32* %45)
store i32 %46, i32* %10
%47 = load i32, i32* @EOF
%48 = icmp ne i32 %46, %47
br i1 %48, label %49, label %55
49: ; preds = %44
%50 = load i32, i32* %10
%51 = load i32*, i32** %7
%52 = call i32 @fputc(i32 %50, i32* %51)
%53 = load i32, i32* %10
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %53)
br label %44
55: ; preds = %44
%56 = load i32*, i32** %6
%57 = call i32 @fclose(i32* %56)
%58 = load i32*, i32** %7
%59 = call i32 @fclose(i32* %58)
%60 = load i32, i32* @EXIT_SUCCESS
store i32 %60, i32* %3
br label %61
61: ; preds = %55, %35, %27, %20
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [38 x i8] c"fichier %s existant, copie impossible\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [24 x i8] c"double du fichier %s : \00"
@EOF = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @putchar(i32 73)
br label %37
11: ; preds = %2
%12 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %37
16: ; preds = %11
%17 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @putchar(i32 73)
br label %37
21: ; preds = %16
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%23 = tail call i32 @fprintf(i32* %17, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%24 = tail call i32 @fgetc(i32* %7)
%25 = load i32, i32* @EOF
%26 = icmp eq i32 %24, %25
br i1 %26, label %34, label %27
27: ; preds = %21, %27
%28 = phi i32 [ %31, %27 ], [ %24, %21 ]
%29 = tail call i32 @fputc(i32 %28, i32* %17)
%30 = tail call i32 @putchar(i32 %28)
%31 = tail call i32 @fgetc(i32* %7)
%32 = load i32, i32* @EOF
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %27
34: ; preds = %27, %21
%35 = tail call i32 @fclose(i32* %7)
%36 = tail call i32 @fclose(i32* %17)
br label %37
37: ; preds = %34, %19, %14, %9
%38 = phi i32* [ @EXIT_FAILURE, %9 ], [ @EXIT_FAILURE, %14 ], [ @EXIT_FAILURE, %19 ], [ @EXIT_SUCCESS, %34 ]
%39 = load i32, i32* %38
ret i32 %39
}