#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 abs(double);
double pnorm(double);
double sqrt(double);
int nbptst(int n, double ps, double pp, double al, int *sw, double *u0,
           double *u) {
  double qn;
  if (n < 1 || ps <= 0.0,
      ps >= 1.0 || pp <= 0. || pp >= 1.0 || al <= 0.0 || al >= 1.0)
    return 999;
  *u0 = (ps - pp) / sqrt(pp * (1.0 - pp) / n);
  if (*sw < 0)
    qn = 1.0 - al;
  else
    qn = 1.0 - 0.5 * al;
  *u = pnorm(qn);
  if (abs(*u0) >= *u)
    *sw = 1;
  else
    *sw = 0;
  return 0;
}


x86 assembly (clang, -O0):
<nbptst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x41(%rbp)
jl     1173 <nbptst+0x43>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
setae  %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
movsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
movsd  0xe7b(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x42(%rbp)
jae    11eb <nbptst+0xbb>
mov    $0x1,%al
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
mov    %al,-0x42(%rbp)
jae    11eb <nbptst+0xbb>
movsd  -0x18(%rbp),%xmm0
mov    $0x1,%al
movsd  0xe4c(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x42(%rbp)
jae    11eb <nbptst+0xbb>
mov    $0x1,%al
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
mov    %al,-0x42(%rbp)
jae    11eb <nbptst+0xbb>
movsd  -0x20(%rbp),%xmm0
movsd  0xe1f(%rip),%xmm1
ucomisd %xmm1,%xmm0
setae  %al
mov    %al,-0x42(%rbp)
mov    -0x42(%rbp),%al
test   $0x1,%al
jne    11fb <nbptst+0xcb>
jmp    1207 <nbptst+0xd7>
movl   $0x3e7,-0x4(%rbp)
jmp    12e1 <nbptst+0x1b1>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xddd(%rip),%xmm1
subsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jge    1272 <nbptst+0x142>
movsd  0xd9d(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1294 <nbptst+0x164>
movsd  -0x20(%rbp),%xmm0
movsd  0xd89(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd75(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <pnorm@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <abs@plt>
mov    -0x38(%rbp),%rax
ucomisd (%rax),%xmm0
jb     12d0 <nbptst+0x1a0>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
jmp    12da <nbptst+0x1aa>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nbptst>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
ucomisd 0xebf(%rip),%xmm2
mov    $0x3e7,%eax
jae    1226 <nbptst+0xf6>
movapd %xmm0,%xmm5
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jae    1226 <nbptst+0xf6>
ucomisd 0xe9a(%rip),%xmm1
jae    1226 <nbptst+0xf6>
ucomisd 0xe8c(%rip),%xmm5
jae    1226 <nbptst+0xf6>
xorpd  %xmm4,%xmm4
ucomisd %xmm1,%xmm4
jae    1226 <nbptst+0xf6>
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r14
subsd  %xmm1,%xmm5
movsd  0xe63(%rip),%xmm6
movapd %xmm6,%xmm0
subsd  %xmm1,%xmm0
cvtsi2sd %edi,%xmm3
mulsd  %xmm1,%xmm0
divsd  %xmm3,%xmm0
ucomisd %xmm4,%xmm0
jb     11bd <nbptst+0x8d>
sqrtsd %xmm0,%xmm0
jmp    11e0 <nbptst+0xb0>
movsd  %xmm2,0x8(%rsp)
movsd  %xmm5,(%rsp)
call   1050 <sqrt@plt>
movsd  0xe2b(%rip),%xmm6
movsd  (%rsp),%xmm5
movsd  0x8(%rsp),%xmm2
divsd  %xmm0,%xmm5
movsd  %xmm5,(%rbx)
cmpl   $0x0,(%r14)
js     11fc <nbptst+0xcc>
mulsd  0xe12(%rip),%xmm2
addsd  %xmm2,%xmm6
jmp    1200 <nbptst+0xd0>
subsd  %xmm2,%xmm6
movapd %xmm6,%xmm0
call   1040 <pnorm@plt>
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm0
call   1030 <abs@plt>
xor    %eax,%eax
ucomisd (%r15),%xmm0
setae  %al
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @nbptst(i32 %0, double %1, double %2, double %3, i32* %4, double* %5, double* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double
store i32 %0, i32* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store i32* %4, i32** %13
store double* %5, double** %14
store double* %6, double** %15
%17 = load i32, i32* %9
%18 = icmp slt i32 %17, 1
br i1 %18, label %22, label %19
19: ; preds = %7
%20 = load double, double* %10
%21 = fcmp ole double %20, 0.000000e+00
br label %22
22: ; preds = %19, %7
%23 = phi i1 [ true, %7 ], [ %21, %19 ]
%24 = zext i1 %23 to i32
%25 = load double, double* %10
%26 = fcmp oge double %25, 1.000000e+00
br i1 %26, label %39, label %27
27: ; preds = %22
%28 = load double, double* %11
%29 = fcmp ole double %28, 0.000000e+00
br i1 %29, label %39, label %30
30: ; preds = %27
%31 = load double, double* %11
%32 = fcmp oge double %31, 1.000000e+00
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = load double, double* %12
%35 = fcmp ole double %34, 0.000000e+00
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load double, double* %12
%38 = fcmp oge double %37, 1.000000e+00
br label %39
39: ; preds = %36, %33, %30, %27, %22
%40 = phi i1 [ true, %33 ], [ true, %30 ], [ true, %27 ], [ true, %22 ], [ %38, %36 ]
br i1 %40, label %41, label %42
41: ; preds = %39
store i32 999, i32* %8
br label %80
42: ; preds = %39
%43 = load double, double* %10
%44 = load double, double* %11
%45 = fsub double %43, %44
%46 = load double, double* %11
%47 = load double, double* %11
%48 = fsub double 1.000000e+00, %47
%49 = fmul double %46, %48
%50 = load i32, i32* %9
%51 = sitofp i32 %50 to double
%52 = fdiv double %49, %51
%53 = call double @sqrt(double %52)
%54 = fdiv double %45, %53
%55 = load double*, double** %14
store double %54, double* %55
%56 = load i32*, i32** %13
%57 = load i32, i32* %56
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %42
%60 = load double, double* %12
%61 = fsub double 1.000000e+00, %60
store double %61, double* %16
br label %65
62: ; preds = %42
%63 = load double, double* %12
%64 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %63, double 1.000000e+00)
store double %64, double* %16
br label %65
65: ; preds = %62, %59
%66 = load double, double* %16
%67 = call double @pnorm(double %66)
%68 = load double*, double** %15
store double %67, double* %68
%69 = load double*, double** %14
%70 = load double, double* %69
%71 = call double @abs(double %70)
%72 = load double*, double** %15
%73 = load double, double* %72
%74 = fcmp oge double %71, %73
br i1 %74, label %75, label %77
75: ; preds = %65
%76 = load i32*, i32** %13
store i32 1, i32* %76
br label %79
77: ; preds = %65
%78 = load i32*, i32** %13
store i32 0, i32* %78
br label %79
79: ; preds = %77, %75
store i32 0, i32* %8
br label %80
80: ; preds = %79, %41
%81 = load i32, i32* %8
ret i32 %81
}

LLVM IR (-O2):
define i32 @nbptst(i32 %0, double %1, double %2, double %3, i32* nocapture %4, double* nocapture %5, double* nocapture %6) {
%8 = fcmp oge double %1, 1.000000e+00
%9 = fcmp ole double %2, 0.000000e+00
%10 = or i1 %8, %9
%11 = fcmp oge double %2, 1.000000e+00
%12 = or i1 %11, %10
%13 = fcmp ole double %3, 0.000000e+00
%14 = or i1 %13, %12
%15 = fcmp oge double %3, 1.000000e+00
%16 = or i1 %15, %14
br i1 %16, label %36, label %17
17: ; preds = %7
%18 = fsub double %1, %2
%19 = fsub double 1.000000e+00, %2
%20 = fmul double %19, %2
%21 = sitofp i32 %0 to double
%22 = fdiv double %20, %21
%23 = tail call double @sqrt(double %22)
%24 = fdiv double %18, %23
store double %24, double* %5
%25 = load i32, i32* %4
%26 = icmp slt i32 %25, 0
%27 = fsub double 1.000000e+00, %3
%28 = tail call double @llvm.fmuladd.f64(double %3, double -5.000000e-01, double 1.000000e+00)
%29 = select i1 %26, double %27, double %28
%30 = tail call double @pnorm(double %29)
store double %30, double* %6
%31 = load double, double* %5
%32 = tail call double @abs(double %31)
%33 = load double, double* %6
%34 = fcmp oge double %32, %33
%35 = zext i1 %34 to i32
store i32 %35, i32* %4
br label %36
36: ; preds = %7, %17
%37 = phi i32 [ 0, %17 ], [ 999, %7 ]
ret i32 %37
}