#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 drand48();
void *malloc(int);
int /*<<< orphan*/ perror(char *);
float **create_random_float_points(int number_of_points) {
  float **points = malloc(sizeof *points * number_of_points);
  if (points == NULL) {
    perror("malloc");
    return NULL;
  }
  for (int i = 0; i < number_of_points; i++) {
    points[i] = malloc(sizeof(float) * 2);
    points[i][0] = drand48();
    points[i][1] = drand48();
  }
  return points;
}


x86 assembly (clang, -O0):
<create_random_float_points>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1172 <create_random_float_points+0x42>
lea    0xea0(%rip),%rdi
call   1040 <perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    11e3 <create_random_float_points+0xb3>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11db <create_random_float_points+0xab>
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    $0x0,%al
call   1050 <drand48@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movss  %xmm0,(%rax)
mov    $0x0,%al
call   1050 <drand48@plt>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movss  %xmm0,0x4(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1179 <create_random_float_points+0x49>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_random_float_points>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
lea    0x0(,%r14,8),%edi
call   1030 <malloc@plt>
test   %rax,%rax
je     11a4 <create_random_float_points+0x74>
mov    %rax,%r15
test   %r14d,%r14d
jle    1195 <create_random_float_points+0x65>
mov    %r14d,%r14d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%r12
mov    %rax,(%r15,%rbx,8)
xor    %eax,%eax
call   1050 <drand48@plt>
movss  %xmm0,(%r12)
xor    %eax,%eax
call   1050 <drand48@plt>
movss  %xmm0,0x4(%r12)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1160 <create_random_float_points+0x30>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe55(%rip),%rdi
call   1040 <perror@plt>
xor    %r15d,%r15d
jmp    1195 <create_random_float_points+0x65>

LLVM IR (-O0):
@.str = [7 x i8] c"malloc\00"
define float** @create_random_float_points(i32 %0) {
%2 = alloca float**
%3 = alloca i32
%4 = alloca float**
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = mul i64 8, %7
%9 = trunc i64 %8 to i32
%10 = call i8* @malloc(i32 %9)
%11 = bitcast i8* %10 to float**
store float** %11, float*** %4
%12 = load float**, float*** %4
%13 = icmp eq float** %12, null
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store float** null, float*** %2
br label %47
16: ; preds = %1
store i32 0, i32* %5
br label %17
17: ; preds = %42, %16
%18 = load i32, i32* %5
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %45
21: ; preds = %17
%22 = call i8* @malloc(i32 8)
%23 = bitcast i8* %22 to float*
%24 = load float**, float*** %4
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float*, float** %24, i64 %26
store float* %23, float** %27
%28 = call float (...) @drand48()
%29 = load float**, float*** %4
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds float*, float** %29, i64 %31
%33 = load float*, float** %32
%34 = getelementptr inbounds float, float* %33, i64 0
store float %28, float* %34
%35 = call float (...) @drand48()
%36 = load float**, float*** %4
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds float*, float** %36, i64 %38
%40 = load float*, float** %39
%41 = getelementptr inbounds float, float* %40, i64 1
store float %35, float* %41
br label %42
42: ; preds = %21
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %17
45: ; preds = %17
%46 = load float**, float*** %4
store float** %46, float*** %2
br label %47
47: ; preds = %45, %14
%48 = load float**, float*** %2
ret float** %48
}

LLVM IR (-O2):
@.str = [7 x i8] c"malloc\00"
define noalias float** @create_random_float_points(i32 %0) {
%2 = shl i32 %0, 3
%3 = tail call i8* @malloc(i32 %2)
%4 = bitcast i8* %3 to float**
%5 = icmp eq i8* %3, null
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %23
8: ; preds = %6
%9 = zext i32 %0 to i64
br label %12
10: ; preds = %1
%11 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %23
12: ; preds = %8, %12
%13 = phi i64 [ 0, %8 ], [ %21, %12 ]
%14 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%15 = getelementptr inbounds float*, float** %4, i64 %13
%16 = bitcast float** %15 to i8**
store i8* %14, i8** %16
%17 = tail call float (...) @drand48()
%18 = bitcast i8* %14 to float*
store float %17, float* %18
%19 = tail call float (...) @drand48()
%20 = getelementptr inbounds float, float* %18, i64 1
store float %19, float* %20
%21 = add nuw nsw i64 %13, 1
%22 = icmp eq i64 %21, %9
br i1 %22, label %23, label %12
23: ; preds = %12, %6, %10
%24 = phi float** [ null, %10 ], [ %4, %6 ], [ %4, %12 ]
ret float** %24
}