#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(float);
float floor(float);
float gammln(float);
float log(float);
double ran3(long *);
float sqrt(double);
float tan(double);
double poisdev(float xm, long *idum) {
  static float sq, alxm, G, oldm = -(1.0);
  float em, t, y;
  if (xm < 12.0) {
    if (xm != oldm) {
      oldm = xm;
      G = exp(-xm);
    }
    em = -1;
    t = 1.0;
    do {
      ++em;
      t *= ran3(idum);
    } while (t > G);
  } else {
    if (xm != oldm) {
      oldm = xm;
      sq = sqrt(2.0 * xm);
      alxm = log(xm);
      G = xm * alxm - gammln(xm + 1.0);
    }
    do {
      do {
        y = tan(3.141592654 * ran3(idum));
        em = sq * y + xm;
      } while (em < 0.0);
      em = floor(em);
      t = 0.9 * (1.0 + y * y) * exp(em * alxm - gammln(em + 1.0) - G);
    } while (ran3(idum) > t);
  }
  return em;
}


x86 assembly (clang, -O0):
<poisdev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
mov    %rdi,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe6e(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    124e <poisdev+0xde>
movss  -0x4(%rbp),%xmm0
ucomiss 0x2eb0(%rip),%xmm0
jne    11b9 <poisdev+0x49>
jp     11b9 <poisdev+0x49>
jmp    11e9 <poisdev+0x79>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,0x2e92(%rip)
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
call   1030 <exp@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x2e7f(%rip)
movss  0xe3b(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe2a(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe1d(%rip),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <ran3@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
ucomiss 0x2e25(%rip),%xmm0
ja     1203 <poisdev+0x93>
jmp    1440 <poisdev+0x2d0>
movss  -0x4(%rbp),%xmm0
ucomiss 0x2dfe(%rip),%xmm0
jne    126b <poisdev+0xfb>
jp     126b <poisdev+0xfb>
jmp    130b <poisdev+0x19b>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,0x2de0(%rip)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xd87(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movss  %xmm0,0x2dc6(%rip)
movss  -0x4(%rbp),%xmm0
call   1060 <log@plt>
movss  %xmm0,0x2db8(%rip)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0x2da6(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd34(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1080 <gammln@plt>
movss  -0x24(%rbp),%xmm2
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,0x2d5d(%rip)
jmp    1310 <poisdev+0x1a0>
jmp    1315 <poisdev+0x1a5>
mov    -0x10(%rbp),%rdi
call   1050 <ran3@plt>
movaps %xmm0,%xmm1
movsd  0xcef(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <tan@plt>
movss  %xmm0,-0x1c(%rbp)
movss  0x2d21(%rip),%xmm0
movss  -0x1c(%rbp),%xmm2
movss  -0x4(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
ja     1315 <poisdev+0x1a5>
movss  -0x14(%rbp),%xmm0
call   1090 <floor@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc77(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xc83(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  0x2cac(%rip),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc3a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1080 <gammln@plt>
movss  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
subss  0x2c63(%rip),%xmm0
call   1030 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <ran3@plt>
movss  -0x18(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
ja     1310 <poisdev+0x1a0>
jmp    1440 <poisdev+0x2d0>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<poisdev>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
movaps %xmm0,%xmm1
movss  0xe7d(%rip),%xmm0
ucomiss %xmm1,%xmm0
movss  0x2eca(%rip),%xmm0
jbe    1212 <poisdev+0xa2>
ucomiss %xmm1,%xmm0
jne    119b <poisdev+0x2b>
jnp    11be <poisdev+0x4e>
movss  %xmm1,0x2eb5(%rip)
xorps  0xe86(%rip),%xmm1
movaps %xmm1,%xmm0
call   1040 <exp@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x2eaa(%rip)
movss  0xe42(%rip),%xmm0
movss  0xe36(%rip),%xmm1
xchg   %ax,%ax
movss  %xmm1,0x20(%rsp)
addss  0xe26(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
mov    %rbx,%rdi
call   1060 <ran3@plt>
movss  0x20(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
cvtsd2ss %xmm1,%xmm1
ucomiss 0x2e5d(%rip),%xmm1
ja     11d0 <poisdev+0x60>
jmp    1369 <poisdev+0x1f9>
ucomiss %xmm1,%xmm0
movaps %xmm1,0x20(%rsp)
jne    121e <poisdev+0xae>
jnp    1290 <poisdev+0x120>
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movss  %xmm1,0x2e2b(%rip)
addsd  %xmm0,%xmm0
call   1080 <sqrt@plt>
movss  %xmm0,0x2e22(%rip)
movaps 0x20(%rsp),%xmm0
call   1070 <log@plt>
movss  %xmm0,0xc(%rsp)
movss  %xmm0,0x2e0e(%rip)
movss  0xda6(%rip),%xmm0
addss  0x20(%rsp),%xmm0
call   1090 <gammln@plt>
movss  0xc(%rsp),%xmm1
mulss  0x20(%rsp),%xmm1
subss  %xmm0,%xmm1
movss  %xmm1,0x2de7(%rip)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <ran3@plt>
mulsd  0xd70(%rip),%xmm0
call   1050 <tan@plt>
movapd %xmm0,%xmm2
movss  0x2daf(%rip),%xmm0
mulss  %xmm2,%xmm0
addss  0x20(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
ja     1290 <poisdev+0x120>
movss  %xmm2,0xc(%rsp)
call   1030 <floorf@plt>
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
mulss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
addsd  0xd31(%rip),%xmm0
mulsd  0xd31(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movaps %xmm1,%xmm0
addss  0xd04(%rip),%xmm0
movss  0x2d5c(%rip),%xmm2
movss  %xmm1,0xc(%rsp)
mulss  %xmm1,%xmm2
movss  %xmm2,0x1c(%rsp)
call   1090 <gammln@plt>
movss  0x1c(%rsp),%xmm1
subss  %xmm0,%xmm1
subss  0x2d39(%rip),%xmm1
movaps %xmm1,%xmm0
call   1040 <exp@plt>
mulsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
call   1060 <ran3@plt>
movss  0x10(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
ja     1290 <poisdev+0x120>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

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

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