#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 fabs(double);
double log(double);
double pnorm(double);
double sqrt(double);
int rptst(int n, double r0, double rp, double al, int *sw, double *u0,
          double *u) {
  double w1, w2;
  if (n < 3 || al <= 0.0 || al >= 1.0 || fabs(r0) >= 1.0 || fabs(rp) >= 1.0)
    return 999;
  w1 = 0.5 * log((1.0 + r0) / (1.0 - r0));
  w2 = 0.5 * log((1.0 + rp) / (1.0 - rp));
  *u0 = (w1 - w2) * sqrt((double)(n - 3));
  *u = pnorm(1.0 - 0.5 * al);
  if (fabs(*u0) >= *u)
    *sw = 1;
  else
    *sw = 0;
  return 0;
}


x86 assembly (clang, -O0):
<rptst>:
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)
cmpl   $0x3,-0x8(%rbp)
jl     11c9 <rptst+0x99>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jae    11c9 <rptst+0x99>
movsd  -0x20(%rbp),%xmm0
movsd  0xe85(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    11c9 <rptst+0x99>
movsd  -0x10(%rbp),%xmm0
movaps 0xe8f(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe63(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    11c9 <rptst+0x99>
movsd  -0x18(%rbp),%xmm0
movaps 0xe6d(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe41(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11d5 <rptst+0xa5>
movl   $0x3e7,-0x4(%rbp)
jmp    12e0 <rptst+0x1b0>
movsd  0xe23(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  0xe16(%rip),%xmm1
subsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe0d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdec(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xddf(%rip),%xmm1
subsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdd6(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
cvtsi2sd %eax,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
movsd  0xd86(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd72(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <pnorm@plt>
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xd72(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x38(%rbp),%rax
ucomisd (%rax),%xmm0
jb     12cf <rptst+0x19f>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
jmp    12d9 <rptst+0x1a9>
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):
<rptst>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    $0x3e7,%eax
ucomisd 0xec9(%rip),%xmm2
jae    1278 <rptst+0x148>
mov    %edi,%ebp
cmp    $0x3,%edi
jl     1278 <rptst+0x148>
xorpd  %xmm3,%xmm3
ucomisd %xmm2,%xmm3
jae    1278 <rptst+0x148>
movapd 0xe92(%rip),%xmm4
movapd %xmm0,%xmm3
andpd  %xmm4,%xmm3
ucomisd 0xe92(%rip),%xmm3
jae    1278 <rptst+0x148>
andpd  %xmm1,%xmm4
ucomisd 0xe80(%rip),%xmm4
jae    1278 <rptst+0x148>
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r14
movsd  %xmm2,0x8(%rsp)
movsd  0xe63(%rip),%xmm3
movapd %xmm3,%xmm2
subsd  %xmm0,%xmm2
addsd  %xmm3,%xmm0
divsd  %xmm2,%xmm0
movapd %xmm1,0x10(%rsp)
call   1040 <log@plt>
mulsd  0xe48(%rip),%xmm0
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm2
movapd %xmm2,%xmm0
movsd  0xe29(%rip),%xmm1
addsd  %xmm1,%xmm0
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movapd %xmm0,%xmm1
mulsd  0xe14(%rip),%xmm1
add    $0xfffffffd,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  (%rsp),%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     122c <rptst+0xfc>
sqrtsd %xmm0,%xmm0
jmp    1231 <rptst+0x101>
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
mulsd  0xdd8(%rip),%xmm1
addsd  0xdc0(%rip),%xmm1
movapd %xmm1,%xmm0
call   1030 <pnorm@plt>
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm1
andpd  0xd96(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setae  %al
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rptst(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
%17 = 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
%18 = load i32, i32* %9
%19 = icmp slt i32 %18, 3
br i1 %19, label %34, label %20
20: ; preds = %7
%21 = load double, double* %12
%22 = fcmp ole double %21, 0.000000e+00
br i1 %22, label %34, label %23
23: ; preds = %20
%24 = load double, double* %12
%25 = fcmp oge double %24, 1.000000e+00
br i1 %25, label %34, label %26
26: ; preds = %23
%27 = load double, double* %10
%28 = call double @llvm.fabs.f64(double %27)
%29 = fcmp oge double %28, 1.000000e+00
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load double, double* %11
%32 = call double @llvm.fabs.f64(double %31)
%33 = fcmp oge double %32, 1.000000e+00
br i1 %33, label %34, label %35
34: ; preds = %30, %26, %23, %20, %7
store i32 999, i32* %8
br label %74
35: ; preds = %30
%36 = load double, double* %10
%37 = fadd double 1.000000e+00, %36
%38 = load double, double* %10
%39 = fsub double 1.000000e+00, %38
%40 = fdiv double %37, %39
%41 = call double @log(double %40)
%42 = fmul double 5.000000e-01, %41
store double %42, double* %16
%43 = load double, double* %11
%44 = fadd double 1.000000e+00, %43
%45 = load double, double* %11
%46 = fsub double 1.000000e+00, %45
%47 = fdiv double %44, %46
%48 = call double @log(double %47)
%49 = fmul double 5.000000e-01, %48
store double %49, double* %17
%50 = load double, double* %16
%51 = load double, double* %17
%52 = fsub double %50, %51
%53 = load i32, i32* %9
%54 = sub nsw i32 %53, 3
%55 = sitofp i32 %54 to double
%56 = call double @sqrt(double %55)
%57 = fmul double %52, %56
%58 = load double*, double** %14
store double %57, double* %58
%59 = load double, double* %12
%60 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %59, double 1.000000e+00)
%61 = call double @pnorm(double %60)
%62 = load double*, double** %15
store double %61, double* %62
%63 = load double*, double** %14
%64 = load double, double* %63
%65 = call double @llvm.fabs.f64(double %64)
%66 = load double*, double** %15
%67 = load double, double* %66
%68 = fcmp oge double %65, %67
br i1 %68, label %69, label %71
69: ; preds = %35
%70 = load i32*, i32** %13
store i32 1, i32* %70
br label %73
71: ; preds = %35
%72 = load i32*, i32** %13
store i32 0, i32* %72
br label %73
73: ; preds = %71, %69
store i32 0, i32* %8
br label %74
74: ; preds = %73, %34
%75 = load i32, i32* %8
ret i32 %75
}

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