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

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
scalar_t__ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *open_file(char *, char *);
int /*<<< orphan*/ remove_new_line(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
char *strerror(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  FILE *fp_in, *fp_out;
  char str_from[64], str_to[64], buf_line[128];
  fputs("File sorgente da cui copiare i dati: ", stdout);
  fgets(str_from, 64, stdin);
  remove_new_line(str_from, sizeof(str_from));
  fputs("File destinazione in cui inserire i dati: ", stdout);
  fgets(str_to, 64, stdin);
  remove_new_line(str_to, sizeof(str_to));
  fp_in = open_file(str_from, "r");
  fp_out = open_file(str_to, "w");
  while (fgets(buf_line, 128, fp_in) != NULL) {
    if (fputs(buf_line, fp_out) == EOF) {
      fprintf(stderr, "Err: fputs(), %s: %s\n", strerror(errno), buf_line);
      exit(EXIT_FAILURE);
    }
  }
  fclose(fp_in);
  fclose(fp_out);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%rsi
lea    0xe56(%rip),%rdi
call   1050 <fputs@plt>
lea    -0x60(%rbp),%rdi
mov    0x2e2e(%rip),%rax
mov    (%rax),%rdx
mov    $0x40,%esi
call   1060 <fgets@plt>
lea    -0x60(%rbp),%rdi
mov    $0x40,%esi
call   1080 <remove_new_line@plt>
mov    0x2ddc(%rip),%rax
mov    (%rax),%rsi
lea    0xe40(%rip),%rdi
call   1050 <fputs@plt>
lea    -0xa0(%rbp),%rdi
mov    0x2def(%rip),%rax
mov    (%rax),%rdx
mov    $0x40,%esi
call   1060 <fgets@plt>
lea    -0xa0(%rbp),%rdi
mov    $0x40,%esi
call   1080 <remove_new_line@plt>
lea    -0x60(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1040 <open_file@plt>
mov    %rax,-0x18(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1040 <open_file@plt>
mov    %rax,-0x20(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     12cd <main+0x14d>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <fputs@plt>
mov    0x2d68(%rip),%rcx
cmp    (%rcx),%rax
jne    12c8 <main+0x148>
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x124(%rbp)
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x124(%rbp),%edi
mov    %rax,%rdx
lea    -0x120(%rbp),%rcx
lea    0xda0(%rip),%rsi
call   1070 <fprintf@plt>
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    1242 <main+0xc2>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2cca(%rip),%rax
mov    (%rax),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    0x2e13(%rip),%r15
mov    (%r15),%rcx
lea    0xe51(%rip),%rdi
mov    $0x25,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    0x2e23(%rip),%rbx
mov    (%rbx),%rdx
lea    0xc0(%rsp),%r14
mov    %r14,%rdi
mov    $0x40,%esi
call   1060 <fgets@plt>
mov    %r14,%rdi
mov    $0x40,%esi
call   1080 <remove_new_line@plt>
mov    (%r15),%rcx
lea    0xe32(%rip),%rdi
mov    $0x2a,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    (%rbx),%rdx
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
mov    $0x40,%esi
call   1080 <remove_new_line@plt>
lea    0xe22(%rip),%rsi
mov    %r14,%rdi
call   1040 <open_file@plt>
mov    %rax,%r14
lea    0xe12(%rip),%rsi
mov    %rbx,%rdi
call   1040 <open_file@plt>
mov    %rax,%r15
mov    %rsp,%rbx
mov    0x2d8a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x80,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     12bf <main+0x12f>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <fputs@plt>
cmp    (%r12),%rax
jne    1260 <main+0xd0>
mov    0x2d43(%rip),%rax
mov    (%rax),%ebx
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xdb1(%rip),%rsi
mov    %rsp,%rcx
mov    %ebx,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    0x2cda(%rip),%rax
mov    (%rax),%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [38 x i8] c"File sorgente da cui copiare i dati: \00"
@stdout = global i32* null
@stdin = global i32* null
@.str.1 = [43 x i8] c"File destinazione in cui inserire i dati: \00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i64 0
@stderr = global i32 0
@.str.4 = [22 x i8] c"Err: fputs(), %s: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@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 [64 x i8]
%9 = alloca [64 x i8]
%10 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32*, i32** @stdout
%12 = call i64 @fputs(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%14 = load i32*, i32** @stdin
%15 = call i32* @fgets(i8* %13, i32 64, i32* %14)
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%17 = call i32 @remove_new_line(i8* %16, i32 64)
%18 = load i32*, i32** @stdout
%19 = call i64 @fputs(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32* %18)
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%21 = load i32*, i32** @stdin
%22 = call i32* @fgets(i8* %20, i32 64, i32* %21)
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%24 = call i32 @remove_new_line(i8* %23, i32 64)
%25 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%26 = call i32* @open_file(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %26, i32** %6
%27 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%28 = call i32* @open_file(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %28, i32** %7
br label %29
29: ; preds = %48, %2
%30 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%31 = load i32*, i32** %6
%32 = call i32* @fgets(i8* %30, i32 128, i32* %31)
%33 = icmp ne i32* %32, null
br i1 %33, label %34, label %49
34: ; preds = %29
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%36 = load i32*, i32** %7
%37 = call i64 @fputs(i8* %35, i32* %36)
%38 = load i64, i64* @EOF
%39 = icmp eq i64 %37, %38
br i1 %39, label %40, label %48
40: ; preds = %34
%41 = load i32, i32* @stderr
%42 = load i32, i32* @errno
%43 = call i8* @strerror(i32 %42)
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%45 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %43, i8* %44)
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %34
br label %29
49: ; preds = %29
%50 = load i32*, i32** %6
%51 = call i32 @fclose(i32* %50)
%52 = load i32*, i32** %7
%53 = call i32 @fclose(i32* %52)
%54 = load i32, i32* @EXIT_SUCCESS
ret i32 %54
}

LLVM IR (-O2):
@.str = [38 x i8] c"File sorgente da cui copiare i dati: \00"
@stdout = global i32* null
@stdin = global i32* null
@.str.1 = [43 x i8] c"File destinazione in cui inserire i dati: \00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [2 x i8] c"w\00"
@EOF = global i64 0
@stderr = global i32 0
@.str.4 = [22 x i8] c"Err: fputs(), %s: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [64 x i8]
%4 = alloca [64 x i8]
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%9 = load i32*, i32** @stdout
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i64 37, i64 1, i32* %9)
%11 = load i32*, i32** @stdin
%12 = call i32* @fgets(i8* %6, i32 64, i32* %11)
%13 = call i32 @remove_new_line(i8* %6, i32 64)
%14 = load i32*, i32** @stdout
%15 = call i64 @fwrite(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i64 42, i64 1, i32* %14)
%16 = load i32*, i32** @stdin
%17 = call i32* @fgets(i8* %7, i32 64, i32* %16)
%18 = call i32 @remove_new_line(i8* %7, i32 64)
%19 = call i32* @open_file(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32* @open_file(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %24, %2
%22 = call i32* @fgets(i8* %8, i32 128, i32* %19)
%23 = icmp eq i32* %22, null
br i1 %23, label %35, label %24
24: ; preds = %21
%25 = call i64 @fputs(i8* %8, i32* %20)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %21
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = load i32, i32* @errno
%31 = call i8* @strerror(i32 %30)
%32 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %31, i8* %8)
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %21
%36 = call i32 @fclose(i32* %19)
%37 = call i32 @fclose(i32* %20)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}