#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 */
int /*<<< orphan*/ error(char *);
double pow(int, unsigned int);
double geomcdf(unsigned k, double p) {
  if (p <= 0 || p > 1)
    error("Parameter lambda is smaller than 0.");
  if (k < 0)
    return 0.0;
  return 1 - pow(1 - p, k);
}


x86 assembly (clang, -O0):
<geomcdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    1155 <geomcdf+0x35>
movsd  -0x18(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1161 <geomcdf+0x41>
lea    0xeac(%rip),%rdi
call   1030 <error@plt>
cmpl   $0x0,-0xc(%rbp)
jae    1178 <geomcdf+0x58>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a5 <geomcdf+0x85>
movsd  0xe80(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    -0xc(%rbp),%esi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  0xe64(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geomcdf>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    113b <geomcdf+0x1b>
ucomisd 0xec7(%rip),%xmm0
jbe    1153 <geomcdf+0x33>
lea    0xec6(%rip),%rdi
movsd  %xmm0,0x8(%rsp)
call   1030 <error@plt>
movsd  0x8(%rsp),%xmm0
movsd  0xea5(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edi
mov    %ebx,%esi
call   1040 <pow@plt>
movsd  0xe8e(%rip),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Parameter lambda is smaller than 0.\00"
define double @geomcdf(i32 %0, double %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
%6 = load double, double* %5
%7 = fcmp ole double %6, 0.000000e+00
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load double, double* %5
%10 = fcmp ogt double %9, 1.000000e+00
br i1 %10, label %11, label %13
11: ; preds = %8, %2
%12 = call i32 @error(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = load i32, i32* %4
%15 = icmp ult i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store double 0.000000e+00, double* %3
br label %24
17: ; preds = %13
%18 = load double, double* %5
%19 = fsub double 1.000000e+00, %18
%20 = fptosi double %19 to i32
%21 = load i32, i32* %4
%22 = call double @pow(i32 %20, i32 %21)
%23 = fsub double 1.000000e+00, %22
store double %23, double* %3
br label %24
24: ; preds = %17, %16
%25 = load double, double* %3
ret double %25
}

LLVM IR (-O2):
@.str = [36 x i8] c"Parameter lambda is smaller than 0.\00"
define double @geomcdf(i32 %0, double %1) {
%3 = fcmp ole double %1, 0.000000e+00
%4 = fcmp ogt double %1, 1.000000e+00
%5 = or i1 %3, %4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @error(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = fsub double 1.000000e+00, %1
%10 = fptosi double %9 to i32
%11 = tail call double @pow(i32 %10, i32 %0)
%12 = fsub double 1.000000e+00, %11
ret double %12
}