#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*/ LineasCodigo(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  FILE *Entrada;
  FILE *respaldo;
  char nomArchivo[20];
  char buf[100];
  printf("Proporcione el nombre del archivo con su extension\nEj. prueba.c \n");
  printf("Nombre del archivo>");
  scanf("%s", nomArchivo);
  if (!(Entrada = fopen(nomArchivo, "rb"))) {
    printf("ERROR: No se puede abrir el archivo %s\n", nomArchivo);
    return 0;
  }
  Entrada = fopen(nomArchivo, "r");
  respaldo = fopen("respaldo.c", "w");
  LineasCodigo(Entrada, respaldo);
  fclose(Entrada);
  fclose(respaldo);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rsi
lea    0xecd(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x30(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11ca <main+0x7a>
lea    -0x30(%rbp),%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    121b <main+0xcb>
lea    -0x30(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xea1(%rip),%rdi
lea    0xea5(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <LineasCodigo@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe86(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe7d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     11ec <main+0x8c>
lea    0xe94(%rip),%rsi
mov    %rsp,%rdi
call   1080 <fopen@plt>
mov    %rax,%r14
lea    0xe84(%rip),%rdi
lea    0xe88(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <LineasCodigo@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    11fd <main+0x9d>
lea    0xe27(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [66 x i8] c"Proporcione el nombre del archivo con su extension\0AEj. prueba.c \0A\00"
@.str.1 = [20 x i8] c"Nombre del archivo>\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [40 x i8] c"ERROR: No se puede abrir el archivo %s\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [11 x i8] c"respaldo.c\00"
@.str.7 = [2 x i8] c"w\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [20 x i8]
%5 = alloca [100 x i8]
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %11, i32** %2
%12 = icmp ne i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %14)
store i32 0, i32* %1
br label %27
16: ; preds = %0
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %18, i32** %2
%19 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %19, i32** %3
%20 = load i32*, i32** %2
%21 = load i32*, i32** %3
%22 = call i32 @LineasCodigo(i32* %20, i32* %21)
%23 = load i32*, i32** %2
%24 = call i32 @fclose(i32* %23)
%25 = load i32*, i32** %3
%26 = call i32 @fclose(i32* %25)
store i32 0, i32* %1
br label %27
27: ; preds = %16, %13
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"Nombre del archivo>\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [40 x i8] c"ERROR: No se puede abrir el archivo %s\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [11 x i8] c"respaldo.c\00"
@.str.7 = [2 x i8] c"w\00"
@str = [65 x i8] c"Proporcione el nombre del archivo con su extension\0AEj. prueba.c \00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %2)
br label %16
10: ; preds = %0
%11 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @LineasCodigo(i32* %11, i32* %12)
%14 = call i32 @fclose(i32* %11)
%15 = call i32 @fclose(i32* %12)
br label %16
16: ; preds = %10, %8
ret i32 0
}