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


x86 assembly (clang, -O0):
<reserva>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x3,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1172 <reserva+0x42>
lea    0xe9d(%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    11a3 <reserva+0x73>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1179 <reserva+0x49>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reserva>:
push   %rax
mov    $0xc,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     1150 <reserva+0x20>
movl   $0x0,0x8(%rax)
movq   $0x0,(%rax)
pop    %rcx
ret
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

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

LLVM IR (-O2):
@str = [20 x i8] c"Problema en reserva\00"
define noalias float* @reserva() {
%1 = tail call float* @malloc(i32 12)
%2 = icmp eq float* %1, null
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = bitcast float* %1 to i8*
ret float* %1
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
}