#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 LnGamma(double);
double exp(double);
double floor(double);
double log(double);
double rndu();
double sqrt(int);
double tan(double);
int rndpoisson(double m) {
  static double sq, alm, g, oldm = -1;
  double em, t, y;
  if (m < 12) {
    if (m != oldm) {
      oldm = m;
      g = exp(-m);
    }
    em = -1;
    t = 1;
    for (;;) {
      em++;
      t *= rndu();
      if (t <= g)
        break;
    }
  } else {
    if (m != oldm) {
      oldm = m;
      sq = sqrt(2 * m);
      alm = log(m);
      g = m * alm - LnGamma(m + 1);
    }
    do {
      do {
        y = tan(3.141592654 * rndu());
        em = sq * y + m;
      } while (em < 0);
      em = floor(em);
      t = 0.9 * (1 + y * y) * exp(em * alm - LnGamma(em + 1) - g);
    } while (rndu() > t);
  }
  return ((int)em);
}


x86 assembly (clang, -O0):
<rndpoisson>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xe7b(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1247 <rndpoisson+0xd7>
movsd  -0x8(%rbp),%xmm0
ucomisd 0x2ebb(%rip),%xmm0
jne    11ae <rndpoisson+0x3e>
jp     11ae <rndpoisson+0x3e>
jmp    11e4 <rndpoisson+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 <rndu@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0x2e4a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jb     123d <rndpoisson+0xcd>
jmp    1242 <rndpoisson+0xd2>
jmp    11fe <rndpoisson+0x8e>
jmp    141a <rndpoisson+0x2aa>
movsd  -0x8(%rbp),%xmm0
ucomisd 0x2e04(%rip),%xmm0
jne    1265 <rndpoisson+0xf5>
jp     1265 <rndpoisson+0xf5>
jmp    12ff <rndpoisson+0x18f>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,0x2de6(%rip)
movsd  0xd96(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movsd  %xmm0,0x2dd8(%rip)
movsd  -0x8(%rbp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,0x2dce(%rip)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0x2dbc(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xd47(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
call   1080 <LnGamma@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,0x2d79(%rip)
jmp    1304 <rndpoisson+0x194>
jmp    1309 <rndpoisson+0x199>
mov    $0x0,%al
call   1030 <rndu@plt>
movaps %xmm0,%xmm1
movsd  0xcfd(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <tan@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0x2d37(%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     1309 <rndpoisson+0x199>
movsd  -0x10(%rbp),%xmm0
call   1090 <floor@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xc8d(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  0xc99(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0x2cce(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xc59(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
call   1080 <LnGamma@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  0x2c8b(%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 <rndu@plt>
ucomisd -0x18(%rbp),%xmm0
ja     1304 <rndpoisson+0x194>
jmp    141a <rndpoisson+0x2aa>
cvttsd2si -0x10(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rndpoisson>:
sub    $0x28,%rsp
movsd  0xe84(%rip),%xmm1
ucomisd %xmm0,%xmm1
movsd  0x2ed0(%rip),%xmm1
jbe    11fc <rndpoisson+0x8c>
ucomisd %xmm0,%xmm1
jne    1192 <rndpoisson+0x22>
jnp    11af <rndpoisson+0x3f>
movsd  %xmm0,0x2ebe(%rip)
xorpd  0xe8e(%rip),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,0x2ec9(%rip)
movsd  0xe69(%rip),%xmm0
movsd  0xe49(%rip),%xmm1
nop
movsd  %xmm1,(%rsp)
addsd  0xe3b(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
xor    %eax,%eax
call   1030 <rndu@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x2e8d(%rip),%xmm0
ucomisd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm0
jb     11c0 <rndpoisson+0x50>
jmp    1332 <rndpoisson+0x1c2>
ucomisd %xmm0,%xmm1
movapd %xmm0,0x10(%rsp)
jne    120a <rndpoisson+0x9a>
jnp    1270 <rndpoisson+0x100>
movsd  %xmm0,0x2e46(%rip)
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%edi
call   1070 <sqrt@plt>
movsd  %xmm0,0x2e41(%rip)
movaps 0x10(%rsp),%xmm0
call   1060 <log@plt>
movsd  %xmm0,(%rsp)
movsd  %xmm0,0x2e32(%rip)
movsd  0xdc2(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
call   1080 <LnGamma@plt>
movsd  (%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x2e10(%rip)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <rndu@plt>
mulsd  0xd91(%rip),%xmm0
call   1050 <tan@plt>
movapd %xmm0,%xmm2
movsd  0x2dd8(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     1270 <rndpoisson+0x100>
movsd  %xmm2,(%rsp)
call   1090 <floor@plt>
movapd %xmm0,%xmm2
movsd  (%rsp),%xmm3
mulsd  %xmm3,%xmm3
movsd  0xd45(%rip),%xmm1
addsd  %xmm1,%xmm3
mulsd  0xd49(%rip),%xmm3
movsd  %xmm3,(%rsp)
addsd  %xmm1,%xmm0
movsd  0x2d90(%rip),%xmm1
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x20(%rsp)
call   1080 <LnGamma@plt>
movsd  0x20(%rsp),%xmm1
subsd  %xmm0,%xmm1
subsd  0x2d71(%rip),%xmm1
movapd %xmm1,%xmm0
call   1040 <exp@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rndu@plt>
ucomisd (%rsp),%xmm0
ja     1270 <rndpoisson+0x100>
movsd  0x8(%rsp),%xmm0
cvttsd2si %xmm0,%eax
add    $0x28,%rsp
ret

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

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