#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 pt(double, int);
double sqrt(double);
int rttst(int n, double r0, double al, int *sw, double *t0, double *t) {
  if (n < 2 || al <= 0.0 || al >= 1.0 || fabs(r0) >= 1.0)
    return 999;
  n -= 2;
  *t0 = r0 * sqrt((double)n) / sqrt(1.0 - r0 * r0);
  *t = pt(al, n);
  if (fabs(*t0) >= *t)
    *sw = 1;
  else
    *sw = 0;
  return 0;
}


x86 assembly (clang, -O0):
<rttst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1192 <rttst+0x72>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    1192 <rttst+0x72>
movsd  -0x18(%rbp),%xmm0
movsd  0xe9a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jae    1192 <rttst+0x72>
movsd  -0x10(%rbp),%xmm0
movaps 0xe94(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe78(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     119e <rttst+0x7e>
movl   $0x3e7,-0x4(%rbp)
jmp    126c <rttst+0x14c>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe07(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%edi
call   1030 <pt@plt>
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xdd6(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x30(%rbp),%rax
ucomisd (%rax),%xmm0
jb     125b <rttst+0x13b>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    1265 <rttst+0x145>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rttst>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    $0x3e7,%eax
ucomisd 0xed9(%rip),%xmm1
jae    121f <rttst+0xff>
mov    %edi,%ebp
cmp    $0x2,%edi
jl     121f <rttst+0xff>
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    121f <rttst+0xff>
movapd 0xe9e(%rip),%xmm0
andpd  %xmm2,%xmm0
ucomisd 0xea2(%rip),%xmm0
jae    121f <rttst+0xff>
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r14
add    $0xfffffffe,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm0
movsd  %xmm1,0x8(%rsp)
jb     119d <rttst+0x7d>
sqrtsd %xmm0,%xmm3
jmp    11b6 <rttst+0x96>
movapd %xmm2,0x10(%rsp)
call   1040 <sqrt@plt>
xorpd  %xmm4,%xmm4
movapd 0x10(%rsp),%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm2,%xmm3
mulsd  %xmm2,%xmm2
movsd  0xe4a(%rip),%xmm0
subsd  %xmm2,%xmm0
ucomisd %xmm4,%xmm0
jb     11d6 <rttst+0xb6>
sqrtsd %xmm0,%xmm0
jmp    11e7 <rttst+0xc7>
movsd  %xmm3,0x10(%rsp)
call   1040 <sqrt@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm3
movsd  %xmm3,(%rbx)
movapd %xmm1,%xmm0
mov    %ebp,%edi
call   1030 <pt@plt>
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm1
andpd  0xdef(%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 @rttst(i32 %0, double %1, double %2, i32* %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca i32*
%12 = alloca double*
%13 = alloca double*
store i32 %0, i32* %8
store double %1, double* %9
store double %2, double* %10
store i32* %3, i32** %11
store double* %4, double** %12
store double* %5, double** %13
%14 = load i32, i32* %8
%15 = icmp slt i32 %14, 2
br i1 %15, label %26, label %16
16: ; preds = %6
%17 = load double, double* %10
%18 = fcmp ole double %17, 0.000000e+00
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = load double, double* %10
%21 = fcmp oge double %20, 1.000000e+00
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = load double, double* %9
%24 = call double @llvm.fabs.f64(double %23)
%25 = fcmp oge double %24, 1.000000e+00
br i1 %25, label %26, label %27
26: ; preds = %22, %19, %16, %6
store i32 999, i32* %7
br label %57
27: ; preds = %22
%28 = load i32, i32* %8
%29 = sub nsw i32 %28, 2
store i32 %29, i32* %8
%30 = load double, double* %9
%31 = load i32, i32* %8
%32 = sitofp i32 %31 to double
%33 = call double @sqrt(double %32)
%34 = fmul double %30, %33
%35 = load double, double* %9
%36 = load double, double* %9
%37 = fneg double %35
%38 = call double @llvm.fmuladd.f64(double %37, double %36, double 1.000000e+00)
%39 = call double @sqrt(double %38)
%40 = fdiv double %34, %39
%41 = load double*, double** %12
store double %40, double* %41
%42 = load double, double* %10
%43 = load i32, i32* %8
%44 = call double @pt(double %42, i32 %43)
%45 = load double*, double** %13
store double %44, double* %45
%46 = load double*, double** %12
%47 = load double, double* %46
%48 = call double @llvm.fabs.f64(double %47)
%49 = load double*, double** %13
%50 = load double, double* %49
%51 = fcmp oge double %48, %50
br i1 %51, label %52, label %54
52: ; preds = %27
%53 = load i32*, i32** %11
store i32 1, i32* %53
br label %56
54: ; preds = %27
%55 = load i32*, i32** %11
store i32 0, i32* %55
br label %56
56: ; preds = %54, %52
store i32 0, i32* %7
br label %57
57: ; preds = %56, %26
%58 = load i32, i32* %7
ret i32 %58
}

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