#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 random();
void rand_num(float output[], float amplitude, int npts) {
  int i;
  for (i = 0; i < npts; i++) {
    output[i] = amplitude * (float)(((random() >> 16) / 32767. - .5) * 2);
  }
}


x86 assembly (clang, -O0):
<rand_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119b <rand_num+0x8b>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <random@plt>
movss  -0x18(%rbp),%xmm0
sar    $0x10,%eax
cvtsi2sd %eax,%xmm1
movsd  0xeb4(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xea0(%rip),%xmm2
subsd  %xmm2,%xmm1
movsd  0xe8c(%rip),%xmm2
mulsd  %xmm2,%xmm1
cvtsd2ss %xmm1,%xmm1
mulss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112b <rand_num+0x1b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rand_num>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
jle    1172 <rand_num+0x62>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
movss  %xmm0,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <random@plt>
movss  0xc(%rsp),%xmm0
sar    $0x10,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  0xeb1(%rip),%xmm1
addsd  0xeb1(%rip),%xmm1
addsd  %xmm1,%xmm1
cvtsd2ss %xmm1,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <rand_num+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rand_num(float* %0, float %1, i32 %2) {
%4 = alloca float*
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
store float* %0, float** %4
store float %1, float* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %26, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %29
12: ; preds = %8
%13 = load float, float* %5
%14 = call i32 (...) @random()
%15 = ashr i32 %14, 16
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, 3.276700e+04
%18 = fsub double %17, 5.000000e-01
%19 = fmul double %18, 2.000000e+00
%20 = fptrunc double %19 to float
%21 = fmul float %13, %20
%22 = load float*, float** %4
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float, float* %22, i64 %24
store float %21, float* %25
br label %26
26: ; preds = %12
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %8
29: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @rand_num(float* nocapture writeonly %0, float %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %18, %7 ]
%9 = tail call i32 (...) @random()
%10 = ashr i32 %9, 16
%11 = sitofp i32 %10 to double
%12 = fdiv double %11, 3.276700e+04
%13 = fadd double %12, -5.000000e-01
%14 = fmul double %13, 2.000000e+00
%15 = fptrunc double %14 to float
%16 = fmul float %15, %1
%17 = getelementptr inbounds float, float* %0, i64 %8
store float %16, float* %17
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, %6
br i1 %19, label %20, label %7
20: ; preds = %7, %3
ret void
}