#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 */
float distributions_uniform(double, double);
scalar_t__ exp(float);
float distributions_poisson(float theta) {
  float x, m, u;
  x = 1;
  m = (float)exp((float)theta);
  while (m >= 1.0) {
    u = distributions_uniform(0.0, 1.0);
    x = x + 1.0;
    m = m * u;
  }
  return (x);
}


x86 assembly (clang, -O0):
<distributions_poisson>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  0xecb(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
call   1040 <exp@plt>
cvtsi2ss %rax,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xea9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11b0 <distributions_poisson+0x90>
xorps  %xmm0,%xmm0
movsd  0xe94(%rip),%xmm1
call   1030 <distributions_uniform@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe79(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    114e <distributions_poisson+0x2e>
movss  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<distributions_poisson>:
push   %rax
call   1040 <exp@plt>
test   %rax,%rax
jle    1187 <distributions_poisson+0x67>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0xec5(%rip),%xmm1
nopl   0x0(%rax,%rax,1)
movss  %xmm0,(%rsp)
movss  %xmm1,0x4(%rsp)
xorps  %xmm0,%xmm0
movsd  0xeb2(%rip),%xmm1
call   1030 <distributions_uniform@plt>
movss  0x4(%rsp),%xmm1
movss  0xe97(%rip),%xmm3
addss  %xmm3,%xmm1
movss  (%rsp),%xmm2
mulss  %xmm0,%xmm2
movss  %xmm2,(%rsp)
movss  (%rsp),%xmm0
ucomiss %xmm3,%xmm0
jae    1140 <distributions_poisson+0x20>
jmp    118f <distributions_poisson+0x6f>
movss  0xe71(%rip),%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @distributions_poisson(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float %0, float* %2
store float 1.000000e+00, float* %3
%6 = load float, float* %2
%7 = call i64 @exp(float %6)
%8 = sitofp i64 %7 to float
store float %8, float* %4
br label %9
9: ; preds = %13, %1
%10 = load float, float* %4
%11 = fpext float %10 to double
%12 = fcmp oge double %11, 1.000000e+00
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
store float %14, float* %5
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fadd double %16, 1.000000e+00
%18 = fptrunc double %17 to float
store float %18, float* %3
%19 = load float, float* %4
%20 = load float, float* %5
%21 = fmul float %19, %20
store float %21, float* %4
br label %9
22: ; preds = %9
%23 = load float, float* %3
ret float %23
}

LLVM IR (-O2):
define float @distributions_poisson(float %0) {
%2 = tail call i64 @exp(float %0)
%3 = icmp slt i64 %2, 1
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = sitofp i64 %2 to float
br label %6
6: ; preds = %4, %6
%7 = phi float [ %10, %6 ], [ 1.000000e+00, %4 ]
%8 = phi float [ %11, %6 ], [ %5, %4 ]
%9 = tail call float @distributions_uniform(double 0.000000e+00, double 1.000000e+00)
%10 = fadd float %7, 1.000000e+00
%11 = fmul float %8, %9
%12 = fcmp ult float %11, 1.000000e+00
br i1 %12, label %13, label %6
13: ; preds = %6, %1
%14 = phi float [ 1.000000e+00, %1 ], [ %10, %6 ]
ret float %14
}