#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  FILE *sorgente;
  FILE *destinazione;
  char ch;
  if (argc != 3) {
    fprintf(stderr, "Errore \n");
    return -1;
  }
  if ((sorgente = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "Errore sorgente \n");
    return -2;
  }
  if ((destinazione = fopen(argv[2], "w+")) == NULL) {
    fprintf(stderr, "Errore destinazione \n");
    return -3;
  }
  while ((ch = fgetc(sorgente)) != EOF) {
    fputc(ch, destinazione);
  }
  fprintf(stdout, "%s", "File scritto con successo \n");
  fclose(sorgente);
  fclose(destinazione);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1193 <main+0x43>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    128e <main+0x13e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe67(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d8 <main+0x88>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    128e <main+0x13e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe36(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    121d <main+0xcd>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    128e <main+0x13e>
jmp    1222 <main+0xd2>
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2db0(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1257 <main+0x107>
mov    -0x21(%rbp),%al
mov    -0x20(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    1222 <main+0xd2>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
lea    0xdcb(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x3,%edi
jne    11fa <main+0xaa>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0xe9e(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1218 <main+0xc8>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     1236 <main+0xe6>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <fgetc@plt>
mov    0x2e41(%rip),%rbp
cmp    0x0(%rbp),%al
je     11c8 <main+0x78>
nopl   0x0(%rax)
movsbl %al,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    %rbx,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%rbp),%al
jne    11b0 <main+0x60>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe5e(%rip),%rsi
lea    0xe5a(%rip),%rdx
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
jmp    1252 <main+0x102>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xdf6(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    1252 <main+0x102>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xde3(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xfffffffe,%ebp
jmp    1252 <main+0x102>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xfffffffd,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [9 x i8] c"Errore \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"Errore sorgente \0A\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [22 x i8] c"Errore destinazione \0A\00"
@EOF = global i8 0
@stdout = global i32 0
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [28 x i8] c"File scritto con successo \0A\00"
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %51
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 -2, i32* %3
br label %51
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %27, i32** %7
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %32
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
store i32 -3, i32* %3
br label %51
32: ; preds = %23
br label %33
33: ; preds = %40, %32
%34 = load i32*, i32** %6
%35 = call signext i8 @fgetc(i32* %34)
store i8 %35, i8* %8
%36 = sext i8 %35 to i32
%37 = load i8, i8* @EOF
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %36, %38
br i1 %39, label %40, label %44
40: ; preds = %33
%41 = load i8, i8* %8
%42 = load i32*, i32** %7
%43 = call i32 @fputc(i8 signext %41, i32* %42)
br label %33
44: ; preds = %33
%45 = load i32, i32* @stdout
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%47 = load i32*, i32** %6
%48 = call i32 @fclose(i32* %47)
%49 = load i32*, i32** %7
%50 = call i32 @fclose(i32* %49)
store i32 0, i32* %3
br label %51
51: ; preds = %44, %29, %20, %11
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [9 x i8] c"Errore \0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [18 x i8] c"Errore sorgente \0A\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [22 x i8] c"Errore destinazione \0A\00"
@EOF = global i8 0
@stdout = global i32 0
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [28 x i8] c"File scritto con successo \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %38
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
br label %38
15: ; preds = %7
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = tail call signext i8 @fgetc(i32* %10)
%22 = load i8, i8* @EOF
%23 = icmp eq i8 %21, %22
br i1 %23, label %33, label %27
24: ; preds = %15
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %38
27: ; preds = %20, %27
%28 = phi i8 [ %30, %27 ], [ %21, %20 ]
%29 = tail call i32 @fputc(i8 signext %28, i32* %18)
%30 = tail call signext i8 @fgetc(i32* %10)
%31 = load i8, i8* @EOF
%32 = icmp eq i8 %30, %31
br i1 %32, label %33, label %27
33: ; preds = %27, %20
%34 = load i32, i32* @stdout
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%36 = tail call i32 @fclose(i32* %10)
%37 = tail call i32 @fclose(i32* %18)
br label %38
38: ; preds = %33, %24, %12, %4
%39 = phi i32 [ -1, %4 ], [ -2, %12 ], [ -3, %24 ], [ 0, %33 ]
ret i32 %39
}