#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 */
typedef int int64_t;

/* Variables and functions */
double randum(int64_t *seed) {
  int64_t sum, mult0, mult1, seed0, seed1, seed2, newseed0, newseed1, newseed2;
  double res;
  mult0 = 1549;
  seed0 = *seed & 4095;
  sum = mult0 * seed0;
  newseed0 = sum & 4095;
  sum >>= 12;
  seed1 = (*seed >> 12) & 4095;
  mult1 = 406;
  sum += mult0 * seed1 + mult1 * seed0;
  newseed1 = sum & 4095;
  sum >>= 12;
  seed2 = (*seed >> 24) & 255;
  sum += mult0 * seed2 + mult1 * seed1;
  newseed2 = sum & 255;
  *seed = newseed2 << 24 | newseed1 << 12 | newseed0;
  res = 0.00390625 *
        (newseed2 + 0.000244140625 * (newseed1 + 0.000244140625 * newseed0));
  return res;
}


x86 assembly (clang, -O0):
<randum>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x60d,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0xfff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfff,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
sar    $0xc,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sar    $0xc,%eax
and    $0xfff,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x196,-0x14(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
add    %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xfff,%eax
mov    %eax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
sar    $0xc,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
shl    $0x18,%ecx
mov    -0x28(%rbp),%eax
shl    $0xc,%eax
or     %eax,%ecx
or     -0x24(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
cvtsi2sdl -0x2c(%rbp),%xmm0
cvtsi2sdl -0x28(%rbp),%xmm2
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xe2b(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
movsd  0xe1b(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe03(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<randum>:
mov    (%rdi),%eax
mov    %eax,%edx
and    $0xfff,%edx
imul   $0x60d,%edx,%esi
mov    %esi,%r8d
and    $0xfff,%r8d
shr    $0xc,%esi
mov    %eax,%ecx
shr    $0xc,%ecx
and    $0xfff,%ecx
imul   $0x60d,%ecx,%r9d
imul   $0x196,%edx,%edx
add    %r9d,%edx
add    %esi,%edx
mov    %edx,%esi
and    $0xfff,%esi
shr    $0xc,%edx
shr    $0x18,%eax
imul   $0x60d,%eax,%eax
imul   $0x196,%ecx,%ecx
add    %eax,%ecx
add    %edx,%ecx
movzbl %cl,%eax
cvtsi2sd %esi,%xmm1
shl    $0x18,%ecx
shl    $0xc,%esi
or     %ecx,%esi
or     %r8d,%esi
cvtsi2sd %eax,%xmm2
cvtsi2sd %r8d,%xmm0
mov    %esi,(%rdi)
movsd  0xe83(%rip),%xmm3
mulsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
mulsd  0xe73(%rip),%xmm0
ret

LLVM IR (-O0):
define double @randum(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
store i32* %0, i32** %2
store i32 1549, i32* %4
%13 = load i32*, i32** %2
%14 = load i32, i32* %13
%15 = and i32 %14, 4095
store i32 %15, i32* %6
%16 = load i32, i32* %4
%17 = load i32, i32* %6
%18 = mul nsw i32 %16, %17
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = and i32 %19, 4095
store i32 %20, i32* %9
%21 = load i32, i32* %3
%22 = ashr i32 %21, 12
store i32 %22, i32* %3
%23 = load i32*, i32** %2
%24 = load i32, i32* %23
%25 = ashr i32 %24, 12
%26 = and i32 %25, 4095
store i32 %26, i32* %7
store i32 406, i32* %5
%27 = load i32, i32* %4
%28 = load i32, i32* %7
%29 = mul nsw i32 %27, %28
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = mul nsw i32 %30, %31
%33 = add nsw i32 %29, %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, %33
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = and i32 %36, 4095
store i32 %37, i32* %10
%38 = load i32, i32* %3
%39 = ashr i32 %38, 12
store i32 %39, i32* %3
%40 = load i32*, i32** %2
%41 = load i32, i32* %40
%42 = ashr i32 %41, 24
%43 = and i32 %42, 255
store i32 %43, i32* %8
%44 = load i32, i32* %4
%45 = load i32, i32* %8
%46 = mul nsw i32 %44, %45
%47 = load i32, i32* %5
%48 = load i32, i32* %7
%49 = mul nsw i32 %47, %48
%50 = add nsw i32 %46, %49
%51 = load i32, i32* %3
%52 = add nsw i32 %51, %50
store i32 %52, i32* %3
%53 = load i32, i32* %3
%54 = and i32 %53, 255
store i32 %54, i32* %11
%55 = load i32, i32* %11
%56 = shl i32 %55, 24
%57 = load i32, i32* %10
%58 = shl i32 %57, 12
%59 = or i32 %56, %58
%60 = load i32, i32* %9
%61 = or i32 %59, %60
%62 = load i32*, i32** %2
store i32 %61, i32* %62
%63 = load i32, i32* %11
%64 = sitofp i32 %63 to double
%65 = load i32, i32* %10
%66 = sitofp i32 %65 to double
%67 = load i32, i32* %9
%68 = sitofp i32 %67 to double
%69 = call double @llvm.fmuladd.f64(double 0x3F30000000000000, double %68, double %66)
%70 = call double @llvm.fmuladd.f64(double 0x3F30000000000000, double %69, double %64)
%71 = fmul double 3.906250e-03, %70
store double %71, double* %12
%72 = load double, double* %12
ret double %72
}

LLVM IR (-O2):
define double @randum(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = and i32 %2, 4095
%4 = mul nuw nsw i32 %3, 1549
%5 = and i32 %4, 4095
%6 = lshr i32 %4, 12
%7 = lshr i32 %2, 12
%8 = and i32 %7, 4095
%9 = mul nuw nsw i32 %8, 1549
%10 = mul nuw nsw i32 %3, 406
%11 = add nuw nsw i32 %9, %10
%12 = add nuw nsw i32 %11, %6
%13 = and i32 %12, 4095
%14 = lshr i32 %12, 12
%15 = lshr i32 %2, 24
%16 = mul nuw nsw i32 %15, 1549
%17 = mul nuw nsw i32 %8, 406
%18 = add nuw nsw i32 %17, %16
%19 = add nuw nsw i32 %18, %14
%20 = and i32 %19, 255
%21 = shl i32 %19, 24
%22 = shl nuw nsw i32 %13, 12
%23 = or i32 %21, %22
%24 = or i32 %23, %5
store i32 %24, i32* %0
%25 = sitofp i32 %20 to double
%26 = sitofp i32 %13 to double
%27 = sitofp i32 %5 to double
%28 = tail call double @llvm.fmuladd.f64(double %27, double 0x3F30000000000000, double %26)
%29 = tail call double @llvm.fmuladd.f64(double %28, double 0x3F30000000000000, double %25)
%30 = fmul double %29, 3.906250e-03
ret double %30
}