#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 RAND_MAX;
scalar_t__ malloc(int);
scalar_t__ rand();
float *genNoisef(short width, short height, float min, float max) {
  int len, i;
  float *out, range;
  len = width * height;
  range = max - min;
  out = (float *)malloc(len * sizeof(float));
  for (i = 0; i < len; i++)
    out[i] = (((float)rand() / RAND_MAX) * range) + min;
  return out;
}


x86 assembly (clang, -O0):
<genNoisef>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %si,%ax
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %ax,-0x4(%rbp)
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movswl -0x2(%rbp),%eax
movswl -0x4(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11c7 <genNoisef+0xa7>
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2e52(%rip),%rax
divss  (%rax),%xmm0
movss  -0x24(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1177 <genNoisef+0x57>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<genNoisef>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movss  %xmm1,(%rsp)
movss  %xmm0,0x4(%rsp)
mov    %edi,%r14d
imul   %esi,%r14d
lea    0x0(,%r14,4),%edi
call   1030 <malloc@plt>
mov    %rax,%r15
test   %r14d,%r14d
jle    119e <genNoisef+0x7e>
movss  (%rsp),%xmm0
subss  0x4(%rsp),%xmm0
movss  %xmm0,(%rsp)
mov    %r14d,%r12d
mov    0x2e7f(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  (%r14),%xmm0
mulss  (%rsp),%xmm0
addss  0x4(%rsp),%xmm0
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1170 <genNoisef+0x50>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@RAND_MAX = global float 0.000000e+00
define float* @genNoisef(i16 signext %0, i16 signext %1, float %2, float %3) {
%5 = alloca i16
%6 = alloca i16
%7 = alloca float
%8 = alloca float
%9 = alloca i32
%10 = alloca i32
%11 = alloca float*
%12 = alloca float
store i16 %0, i16* %5
store i16 %1, i16* %6
store float %2, float* %7
store float %3, float* %8
%13 = load i16, i16* %5
%14 = sext i16 %13 to i32
%15 = load i16, i16* %6
%16 = sext i16 %15 to i32
%17 = mul nsw i32 %14, %16
store i32 %17, i32* %9
%18 = load float, float* %8
%19 = load float, float* %7
%20 = fsub float %18, %19
store float %20, float* %12
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = mul i64 %22, 4
%24 = trunc i64 %23 to i32
%25 = call i64 @malloc(i32 %24)
%26 = inttoptr i64 %25 to float*
store float* %26, float** %11
store i32 0, i32* %10
br label %27
27: ; preds = %43, %4
%28 = load i32, i32* %10
%29 = load i32, i32* %9
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %46
31: ; preds = %27
%32 = call i64 (...) @rand()
%33 = sitofp i64 %32 to float
%34 = load float, float* @RAND_MAX
%35 = fdiv float %33, %34
%36 = load float, float* %12
%37 = load float, float* %7
%38 = call float @llvm.fmuladd.f32(float %35, float %36, float %37)
%39 = load float*, float** %11
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %39, i64 %41
store float %38, float* %42
br label %43
43: ; preds = %31
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %27
46: ; preds = %27
%47 = load float*, float** %11
ret float* %47
}

LLVM IR (-O2):
@RAND_MAX = global float 0.000000e+00
define float* @genNoisef(i16 signext %0, i16 signext %1, float %2, float %3) {
%5 = sext i16 %0 to i32
%6 = sext i16 %1 to i32
%7 = mul nsw i32 %6, %5
%8 = fsub float %3, %2
%9 = shl i32 %7, 2
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to float*
%12 = icmp sgt i32 %7, 0
br i1 %12, label %13, label %25
13: ; preds = %4
%14 = zext i32 %7 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %23, %15 ]
%17 = tail call i64 (...) @rand()
%18 = sitofp i64 %17 to float
%19 = load float, float* @RAND_MAX
%20 = fdiv float %18, %19
%21 = tail call float @llvm.fmuladd.f32(float %20, float %8, float %2)
%22 = getelementptr inbounds float, float* %11, i64 %16
store float %21, float* %22
%23 = add nuw nsw i64 %16, 1
%24 = icmp eq i64 %23, %14
br i1 %24, label %25, label %15
25: ; preds = %15, %4
ret float* %11
}