#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 pnorm(double);
double sqrt(int);
int mtst1(int n, double xbar, double pm, double pv, double al, int *sw,
          double *u0, double *u) {
  double qn;
  if (n < 1 || al <= 0.0 || al >= 1.0)
    return 999;
  *u0 = (xbar - pm) * sqrt(n / pv);
  if (*sw < 0)
    qn = 1.0 - al;
  else
    qn = 1.0 - 0.5 * al;
  *u = pnorm(qn);
  if (fabs(*u0) >= *u)
    *sw = 1;
  else
    *sw = 0;
  return 0;
}


x86 assembly (clang, -O0):
<mtst1>:
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 <mtst1+0x5a>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jae    117a <mtst1+0x5a>
movsd  -0x28(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1186 <mtst1+0x66>
movl   $0x3e7,-0x4(%rbp)
jmp    1255 <mtst1+0x135>
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 <mtst1+0xc0>
movsd  0xe2f(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1202 <mtst1+0xe2>
movsd  -0x28(%rbp),%xmm0
movsd  0xe1b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe07(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1030 <pnorm@plt>
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x38(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xded(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x40(%rbp),%rax
ucomisd (%rax),%xmm0
jb     1244 <mtst1+0x124>
mov    -0x30(%rbp),%rax
movl   $0x1,(%rax)
jmp    124e <mtst1+0x12e>
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):
<mtst1>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
ucomisd 0xecf(%rip),%xmm3
mov    $0x3e7,%eax
jae    11d2 <mtst1+0xb2>
test   %edi,%edi
jle    11d2 <mtst1+0xb2>
xorpd  %xmm4,%xmm4
ucomisd %xmm3,%xmm4
jae    11d2 <mtst1+0xb2>
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r14
movsd  %xmm3,(%rsp)
xorps  %xmm3,%xmm3
cvtsi2sd %edi,%xmm3
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
divsd  %xmm2,%xmm3
cvttsd2si %xmm3,%edi
call   1040 <sqrt@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx)
cmpl   $0x0,(%r14)
movsd  0xe6c(%rip),%xmm0
js     11a9 <mtst1+0x89>
movsd  (%rsp),%xmm1
mulsd  0xe65(%rip),%xmm1
addsd  %xmm1,%xmm0
jmp    11ae <mtst1+0x8e>
subsd  (%rsp),%xmm0
call   1030 <pnorm@plt>
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm1
andpd  0xe4c(%rip),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setae  %al
mov    %eax,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @mtst1(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, 1.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %24, %21, %8
store i32 999, i32* %9
br label %64
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 = fsub double 1.000000e+00, %44
store double %45, double* %18
br label %49
46: ; preds = %28
%47 = load double, double* %14
%48 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %47, double 1.000000e+00)
store double %48, double* %18
br label %49
49: ; preds = %46, %43
%50 = load double, double* %18
%51 = call double @pnorm(double %50)
%52 = load double*, double** %17
store double %51, double* %52
%53 = load double*, double** %16
%54 = load double, double* %53
%55 = call double @llvm.fabs.f64(double %54)
%56 = load double*, double** %17
%57 = load double, double* %56
%58 = fcmp oge double %55, %57
br i1 %58, label %59, label %61
59: ; preds = %49
%60 = load i32*, i32** %15
store i32 1, i32* %60
br label %63
61: ; preds = %49
%62 = load i32*, i32** %15
store i32 0, i32* %62
br label %63
63: ; preds = %61, %59
store i32 0, i32* %9
br label %64
64: ; preds = %63, %27
%65 = load i32, i32* %9
ret i32 %65
}

LLVM IR (-O2):
define i32 @mtst1(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, 1.000000e+00
%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 = fsub double 1.000000e+00, %4
%24 = tail call double @llvm.fmuladd.f64(double %4, double -5.000000e-01, double 1.000000e+00)
%25 = select i1 %22, double %23, double %24
%26 = tail call double @pnorm(double %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
}