#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 */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ leerFichero(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rellenaFichero(char *, int *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  if (argc == 1) {
    printf("\nNo se han pasado argumentos\n");
    exit(-1);
  }
  char nombreFichero[20];
  strcpy(nombreFichero, argv[1]);
  strcat(nombreFichero, ".bin\0");
  int limite[1], nEle = 0, *vector;
  nEle = atoi(argv[2]);
  limite[0] = atoi(argv[3]);
  limite[1] = atoi(argv[4]);
  rellenaFichero(nombreFichero, limite, nEle);
  leerFichero(nombreFichero, nEle);
  return 0;
}


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)
cmpl   $0x1,-0x8(%rbp)
jne    11a6 <main+0x36>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x30(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1070 <strcat@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x34(%rbp),%rsi
mov    -0x38(%rbp),%edx
call   1080 <rellenaFichero@plt>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%esi
call   1050 <leerFichero@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
cmp    $0x1,%edi
je     11dc <main+0x6c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xe68(%rip),%rsi
mov    %r14,%rdi
call   1070 <strcat@plt>
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x20(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,0x10(%rsp)
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1080 <rellenaFichero@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1050 <leerFichero@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"\0ANo se han pasado argumentos\0A\00"
@.str.1 = [6 x i8] c".bin\00\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [20 x i8]
%7 = alloca [1 x i32]
%8 = alloca i32
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @strcpy(i8* %16, i8* %19)
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%22 = call i32 @strcat(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %8
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %8
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
%31 = getelementptr inbounds [1 x i32], [1 x i32]* %7, i64 0, i64 0
store i32 %30, i32* %31
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 4
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
%36 = getelementptr inbounds [1 x i32], [1 x i32]* %7, i64 0, i64 1
store i32 %35, i32* %36
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%38 = getelementptr inbounds [1 x i32], [1 x i32]* %7, i64 0, i64 0
%39 = load i32, i32* %8
%40 = call i32 @rellenaFichero(i8* %37, i32* %38, i32 %39)
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%42 = load i32, i32* %8
%43 = call i32 @leerFichero(i8* %41, i32 %42)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c".bin\00\00"
@str = [29 x i8] c"\0ANo se han pasado argumentos\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = alloca [1 x i32]
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @strcpy(i8* %10, i8* %12)
%14 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = bitcast [1 x i32]* %4 to i8*
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
%19 = getelementptr inbounds [1 x i32], [1 x i32]* %4, i64 0, i64 0
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
%23 = getelementptr inbounds [1 x i32], [1 x i32]* %4, i64 0, i64 1
store i32 %22, i32* %23
%24 = call i32 @rellenaFichero(i8* %10, i32* %19, i32 %18)
%25 = call i32 @leerFichero(i8* %10, i32 %18)
ret i32 0
}