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


x86 assembly (clang, -O0):
<rptst2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     11d6 <rptst2+0xa6>
cmpl   $0x4,-0xc(%rbp)
jl     11d6 <rptst2+0xa6>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jae    11d6 <rptst2+0xa6>
movsd  -0x28(%rbp),%xmm0
movsd  0xe78(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    11d6 <rptst2+0xa6>
movsd  -0x18(%rbp),%xmm0
movaps 0xe82(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe56(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    11d6 <rptst2+0xa6>
movsd  -0x20(%rbp),%xmm0
movaps 0xe60(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe34(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11e2 <rptst2+0xb2>
movl   $0x3e7,-0x4(%rbp)
jmp    1313 <rptst2+0x1e3>
movsd  0xe16(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  0xe09(%rip),%xmm1
subsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe00(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xddf(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xdd2(%rip),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xdc9(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
cvtsi2sd %eax,%xmm1
movsd  0xd8f(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
sub    $0x3,%eax
cvtsi2sd %eax,%xmm2
movsd  0xd79(%rip),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
movsd  0xd53(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd3f(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <pnorm@plt>
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xd3f(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x40(%rbp),%rax
ucomisd (%rax),%xmm0
jb     1302 <rptst2+0x1d2>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
jmp    130c <rptst2+0x1dc>
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rptst2>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    $0x3e7,%eax
ucomisd 0xec7(%rip),%xmm2
jae    12b3 <rptst2+0x183>
mov    %edi,%ebx
cmp    $0x4,%edi
jl     12b3 <rptst2+0x183>
mov    %esi,%ebp
cmp    $0x4,%esi
jl     12b3 <rptst2+0x183>
xorpd  %xmm3,%xmm3
ucomisd %xmm2,%xmm3
jae    12b3 <rptst2+0x183>
movapd 0xe85(%rip),%xmm4
movapd %xmm0,%xmm3
andpd  %xmm4,%xmm3
ucomisd 0xe85(%rip),%xmm3
jae    12b3 <rptst2+0x183>
andpd  %xmm1,%xmm4
ucomisd 0xe73(%rip),%xmm4
jae    12b3 <rptst2+0x183>
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%r14
movsd  %xmm2,0x8(%rsp)
movsd  0xe56(%rip),%xmm3
movapd %xmm3,%xmm2
subsd  %xmm0,%xmm2
addsd  %xmm3,%xmm0
divsd  %xmm2,%xmm0
movapd %xmm1,0x10(%rsp)
call   1040 <log@plt>
mulsd  0xe3b(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xe26(%rip),%xmm1
movapd %xmm1,%xmm0
movapd 0x10(%rsp),%xmm2
subsd  %xmm2,%xmm0
addsd  %xmm1,%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
call   1040 <log@plt>
mulsd  0xe07(%rip),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
add    $0xfffffffd,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xddf(%rip),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
add    $0xfffffffd,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
divsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
movapd %xmm2,%xmm0
jb     125f <rptst2+0x12f>
sqrtsd %xmm0,%xmm0
jmp    1264 <rptst2+0x134>
call   1050 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,(%r12)
mulsd  0xd9f(%rip),%xmm1
addsd  0xd87(%rip),%xmm1
movapd %xmm1,%xmm0
call   1030 <pnorm@plt>
movsd  %xmm0,(%r15)
movsd  (%r12),%xmm1
andpd  0xd5b(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setae  %al
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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