#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 /*<<< orphan*/ exit(int);
double *malloc(int);
int /*<<< orphan*/ printf(char *);
double *initArray(int n_puntos) {
  double *array;
  int i;
  if (!(array = malloc(n_puntos * sizeof(double)))) {
    printf("Problema en initArray\n");
    exit(1);
  }
  for (i = 0; i < n_puntos; i++) {
    array[i] = 0.0;
  }
  return array;
}


x86 assembly (clang, -O0):
<initArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    116e <initArray+0x3e>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    119f <initArray+0x6f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1175 <initArray+0x45>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initArray>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x0(,%rbx,8),%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1179 <initArray+0x39>
mov    %rax,%r14
test   %ebx,%ebx
jle    116e <initArray+0x2e>
mov    %ebx,%edx
shl    $0x3,%rdx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"Problema en initArray\0A\00"
define double* @initArray(i32 %0) {
%2 = alloca i32
%3 = alloca double*
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = mul i64 %6, 8
%8 = trunc i64 %7 to i32
%9 = call double* @malloc(i32 %8)
store double* %9, double** %3
%10 = icmp ne double* %9, null
br i1 %10, label %14, label %11
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %1
store i32 0, i32* %4
br label %15
15: ; preds = %24, %14
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load double*, double** %3
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
store double 0.000000e+00, double* %23
br label %24
24: ; preds = %19
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %15
27: ; preds = %15
%28 = load double*, double** %3
ret double* %28
}

LLVM IR (-O2):
@str = [22 x i8] c"Problema en initArray\00"
define noalias double* @initArray(i32 %0) {
%2 = shl i32 %0, 3
%3 = tail call double* @malloc(i32 %2)
%4 = bitcast double* %3 to i8*
%5 = icmp eq double* %3, null
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %14
8: ; preds = %6
%9 = zext i32 %0 to i64
%10 = shl nuw nsw i64 %9, 3
br label %14
11: ; preds = %1
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8, %6
ret double* %3
}