#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(int);
int mtst2(int n, double xbar, double pm, double uv, double al, int *sw,
          double *t0, double *t) {
  double qt;
  if (n < 1 || al <= 0.0 || al >= 0.5)
    return 999;
  *t0 = (xbar - pm) * sqrt(n / uv);
  if (*sw < 0)
    qt = 2.0 * al;
  else
    qt = al;
  n--;
  *t = pt(qt, n);
  if (fabs(*t0) >= *t)
    *sw = 1;
  else
    *sw = 0;
  return 0;
}


x86 assembly (clang, -O0):
<mtst2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
mov    %rcx,-0x40(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     117a <mtst2+0x5a>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jae    117a <mtst2+0x5a>
movsd  -0x28(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1186 <mtst2+0x66>
movl   $0x3e7,-0x4(%rbp)
jmp    1249 <mtst2+0x129>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x38(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
cmpl   $0x0,(%rax)
jge    11e0 <mtst2+0xc0>
movsd  0xe37(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11ea <mtst2+0xca>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
movsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%edi
call   1030 <pt@plt>
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xdf9(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x40(%rbp),%rax
ucomisd (%rax),%xmm0
jb     1238 <mtst2+0x118>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
jmp    1242 <mtst2+0x122>
mov    -0x30(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtst2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
ucomisd 0xece(%rip),%xmm3
mov    $0x3e7,%eax
jae    11c9 <mtst2+0xa9>
mov    %edi,%ebp
test   %edi,%edi
jle    11c9 <mtst2+0xa9>
xorpd  %xmm4,%xmm4
ucomisd %xmm3,%xmm4
jae    11c9 <mtst2+0xa9>
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r14
movsd  %xmm3,0x8(%rsp)
xorps  %xmm3,%xmm3
cvtsi2sd %ebp,%xmm3
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
divsd  %xmm2,%xmm3
cvttsd2si %xmm3,%edi
call   1040 <sqrt@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx)
cmpl   $0x0,(%r14)
js     1196 <mtst2+0x76>
movsd  0x8(%rsp),%xmm0
jmp    11a0 <mtst2+0x80>
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
add    $0xffffffff,%ebp
mov    %ebp,%edi
call   1030 <pt@plt>
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm1
andpd  0xe55(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setae  %al
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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