float randfloat() {
  static unsigned int seed = 123;
  static unsigned int i = 456;
  unsigned int m = 0x5bd1e995;
  unsigned int k = i++ * m;
  seed = (k ^ (k >> 24) ^ (seed * m)) * m;
  unsigned int R = (seed ^ (seed >> 13)) & 0x007FFFFF;
  union {
    unsigned int i;
    float f;
  } u = {u.i = 0x3F800000 | R};
  return u.f - 1.0f;
}


x86 assembly (clang, -O0):
<randfloat>:
push   %rbp
mov    %rsp,%rbp
movl   $0x5bd1e995,-0x4(%rbp)
mov    0x2f13(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2f08(%rip)
imul   -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x18,%ecx
xor    %ecx,%eax
mov    0x2eec(%rip),%ecx
imul   -0x4(%rbp),%ecx
xor    %ecx,%eax
imul   -0x4(%rbp),%eax
mov    %eax,0x2edc(%rip)
mov    0x2ed6(%rip),%eax
mov    0x2ed0(%rip),%ecx
shr    $0xd,%ecx
xor    %ecx,%eax
and    $0x7fffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x3f800000,%eax
mov    %eax,-0x10(%rbp)
mov    %eax,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xe88(%rip),%xmm1
subss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<randfloat>:
mov    0x2f1e(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2f15(%rip)
imul   $0x5bd1e995,%eax,%eax
imul   $0x5bd1e995,0x2f01(%rip),%ecx
e9 d1 5b
xor    %eax,%ecx
shr    $0x18,%eax
xor    %eax,%ecx
imul   $0x5bd1e995,%ecx,%eax
mov    %eax,0x2eee(%rip)
mov    %eax,%ecx
shr    $0xd,%ecx
and    $0x7fffff,%eax
xor    %ecx,%eax
or     $0x3f800000,%eax
movd   %eax,%xmm0
addss  0xeb1(%rip),%xmm0
ret

LLVM IR (-O0):
%union.anon = type { i32 }
@randfloat.seed = internal global i32 123
@randfloat.i = internal global i32 456
define float @randfloat() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %union.anon
store i32 1540483477, i32* %1
%5 = load i32, i32* @randfloat.i
%6 = add i32 %5, 1
store i32 %6, i32* @randfloat.i
%7 = load i32, i32* %1
%8 = mul i32 %5, %7
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = load i32, i32* %2
%11 = lshr i32 %10, 24
%12 = xor i32 %9, %11
%13 = load i32, i32* @randfloat.seed
%14 = load i32, i32* %1
%15 = mul i32 %13, %14
%16 = xor i32 %12, %15
%17 = load i32, i32* %1
%18 = mul i32 %16, %17
store i32 %18, i32* @randfloat.seed
%19 = load i32, i32* @randfloat.seed
%20 = load i32, i32* @randfloat.seed
%21 = lshr i32 %20, 13
%22 = xor i32 %19, %21
%23 = and i32 %22, 8388607
store i32 %23, i32* %3
%24 = bitcast %union.anon* %4 to i32*
%25 = load i32, i32* %3
%26 = or i32 1065353216, %25
%27 = bitcast %union.anon* %4 to i32*
store i32 %26, i32* %27
store i32 %26, i32* %24
%28 = bitcast %union.anon* %4 to float*
%29 = load float, float* %28
%30 = fsub float %29, 1.000000e+00
ret float %30
}

LLVM IR (-O2):
@randfloat.seed = internal unnamed_addr global i32 123
@randfloat.i = internal unnamed_addr global i32 456
define float @randfloat() {
%1 = load i32, i32* @randfloat.i
%2 = add i32 %1, 1
store i32 %2, i32* @randfloat.i
%3 = mul i32 %1, 1540483477
%4 = lshr i32 %3, 24
%5 = xor i32 %4, %3
%6 = load i32, i32* @randfloat.seed
%7 = mul i32 %6, 1540483477
%8 = xor i32 %5, %7
%9 = mul i32 %8, 1540483477
store i32 %9, i32* @randfloat.seed
%10 = lshr i32 %9, 13
%11 = and i32 %9, 8388607
%12 = xor i32 %11, %10
%13 = or i32 %12, 1065353216
%14 = bitcast i32 %13 to float
%15 = fadd float %14, -1.000000e+00
ret float %15
}