#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 */
unsigned int hGetRealRndNumber();
double hRnd_MTWIST(float);
double hRnd_REAL(float n) {
  static unsigned int count = 0;
  static unsigned int v;
  double mtwist;
  mtwist = hRnd_MTWIST(n);
  if ((count % 256) == 0) {
    count = 1;
    v = hGetRealRndNumber();
  } else {
    count++;
  }
  if (v == 0) {
    return mtwist;
  }
  v *= mtwist;
  v ^= (v >> 11);
  v ^= ((v << 7) & 0x9D2C5680);
  v ^= ((v << 15) & 0xEFC60000);
  v ^= (v >> 18);
  return (double)v / (double)4294967296ULL;
}


x86 assembly (clang, -O0):
<hRnd_REAL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
call   1030 <hRnd_MTWIST@plt>
movsd  %xmm0,-0x18(%rbp)
mov    0x2ef2(%rip),%eax
and    $0xff,%eax
cmp    $0x0,%eax
jne    116c <hRnd_REAL+0x4c>
movl   $0x1,0x2eda(%rip)
mov    $0x0,%al
call   1040 <hGetRealRndNumber@plt>
mov    %eax,0x2ed1(%rip)
jmp    117b <hRnd_REAL+0x5b>
mov    0x2ec2(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2eb9(%rip)
cmpl   $0x0,0x2eb6(%rip)
jne    1197 <hRnd_REAL+0x77>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    122a <hRnd_REAL+0x10a>
movsd  -0x18(%rbp),%xmm1
mov    0x2e96(%rip),%eax
cvtsi2sd %rax,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,0x2e82(%rip)
mov    0x2e7c(%rip),%eax
mov    %eax,%ecx
shr    $0xb,%ecx
xor    %ecx,%eax
mov    %eax,0x2e6f(%rip)
mov    0x2e69(%rip),%eax
mov    %eax,%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
xor    %ecx,%eax
mov    %eax,0x2e56(%rip)
mov    0x2e50(%rip),%eax
mov    %eax,%ecx
shl    $0xf,%ecx
and    $0xefc60000,%ecx
xor    %ecx,%eax
mov    %eax,0x2e3d(%rip)
mov    0x2e37(%rip),%eax
mov    %eax,%ecx
shr    $0x12,%ecx
xor    %ecx,%eax
mov    %eax,0x2e2a(%rip)
mov    0x2e24(%rip),%eax
cvtsi2sd %rax,%xmm0
movsd  0xddf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hRnd_REAL>:
push   %rax
call   1030 <hRnd_MTWIST@plt>
mov    0x2f08(%rip),%eax
test   %al,%al
je     1192 <hRnd_REAL+0x72>
add    $0x1,%eax
mov    %eax,0x2efb(%rip)
mov    0x2ef9(%rip),%eax
test   %eax,%eax
je     1190 <hRnd_REAL+0x70>
mov    %eax,%eax
cvtsi2sd %rax,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %eax,%ecx
shr    $0xb,%ecx
xor    %eax,%ecx
mov    %ecx,%eax
shl    $0x7,%eax
and    $0x9d2c5680,%eax
xor    %ecx,%eax
mov    %eax,%ecx
shl    $0xf,%ecx
and    $0xefc60000,%ecx
xor    %eax,%ecx
mov    %ecx,%eax
shr    $0x12,%eax
xor    %ecx,%eax
mov    %eax,0x2eb8(%rip)
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  0xe70(%rip),%xmm0
pop    %rax
ret
movl   $0x1,0x2e98(%rip)
xor    %eax,%eax
movsd  %xmm0,(%rsp)
call   1040 <hGetRealRndNumber@plt>
movsd  (%rsp),%xmm0
mov    %eax,0x2e85(%rip)
test   %eax,%eax
jne    1143 <hRnd_REAL+0x23>
jmp    1190 <hRnd_REAL+0x70>

LLVM IR (-O0):
@hRnd_REAL.count = internal global i32 0
@hRnd_REAL.v = internal global i32 0
define double @hRnd_REAL(float %0) {
%2 = alloca double
%3 = alloca float
%4 = alloca double
store float %0, float* %3
%5 = load float, float* %3
%6 = call double @hRnd_MTWIST(float %5)
store double %6, double* %4
%7 = load i32, i32* @hRnd_REAL.count
%8 = urem i32 %7, 256
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
store i32 1, i32* @hRnd_REAL.count
%11 = call i32 (...) @hGetRealRndNumber()
store i32 %11, i32* @hRnd_REAL.v
br label %15
12: ; preds = %1
%13 = load i32, i32* @hRnd_REAL.count
%14 = add i32 %13, 1
store i32 %14, i32* @hRnd_REAL.count
br label %15
15: ; preds = %12, %10
%16 = load i32, i32* @hRnd_REAL.v
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load double, double* %4
store double %19, double* %2
br label %47
20: ; preds = %15
%21 = load double, double* %4
%22 = load i32, i32* @hRnd_REAL.v
%23 = uitofp i32 %22 to double
%24 = fmul double %23, %21
%25 = fptoui double %24 to i32
store i32 %25, i32* @hRnd_REAL.v
%26 = load i32, i32* @hRnd_REAL.v
%27 = lshr i32 %26, 11
%28 = load i32, i32* @hRnd_REAL.v
%29 = xor i32 %28, %27
store i32 %29, i32* @hRnd_REAL.v
%30 = load i32, i32* @hRnd_REAL.v
%31 = shl i32 %30, 7
%32 = and i32 %31, -1658038656
%33 = load i32, i32* @hRnd_REAL.v
%34 = xor i32 %33, %32
store i32 %34, i32* @hRnd_REAL.v
%35 = load i32, i32* @hRnd_REAL.v
%36 = shl i32 %35, 15
%37 = and i32 %36, -272236544
%38 = load i32, i32* @hRnd_REAL.v
%39 = xor i32 %38, %37
store i32 %39, i32* @hRnd_REAL.v
%40 = load i32, i32* @hRnd_REAL.v
%41 = lshr i32 %40, 18
%42 = load i32, i32* @hRnd_REAL.v
%43 = xor i32 %42, %41
store i32 %43, i32* @hRnd_REAL.v
%44 = load i32, i32* @hRnd_REAL.v
%45 = uitofp i32 %44 to double
%46 = fdiv double %45, 0x41F0000000000000
store double %46, double* %2
br label %47
47: ; preds = %20, %18
%48 = load double, double* %2
ret double %48
}

LLVM IR (-O2):
@hRnd_REAL.count = internal unnamed_addr global i32 0
@hRnd_REAL.v = internal unnamed_addr global i32 0
define double @hRnd_REAL(float %0) {
%2 = tail call double @hRnd_MTWIST(float %0)
%3 = load i32, i32* @hRnd_REAL.count
%4 = and i32 %3, 255
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
store i32 1, i32* @hRnd_REAL.count
%7 = tail call i32 (...) @hGetRealRndNumber()
store i32 %7, i32* @hRnd_REAL.v
br label %11
8: ; preds = %1
%9 = add i32 %3, 1
store i32 %9, i32* @hRnd_REAL.count
%10 = load i32, i32* @hRnd_REAL.v
br label %11
11: ; preds = %8, %6
%12 = phi i32 [ %10, %8 ], [ %7, %6 ]
%13 = icmp eq i32 %12, 0
br i1 %13, label %30, label %14
14: ; preds = %11
%15 = uitofp i32 %12 to double
%16 = fmul double %2, %15
%17 = fptoui double %16 to i32
%18 = lshr i32 %17, 11
%19 = xor i32 %18, %17
%20 = shl i32 %19, 7
%21 = and i32 %20, -1658038656
%22 = xor i32 %21, %19
%23 = shl i32 %22, 15
%24 = and i32 %23, -272236544
%25 = xor i32 %24, %22
%26 = lshr i32 %25, 18
%27 = xor i32 %26, %25
store i32 %27, i32* @hRnd_REAL.v
%28 = uitofp i32 %27 to double
%29 = fmul double %28, 0x3DF0000000000000
br label %30
30: ; preds = %11, %14
%31 = phi double [ %29, %14 ], [ %2, %11 ]
ret double %31
}