#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 pow(int, int);
double GetPlayerProbability(int players, double p, int winner) {
  if (((p) > -0.000001 && ((p) < 0.000001)))
    return 0.0000;
  if (winner == 1)
    return p / (1 - pow(1 - p, players));
  else
    return (pow(1 - p, players - 1) * p) / (1 - pow(1 - p, players));
}


x86 assembly (clang, -O0):
<GetPlayerProbability>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xed0(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115a <GetPlayerProbability+0x4a>
movsd  0xec6(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    115a <GetPlayerProbability+0x4a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1205 <GetPlayerProbability+0xf5>
cmpl   $0x1,-0x1c(%rbp)
jne    11a7 <GetPlayerProbability+0x97>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe9a(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    -0xc(%rbp),%esi
call   1030 <pow@plt>
movsd  -0x28(%rbp),%xmm0
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1205 <GetPlayerProbability+0xf5>
movsd  0xe61(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
call   1030 <pow@plt>
cvtsi2sd %eax,%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe37(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    -0xc(%rbp),%esi
call   1030 <pow@plt>
movsd  -0x30(%rbp),%xmm0
mov    %eax,%ecx
mov    $0x1,%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetPlayerProbability>:
push   %rbp
push   %rbx
push   %rax
movapd %xmm0,%xmm2
mov    %edi,%ebx
ucomisd 0xedf(%rip),%xmm0
jbe    1135 <GetPlayerProbability+0x25>
xorpd  %xmm0,%xmm0
movsd  0xed9(%rip),%xmm1
ucomisd %xmm2,%xmm1
ja     1192 <GetPlayerProbability+0x82>
movsd  0xed3(%rip),%xmm0
subsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ebp
cmp    $0x1,%esi
movsd  %xmm2,(%rsp)
je     116e <GetPlayerProbability+0x5e>
lea    -0x1(%rbx),%esi
mov    %ebp,%edi
call   1030 <pow@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <pow@plt>
mov    $0x1,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define double @GetPlayerProbability(i32 %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
store i32 %0, i32* %5
store double %1, double* %6
store i32 %2, i32* %7
%8 = load double, double* %6
%9 = fcmp ogt double %8, 0xBEB0C6F7A0B5ED8D
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load double, double* %6
%12 = fcmp olt double %11, 0x3EB0C6F7A0B5ED8D
br i1 %12, label %13, label %14
13: ; preds = %10
store double 0.000000e+00, double* %4
br label %45
14: ; preds = %10, %3
%15 = load i32, i32* %7
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load double, double* %6
%19 = load double, double* %6
%20 = fsub double 1.000000e+00, %19
%21 = fptosi double %20 to i32
%22 = load i32, i32* %5
%23 = call i32 @pow(i32 %21, i32 %22)
%24 = sub nsw i32 1, %23
%25 = sitofp i32 %24 to double
%26 = fdiv double %18, %25
store double %26, double* %4
br label %45
27: ; preds = %14
%28 = load double, double* %6
%29 = fsub double 1.000000e+00, %28
%30 = fptosi double %29 to i32
%31 = load i32, i32* %5
%32 = sub nsw i32 %31, 1
%33 = call i32 @pow(i32 %30, i32 %32)
%34 = sitofp i32 %33 to double
%35 = load double, double* %6
%36 = fmul double %34, %35
%37 = load double, double* %6
%38 = fsub double 1.000000e+00, %37
%39 = fptosi double %38 to i32
%40 = load i32, i32* %5
%41 = call i32 @pow(i32 %39, i32 %40)
%42 = sub nsw i32 1, %41
%43 = sitofp i32 %42 to double
%44 = fdiv double %36, %43
store double %44, double* %4
br label %45
45: ; preds = %27, %17, %13
%46 = load double, double* %4
ret double %46
}

LLVM IR (-O2):
define double @GetPlayerProbability(i32 %0, double %1, i32 %2) {
%4 = fcmp ogt double %1, 0xBEB0C6F7A0B5ED8D
%5 = fcmp olt double %1, 0x3EB0C6F7A0B5ED8D
%6 = and i1 %4, %5
br i1 %6, label %22, label %7
7: ; preds = %3
%8 = icmp eq i32 %2, 1
%9 = fsub double 1.000000e+00, %1
%10 = fptosi double %9 to i32
br i1 %8, label %16, label %11
11: ; preds = %7
%12 = add nsw i32 %0, -1
%13 = tail call i32 @pow(i32 %10, i32 %12)
%14 = sitofp i32 %13 to double
%15 = fmul double %14, %1
br label %16
16: ; preds = %7, %11
%17 = phi double [ %15, %11 ], [ %1, %7 ]
%18 = tail call i32 @pow(i32 %10, i32 %0)
%19 = sub nsw i32 1, %18
%20 = sitofp i32 %19 to double
%21 = fdiv double %17, %20
br label %22
22: ; preds = %16, %3
%23 = phi double [ 0.000000e+00, %3 ], [ %21, %16 ]
ret double %23
}