#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 */
double exp(double);
double floor(double);
double log(double);
double sqrt(double);
double tan(double);
double uniform();
double Poisson(double xm) {
  double lgamma(double xx);
  static double sq, alxm, g, oldm = (-1.0);
  double em, t, y;
  if (xm < 12.0) {
    if (xm != oldm) {
      oldm = xm;
      g = exp(-xm);
    }
    em = -1;
    t = 1.0;
    do {
      ++em;
      t *= uniform();
    } while (t > g);
  } else {
    if (xm != oldm) {
      oldm = xm;
      sq = sqrt(2.0 * xm);
      alxm = log(xm);
      g = xm * alxm - lgamma(xm + 1.0);
    }
    do {
      do {
        y = tan(3.141592654 * uniform());
        em = sq * y + xm;
      } while (em < 0.0);
      em = floor(em);
      t = 0.9 * (1.0 + y * y) * exp(em * alxm - lgamma(em + 1.0) - g);
    } while (uniform() > t);
  }
  return em;
}


x86 assembly (clang, -O0):
<Poisson>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xe7b(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1239 <Poisson+0xc9>
movsd  -0x8(%rbp),%xmm0
ucomisd 0x2ebb(%rip),%xmm0
jne    11ae <Poisson+0x3e>
jp     11ae <Poisson+0x3e>
jmp    11e4 <Poisson+0x74>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,0x2e9d(%rip)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x2e94(%rip)
movsd  0xe3c(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe0f(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe02(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <uniform@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd 0x2e4a(%rip),%xmm0
ja     11fe <Poisson+0x8e>
jmp    1408 <Poisson+0x298>
movsd  -0x8(%rbp),%xmm0
ucomisd 0x2e12(%rip),%xmm0
jne    1257 <Poisson+0xe7>
jp     1257 <Poisson+0xe7>
jmp    12ed <Poisson+0x17d>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,0x2df4(%rip)
movsd  0xda4(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1080 <sqrt@plt>
movsd  %xmm0,0x2dea(%rip)
movsd  -0x8(%rbp),%xmm0
call   1070 <log@plt>
movsd  %xmm0,0x2de0(%rip)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0x2dce(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xd59(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
call   1050 <lgamma@plt>
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x2d8b(%rip)
jmp    12f2 <Poisson+0x182>
jmp    12f7 <Poisson+0x187>
mov    $0x0,%al
call   1030 <uniform@plt>
movaps %xmm0,%xmm1
movsd  0xd0f(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <tan@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0x2d49(%rip),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     12f7 <Poisson+0x187>
movsd  -0x10(%rbp),%xmm0
call   1090 <floor@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xc9f(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xcab(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0x2ce0(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xc6b(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1050 <lgamma@plt>
movsd  -0x48(%rbp),%xmm2
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  0x2c9d(%rip),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <uniform@plt>
ucomisd -0x18(%rbp),%xmm0
ja     12f2 <Poisson+0x182>
jmp    1408 <Poisson+0x298>
movsd  -0x10(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Poisson>:
sub    $0x28,%rsp
movapd %xmm0,%xmm2
movsd  0xe80(%rip),%xmm0
ucomisd %xmm2,%xmm0
movsd  0x2ecc(%rip),%xmm0
jbe    1208 <Poisson+0x98>
ucomisd %xmm2,%xmm0
jne    1196 <Poisson+0x26>
jnp    11b7 <Poisson+0x47>
movsd  %xmm2,0x2eba(%rip)
xorpd  0xe8a(%rip),%xmm2
movapd %xmm2,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x2ec1(%rip)
movsd  0xe61(%rip),%xmm0
movsd  0xe41(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,(%rsp)
addsd  0xe2b(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <uniform@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
ucomisd 0x2e77(%rip),%xmm1
ja     11d0 <Poisson+0x60>
add    $0x28,%rsp
ret
ucomisd %xmm2,%xmm0
movapd %xmm2,0x10(%rsp)
jne    1216 <Poisson+0xa6>
jnp    1290 <Poisson+0x120>
movsd  %xmm2,0x2e3a(%rip)
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1236 <Poisson+0xc6>
sqrtsd %xmm0,%xmm0
jmp    1241 <Poisson+0xd1>
call   1080 <sqrt@plt>
movapd 0x10(%rsp),%xmm2
movsd  %xmm0,0x2e1f(%rip)
movapd %xmm2,%xmm0
call   1070 <log@plt>
movsd  %xmm0,(%rsp)
movsd  %xmm0,0x2e11(%rip)
movsd  0xda1(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
call   1050 <lgamma@plt>
movsd  (%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x2def(%rip)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <uniform@plt>
mulsd  0xd71(%rip),%xmm0
call   1060 <tan@plt>
movapd %xmm0,%xmm2
movsd  0x2db8(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1290 <Poisson+0x120>
movsd  %xmm2,(%rsp)
call   1090 <floor@plt>
movapd %xmm0,%xmm2
movsd  (%rsp),%xmm3
mulsd  %xmm3,%xmm3
movsd  0xd25(%rip),%xmm1
addsd  %xmm1,%xmm3
mulsd  0xd29(%rip),%xmm3
movsd  %xmm3,(%rsp)
addsd  %xmm1,%xmm0
movsd  0x2d70(%rip),%xmm1
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x20(%rsp)
call   1050 <lgamma@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
subsd  0x2d51(%rip),%xmm1
movapd %xmm1,%xmm0
call   1040 <exp@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <uniform@plt>
ucomisd (%rsp),%xmm0
ja     1290 <Poisson+0x120>
movsd  0x8(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@Poisson.sq = internal global double 0.000000e+00
@Poisson.alxm = internal global double 0.000000e+00
@Poisson.g = internal global double 0.000000e+00
@Poisson.oldm = internal global double -1.000000e+00
define double @Poisson(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %2
%6 = load double, double* %2
%7 = fcmp olt double %6, 1.200000e+01
br i1 %7, label %8, label %29
8: ; preds = %1
%9 = load double, double* %2
%10 = load double, double* @Poisson.oldm
%11 = fcmp une double %9, %10
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load double, double* %2
store double %13, double* @Poisson.oldm
%14 = load double, double* %2
%15 = fneg double %14
%16 = call double @exp(double %15)
store double %16, double* @Poisson.g
br label %17
17: ; preds = %12, %8
store double -1.000000e+00, double* %3
store double 1.000000e+00, double* %4
br label %18
18: ; preds = %24, %17
%19 = load double, double* %3
%20 = fadd double %19, 1.000000e+00
store double %20, double* %3
%21 = call double (...) @uniform()
%22 = load double, double* %4
%23 = fmul double %22, %21
store double %23, double* %4
br label %24
24: ; preds = %18
%25 = load double, double* %4
%26 = load double, double* @Poisson.g
%27 = fcmp ogt double %25, %26
br i1 %27, label %18, label %28
28: ; preds = %24
br label %83
29: ; preds = %1
%30 = load double, double* %2
%31 = load double, double* @Poisson.oldm
%32 = fcmp une double %30, %31
br i1 %32, label %33, label %47
33: ; preds = %29
%34 = load double, double* %2
store double %34, double* @Poisson.oldm
%35 = load double, double* %2
%36 = fmul double 2.000000e+00, %35
%37 = call double @sqrt(double %36)
store double %37, double* @Poisson.sq
%38 = load double, double* %2
%39 = call double @log(double %38)
store double %39, double* @Poisson.alxm
%40 = load double, double* %2
%41 = load double, double* @Poisson.alxm
%42 = load double, double* %2
%43 = fadd double %42, 1.000000e+00
%44 = call double @lgamma(double %43)
%45 = fneg double %44
%46 = call double @llvm.fmuladd.f64(double %40, double %41, double %45)
store double %46, double* @Poisson.g
br label %47
47: ; preds = %33, %29
br label %48
48: ; preds = %78, %47
br label %49
49: ; preds = %57, %48
%50 = call double (...) @uniform()
%51 = fmul double 0x400921FB54524550, %50
%52 = call double @tan(double %51)
store double %52, double* %5
%53 = load double, double* @Poisson.sq
%54 = load double, double* %5
%55 = load double, double* %2
%56 = call double @llvm.fmuladd.f64(double %53, double %54, double %55)
store double %56, double* %3
br label %57
57: ; preds = %49
%58 = load double, double* %3
%59 = fcmp olt double %58, 0.000000e+00
br i1 %59, label %49, label %60
60: ; preds = %57
%61 = load double, double* %3
%62 = call double @llvm.floor.f64(double %61)
store double %62, double* %3
%63 = load double, double* %5
%64 = load double, double* %5
%65 = call double @llvm.fmuladd.f64(double %63, double %64, double 1.000000e+00)
%66 = fmul double 9.000000e-01, %65
%67 = load double, double* %3
%68 = load double, double* @Poisson.alxm
%69 = load double, double* %3
%70 = fadd double %69, 1.000000e+00
%71 = call double @lgamma(double %70)
%72 = fneg double %71
%73 = call double @llvm.fmuladd.f64(double %67, double %68, double %72)
%74 = load double, double* @Poisson.g
%75 = fsub double %73, %74
%76 = call double @exp(double %75)
%77 = fmul double %66, %76
store double %77, double* %4
br label %78
78: ; preds = %60
%79 = call double (...) @uniform()
%80 = load double, double* %4
%81 = fcmp ogt double %79, %80
br i1 %81, label %48, label %82
82: ; preds = %78
br label %83
83: ; preds = %82, %28
%84 = load double, double* %3
ret double %84
}

LLVM IR (-O2):
@Poisson.sq = internal unnamed_addr global double 0.000000e+00
@Poisson.alxm = internal unnamed_addr global double 0.000000e+00
@Poisson.g = internal unnamed_addr global double 0.000000e+00
@Poisson.oldm = internal unnamed_addr global double -1.000000e+00
define double @Poisson(double %0) {
%2 = fcmp olt double %0, 1.200000e+01
%3 = load double, double* @Poisson.oldm
%4 = fcmp une double %3, %0
br i1 %2, label %5, label %18
5: ; preds = %1
br i1 %4, label %6, label %9
6: ; preds = %5
store double %0, double* @Poisson.oldm
%7 = fneg double %0
%8 = tail call double @exp(double %7)
store double %8, double* @Poisson.g
br label %9
9: ; preds = %6, %5
br label %10
10: ; preds = %9, %10
%11 = phi double [ %15, %10 ], [ 1.000000e+00, %9 ]
%12 = phi double [ %13, %10 ], [ -1.000000e+00, %9 ]
%13 = fadd double %12, 1.000000e+00
%14 = tail call double (...) @uniform()
%15 = fmul double %11, %14
%16 = load double, double* @Poisson.g
%17 = fcmp ogt double %15, %16
br i1 %17, label %10, label %51
18: ; preds = %1
br i1 %4, label %19, label %27
19: ; preds = %18
store double %0, double* @Poisson.oldm
%20 = fmul double %0, 2.000000e+00
%21 = tail call double @sqrt(double %20)
store double %21, double* @Poisson.sq
%22 = tail call double @log(double %0)
store double %22, double* @Poisson.alxm
%23 = fadd double %0, 1.000000e+00
%24 = tail call double @lgamma(double %23)
%25 = fneg double %24
%26 = tail call double @llvm.fmuladd.f64(double %0, double %22, double %25)
store double %26, double* @Poisson.g
br label %27
27: ; preds = %18, %19
br label %28
28: ; preds = %35, %27
%29 = tail call double (...) @uniform()
%30 = fmul double %29, 0x400921FB54524550
%31 = tail call double @tan(double %30)
%32 = load double, double* @Poisson.sq
%33 = tail call double @llvm.fmuladd.f64(double %32, double %31, double %0)
%34 = fcmp olt double %33, 0.000000e+00
br i1 %34, label %35, label %36
35: ; preds = %28, %36
br label %28
36: ; preds = %28
%37 = tail call double @llvm.floor.f64(double %33)
%38 = tail call double @llvm.fmuladd.f64(double %31, double %31, double 1.000000e+00)
%39 = fmul double %38, 9.000000e-01
%40 = load double, double* @Poisson.alxm
%41 = fadd double %37, 1.000000e+00
%42 = tail call double @lgamma(double %41)
%43 = fneg double %42
%44 = tail call double @llvm.fmuladd.f64(double %37, double %40, double %43)
%45 = load double, double* @Poisson.g
%46 = fsub double %44, %45
%47 = tail call double @exp(double %46)
%48 = fmul double %39, %47
%49 = tail call double (...) @uniform()
%50 = fcmp ogt double %49, %48
br i1 %50, label %35, label %51
51: ; preds = %36, %10
%52 = phi double [ %13, %10 ], [ %37, %36 ]
ret double %52
}