#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 *malloc(int);
int /*<<< orphan*/ ordinaryf(float);
float rand_float();
float *get_random_floats(int nums) {
  int i;
  float *arr = malloc(sizeof(float) * nums * 1);
  for (i = 0; i < nums * 1; i++) {
    float rand;
    do {
      rand = rand_float();
    } while (!ordinaryf(rand));
    arr[i] = rand;
  }
  return arr;
}


x86 assembly (clang, -O0):
<get_random_floats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x2,%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x0,%ecx
cmp    %ecx,%eax
jge    11b5 <get_random_floats+0x85>
jmp    116f <get_random_floats+0x3f>
mov    $0x0,%al
call   1040 <rand_float@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
call   1030 <ordinaryf@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    116f <get_random_floats+0x3f>
movss  -0x14(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1159 <get_random_floats+0x29>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_random_floats>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
lea    0x0(,%r14,4),%edi
call   1050 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    118b <get_random_floats+0x5b>
mov    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand_float@plt>
movss  %xmm0,0xc(%rsp)
call   1030 <ordinaryf@plt>
test   %eax,%eax
je     1160 <get_random_floats+0x30>
movss  0xc(%rsp),%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %r14,%rbx
jne    1160 <get_random_floats+0x30>
mov    %r15,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float* @get_random_floats(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca float*
%5 = alloca float
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = mul i64 4, %7
%9 = mul i64 %8, 1
%10 = trunc i64 %9 to i32
%11 = call float* @malloc(i32 %10)
store float* %11, float** %4
store i32 0, i32* %3
br label %12
12: ; preds = %31, %1
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = mul nsw i32 %14, 1
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %34
17: ; preds = %12
br label %18
18: ; preds = %20, %17
%19 = call float (...) @rand_float()
store float %19, float* %5
br label %20
20: ; preds = %18
%21 = load float, float* %5
%22 = call i32 @ordinaryf(float %21)
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br i1 %24, label %18, label %25
25: ; preds = %20
%26 = load float, float* %5
%27 = load float*, float** %4
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds float, float* %27, i64 %29
store float %26, float* %30
br label %31
31: ; preds = %25
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %12
34: ; preds = %12
%35 = load float*, float** %4
ret float* %35
}

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