#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 rand();
float CG_RandomiseValue(float value, float variance) {
  if (value != 0.0f)
    return value * (1.0f + (((rand() & 0x7fff) / ((float)0x7fff)) * variance));
  else
    return ((rand() & 0x7fff) / ((float)0x7fff)) * variance;
}


x86 assembly (clang, -O0):
<CG_RandomiseValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    113e <CG_RandomiseValue+0x2e>
jp     113e <CG_RandomiseValue+0x2e>
jmp    118c <CG_RandomiseValue+0x7c>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
movss  -0x10(%rbp),%xmm0
and    $0x7fff,%eax
cvtsi2ss %eax,%xmm1
movss  0xe9b(%rip),%xmm2
divss  %xmm2,%xmm1
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm1
movss  0xe8a(%rip),%xmm2
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11b2 <CG_RandomiseValue+0xa2>
mov    $0x0,%al
call   1030 <rand@plt>
and    $0x7fff,%eax
cvtsi2ss %eax,%xmm0
movss  0xe5c(%rip),%xmm1
divss  %xmm1,%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CG_RandomiseValue>:
push   %rax
movss  %xmm1,(%rsp)
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
and    $0x7fff,%eax
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
divss  0xec9(%rip),%xmm1
mulss  (%rsp),%xmm1
movss  0xec0(%rip),%xmm2
addss  %xmm1,%xmm2
movss  0x4(%rsp),%xmm3
mulss  %xmm3,%xmm2
xorps  %xmm0,%xmm0
cmpneqss %xmm3,%xmm0
movaps %xmm0,%xmm3
andnps %xmm1,%xmm3
andps  %xmm2,%xmm0
orps   %xmm3,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @CG_RandomiseValue(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %4
store float %1, float* %5
%6 = load float, float* %4
%7 = fcmp une float %6, 0.000000e+00
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load float, float* %4
%10 = call i32 (...) @rand()
%11 = and i32 %10, 32767
%12 = sitofp i32 %11 to float
%13 = fdiv float %12, 3.276700e+04
%14 = load float, float* %5
%15 = call float @llvm.fmuladd.f32(float %13, float %14, float 1.000000e+00)
%16 = fmul float %9, %15
store float %16, float* %3
br label %24
17: ; preds = %2
%18 = call i32 (...) @rand()
%19 = and i32 %18, 32767
%20 = sitofp i32 %19 to float
%21 = fdiv float %20, 3.276700e+04
%22 = load float, float* %5
%23 = fmul float %21, %22
store float %23, float* %3
br label %24
24: ; preds = %17, %8
%25 = load float, float* %3
ret float %25
}

LLVM IR (-O2):
define float @CG_RandomiseValue(float %0, float %1) {
%3 = fcmp une float %0, 0.000000e+00
%4 = tail call i32 (...) @rand()
%5 = and i32 %4, 32767
%6 = sitofp i32 %5 to float
%7 = fdiv float %6, 3.276700e+04
%8 = tail call float @llvm.fmuladd.f32(float %7, float %1, float 1.000000e+00)
%9 = fmul float %8, %0
%10 = fmul float %7, %1
%11 = select i1 %3, float %9, float %10
ret float %11
}