#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__ calloc(unsigned int, int);
float randf(float, float);
float *wnoise_wavetable_init(unsigned int wavetable_size, float amount) {
  unsigned int i = 0;
  float *wt = (float *)calloc(wavetable_size, sizeof(float));
  for (i = 0; i < wavetable_size; i += 1) {
    wt[i] = randf(-amount, amount);
  }
  return wt;
}


x86 assembly (clang, -O0):
<wnoise_wavetable_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1191 <wnoise_wavetable_init+0x71>
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0x8(%rbp),%xmm1
call   1040 <randf@plt>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
movss  %xmm0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <wnoise_wavetable_init+0x2f>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wnoise_wavetable_init>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movaps %xmm0,(%rsp)
mov    %edi,%ebp
mov    $0x4,%esi
call   1030 <calloc@plt>
mov    %rax,%r14
test   %ebp,%ebp
je     117d <wnoise_wavetable_init+0x5d>
movaps 0xeba(%rip),%xmm0
xorps  (%rsp),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movaps 0x10(%rsp),%xmm0
movaps (%rsp),%xmm1
call   1040 <randf@plt>
movss  %xmm0,(%r14,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <wnoise_wavetable_init+0x40>
mov    %r14,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define float* @wnoise_wavetable_init(i32 %0, float %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca i32
%6 = alloca float*
store i32 %0, i32* %3
store float %1, float* %4
store i32 0, i32* %5
%7 = load i32, i32* %3
%8 = call i64 @calloc(i32 %7, i32 4)
%9 = inttoptr i64 %8 to float*
store float* %9, float** %6
store i32 0, i32* %5
br label %10
10: ; preds = %23, %2
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load float, float* %4
%16 = fneg float %15
%17 = load float, float* %4
%18 = call float @randf(float %16, float %17)
%19 = load float*, float** %6
%20 = load i32, i32* %5
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds float, float* %19, i64 %21
store float %18, float* %22
br label %23
23: ; preds = %14
%24 = load i32, i32* %5
%25 = add i32 %24, 1
store i32 %25, i32* %5
br label %10
26: ; preds = %10
%27 = load float*, float** %6
ret float* %27
}

LLVM IR (-O2):
define float* @wnoise_wavetable_init(i32 %0, float %1) {
%3 = tail call i64 @calloc(i32 %0, i32 4)
%4 = inttoptr i64 %3 to float*
%5 = icmp eq i32 %0, 0
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = fneg float %1
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %13, %9 ]
%11 = tail call float @randf(float %7, float %1)
%12 = getelementptr inbounds float, float* %4, i64 %10
store float %11, float* %12
%13 = add nuw nsw i64 %10, 1
%14 = icmp eq i64 %13, %8
br i1 %14, label %15, label %9
15: ; preds = %9, %2
ret float* %4
}