float rnd_park_miller(int *seed) {
  int k;
  float ans;
  *seed ^= 123459876;
  k = (*seed) / 127773;
  *seed = 16807 * (*seed - k * 127773) - 2836 * k;
  if (*seed < 0) {
    *seed += 2147483647;
  }
  ans = (1.0 / 2147483647) * (*seed);
  *seed ^= 123459876;
  return ans;
}


x86 assembly (clang, -O0):
<rnd_park_miller>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
xor    $0x75bd924,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    $0x1f31d,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
imul   $0x1f31d,-0xc(%rbp),%ecx
sub    %ecx,%eax
imul   $0x41a7,%eax,%ecx
imul   $0xb14,-0xc(%rbp),%eax
sub    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jge    1166 <rnd_park_miller+0x66>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
add    $0x7fffffff,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
movsd  0xe8a(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
xor    $0x75bd924,%ecx
mov    %ecx,(%rax)
movss  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<rnd_park_miller>:
movslq (%rdi),%rax
xor    $0x75bd924,%rax
imul   $0xffffffff834e0b5f,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x10,%ecx
add    %edx,%ecx
imul   $0xfffe0ce3,%ecx,%edx
add    %eax,%edx
imul   $0x41a7,%edx,%eax
imul   $0xfffff4ec,%ecx,%ecx
lea    (%rax,%rcx,1),%edx
add    $0x7fffffff,%edx
add    %ecx,%eax
cmovns %eax,%edx
cvtsi2sd %edx,%xmm0
mulsd  0xeb2(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
xor    $0x75bd924,%edx
mov    %edx,(%rdi)
ret

LLVM IR (-O0):
define float @rnd_park_miller(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca float
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = load i32, i32* %5
%7 = xor i32 %6, 123459876
store i32 %7, i32* %5
%8 = load i32*, i32** %2
%9 = load i32, i32* %8
%10 = sdiv i32 %9, 127773
store i32 %10, i32* %3
%11 = load i32*, i32** %2
%12 = load i32, i32* %11
%13 = load i32, i32* %3
%14 = mul nsw i32 %13, 127773
%15 = sub nsw i32 %12, %14
%16 = mul nsw i32 16807, %15
%17 = load i32, i32* %3
%18 = mul nsw i32 2836, %17
%19 = sub nsw i32 %16, %18
%20 = load i32*, i32** %2
store i32 %19, i32* %20
%21 = load i32*, i32** %2
%22 = load i32, i32* %21
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %1
%25 = load i32*, i32** %2
%26 = load i32, i32* %25
%27 = add nsw i32 %26, 2147483647
store i32 %27, i32* %25
br label %28
28: ; preds = %24, %1
%29 = load i32*, i32** %2
%30 = load i32, i32* %29
%31 = sitofp i32 %30 to double
%32 = fmul double 0x3E00000000200000, %31
%33 = fptrunc double %32 to float
store float %33, float* %4
%34 = load i32*, i32** %2
%35 = load i32, i32* %34
%36 = xor i32 %35, 123459876
store i32 %36, i32* %34
%37 = load float, float* %4
ret float %37
}

LLVM IR (-O2):
define float @rnd_park_miller(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = xor i32 %2, 123459876
%4 = sdiv i32 %3, 127773
%5 = mul nsw i32 %4, -127773
%6 = add i32 %5, %3
%7 = mul nsw i32 %6, 16807
%8 = mul nsw i32 %4, -2836
%9 = add i32 %7, %8
%10 = icmp slt i32 %9, 0
%11 = add nsw i32 %9, 2147483647
%12 = select i1 %10, i32 %11, i32 %9
%13 = sitofp i32 %12 to double
%14 = fmul double %13, 0x3E00000000200000
%15 = fptrunc double %14 to float
%16 = xor i32 %12, 123459876
store i32 %16, i32* %0
ret float %15
}