#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 */
float calcularMedia(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  if (argc == 1) {
    printf("Error. No se ha introducido ningun paramentro\n");
    exit(-1);
  }
  float media = 0;
  char nombre[20];
  strcat(argv[1], ".txt\0");
  strcpy(nombre, argv[1]);
  printf("\nEl nombre del fichero es %s \n", nombre);
  media = calcularMedia(nombre);
  printf("\nLa media de los elementos del fichero es → %.3f\n", media);
  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   $0x1,-0x8(%rbp)
jne    1188 <main+0x38>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xee3(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
lea    -0x30(%rbp),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1040 <calcularMedia@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe69(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
cmp    $0x1,%edi
je     11bf <main+0x5f>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe88(%rip),%rsi
call   1070 <strcat@plt>
mov    0x8(%rbx),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe73(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <calcularMedia@plt>
cvtss2sd %xmm0,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"Error. No se ha introducido ningun paramentro\0A\00"
@.str.1 = [6 x i8] c".txt\00\00"
@.str.2 = [31 x i8] c"\0AEl nombre del fichero es %s \0A\00"
@.str.3 = [52 x i8] c"\0ALa media de los elementos del fichero es \E2\86\92 %.3f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca [20 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @exit(i32 -1)
unreachable
13: ; preds = %2
store float 0.000000e+00, float* %6
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @strcpy(i8* %18, i8* %21)
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%26 = call float @calcularMedia(i8* %25)
store float %26, float* %6
%27 = load float, float* %6
%28 = fpext float %27 to double
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), double %28)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c".txt\00\00"
@.str.2 = [31 x i8] c"\0AEl nombre del fichero es %s \0A\00"
@.str.3 = [52 x i8] c"\0ALa media de los elementos del fichero es \E2\86\92 %.3f\0A\00"
@str = [46 x i8] c"Error. No se ha introducido ningun paramentro\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 -1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strcat(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8*, i8** %10
%14 = call i32 @strcpy(i8* %9, i8* %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%16 = call float @calcularMedia(i8* %9)
%17 = fpext float %16 to double
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), double %17)
ret i32 0
}