#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 getRandomNumberF(double, double);
scalar_t__ malloc(int);
float *generateBias(int numHiddenLayerNeurons, int numCategories) {
  int i;
  float *bias =
      (float *)malloc(sizeof(float) * (numHiddenLayerNeurons + numCategories));
  for (i = 0; i < (numHiddenLayerNeurons + numCategories); i++)
    bias[i] = getRandomNumberF(-0.5, 0.5);
  return bias;
}


x86 assembly (clang, -O0):
<generateBias>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    118d <generateBias+0x6d>
movsd  0xe9b(%rip),%xmm0
movsd  0xe9b(%rip),%xmm1
call   1030 <getRandomNumberF@plt>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114c <generateBias+0x2c>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateBias>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%r14d
add    %esi,%r14d
lea    0x0(,%r14,4),%edi
call   1040 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    1174 <generateBias+0x54>
mov    %r14d,%r14d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0xea8(%rip),%xmm0
movsd  0xea8(%rip),%xmm1
call   1030 <getRandomNumberF@plt>
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1150 <generateBias+0x30>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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