#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 */
scalar_t__ malloc(int);
scalar_t__ rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
float *rand_float_arr(int size) {
  float *res = (float *)malloc(size * sizeof(float));
  srand((unsigned)time(NULL));
  for (int i = 0; i < size; ++i) {
    res[i] = (float)rand();
  }
  return res;
}


x86 assembly (clang, -O0):
<rand_float_arr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a8 <rand_float_arr+0x68>
mov    $0x0,%al
call   1060 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1175 <rand_float_arr+0x35>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_float_arr>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%r14d
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,%edi
call   1030 <srand@plt>
test   %r14d,%r14d
jle    118e <rand_float_arr+0x4e>
mov    %r14d,%r14d
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1170 <rand_float_arr+0x30>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float* @rand_float_arr(i32 %0) {
%2 = alloca i32
%3 = alloca float*
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = mul i64 %6, 4
%8 = trunc i64 %7 to i32
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to float*
store float* %10, float** %3
%11 = call i64 @time(i32* null)
%12 = trunc i64 %11 to i32
%13 = call i32 @srand(i32 %12)
store i32 0, i32* %4
br label %14
14: ; preds = %25, %1
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = call i64 (...) @rand()
%20 = sitofp i64 %19 to float
%21 = load float*, float** %3
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds float, float* %21, i64 %23
store float %20, float* %24
br label %25
25: ; preds = %18
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %14
28: ; preds = %14
%29 = load float*, float** %3
ret float* %29
}

LLVM IR (-O2):
define float* @rand_float_arr(i32 %0) {
%2 = shl i32 %0, 2
%3 = tail call i64 @malloc(i32 %2)
%4 = inttoptr i64 %3 to float*
%5 = tail call i64 @time(i32* null)
%6 = trunc i64 %5 to i32
%7 = tail call i32 @srand(i32 %6)
%8 = icmp sgt i32 %0, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = zext i32 %0 to i64
br label %12
11: ; preds = %12, %1
ret float* %4
12: ; preds = %9, %12
%13 = phi i64 [ 0, %9 ], [ %17, %12 ]
%14 = tail call i64 (...) @rand()
%15 = sitofp i64 %14 to float
%16 = getelementptr inbounds float, float* %4, i64 %13
store float %15, float* %16
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, %10
br i1 %18, label %11, label %12
}