#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(double);
int mdtst1(int n1, int n2, double xbar1, double xbar2, double pv1, double pv2,
           double al, int *sw, double *u0, double *u) {
  double w1, w2, qn;
  if (n1 < 1 || n2 < 1 || al <= 0.0 || al >= 1.0)
    return 999;
  w1 = xbar1 - xbar2;
  w2 = sqrt(pv1 / n1 + pv2 / n2);
  *u0 = w1 / w2;
  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):
<mdtst1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %r8,-0x50(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     118c <mdtst1+0x6c>
cmpl   $0x1,-0xc(%rbp)
jl     118c <mdtst1+0x6c>
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jae    118c <mdtst1+0x6c>
movsd  -0x38(%rbp),%xmm0
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1198 <mdtst1+0x78>
movl   $0x3e7,-0x4(%rbp)
jmp    127c <mdtst1+0x15c>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
cvtsi2sdl -0xc(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
cmpl   $0x0,(%rax)
jge    1207 <mdtst1+0xe7>
movsd  0xe08(%rip),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1229 <mdtst1+0x109>
movsd  -0x38(%rbp),%xmm0
movsd  0xdf4(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xde0(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1030 <pnorm@plt>
mov    -0x50(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x48(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xdc6(%rip),%xmm1
pand   %xmm1,%xmm0
mov    -0x50(%rbp),%rax
ucomisd (%rax),%xmm0
jb     126b <mdtst1+0x14b>
mov    -0x40(%rbp),%rax
movl   $0x1,(%rax)
jmp    1275 <mdtst1+0x155>
mov    -0x40(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mdtst1>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
ucomisd 0xecf(%rip),%xmm4
mov    $0x3e7,%eax
jae    11fc <mdtst1+0xdc>
test   %edi,%edi
jle    11fc <mdtst1+0xdc>
test   %esi,%esi
jle    11fc <mdtst1+0xdc>
movapd %xmm0,%xmm6
xorpd  %xmm0,%xmm0
ucomisd %xmm4,%xmm0
jae    11fc <mdtst1+0xdc>
mov    %r8,%r15
mov    %rcx,%rbx
mov    %rdx,%r14
cvtsi2sd %edi,%xmm5
subsd  %xmm1,%xmm6
divsd  %xmm5,%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
divsd  %xmm1,%xmm3
addsd  %xmm2,%xmm3
ucomisd %xmm0,%xmm3
jb     1191 <mdtst1+0x71>
xorps  %xmm0,%xmm0
sqrtsd %xmm3,%xmm0
jmp    11b0 <mdtst1+0x90>
movapd %xmm3,%xmm0
movsd  %xmm4,0x8(%rsp)
movsd  %xmm6,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm6
movsd  0x8(%rsp),%xmm4
divsd  %xmm0,%xmm6
movsd  %xmm6,(%rbx)
cmpl   $0x0,(%r14)
movsd  0xe3c(%rip),%xmm0
js     11d4 <mdtst1+0xb4>
mulsd  0xe3a(%rip),%xmm4
addsd  %xmm4,%xmm0
jmp    11d8 <mdtst1+0xb8>
subsd  %xmm4,%xmm0
call   1030 <pnorm@plt>
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm1
andpd  0xe22(%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 @mdtst1(i32 %0, i32 %1, double %2, double %3, double %4, double %5, double %6, i32* %7, double* %8, double* %9) {
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca i32*
%20 = alloca double*
%21 = alloca double*
%22 = alloca double
%23 = alloca double
%24 = alloca double
store i32 %0, i32* %12
store i32 %1, i32* %13
store double %2, double* %14
store double %3, double* %15
store double %4, double* %16
store double %5, double* %17
store double %6, double* %18
store i32* %7, i32** %19
store double* %8, double** %20
store double* %9, double** %21
%25 = load i32, i32* %12
%26 = icmp slt i32 %25, 1
br i1 %26, label %36, label %27
27: ; preds = %10
%28 = load i32, i32* %13
%29 = icmp slt i32 %28, 1
br i1 %29, label %36, label %30
30: ; preds = %27
%31 = load double, double* %18
%32 = fcmp ole double %31, 0.000000e+00
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load double, double* %18
%35 = fcmp oge double %34, 1.000000e+00
br i1 %35, label %36, label %37
36: ; preds = %33, %30, %27, %10
store i32 999, i32* %11
br label %79
37: ; preds = %33
%38 = load double, double* %14
%39 = load double, double* %15
%40 = fsub double %38, %39
store double %40, double* %22
%41 = load double, double* %16
%42 = load i32, i32* %12
%43 = sitofp i32 %42 to double
%44 = fdiv double %41, %43
%45 = load double, double* %17
%46 = load i32, i32* %13
%47 = sitofp i32 %46 to double
%48 = fdiv double %45, %47
%49 = fadd double %44, %48
%50 = call double @sqrt(double %49)
store double %50, double* %23
%51 = load double, double* %22
%52 = load double, double* %23
%53 = fdiv double %51, %52
%54 = load double*, double** %20
store double %53, double* %54
%55 = load i32*, i32** %19
%56 = load i32, i32* %55
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %37
%59 = load double, double* %18
%60 = fsub double 1.000000e+00, %59
store double %60, double* %24
br label %64
61: ; preds = %37
%62 = load double, double* %18
%63 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %62, double 1.000000e+00)
store double %63, double* %24
br label %64
64: ; preds = %61, %58
%65 = load double, double* %24
%66 = call double @pnorm(double %65)
%67 = load double*, double** %21
store double %66, double* %67
%68 = load double*, double** %20
%69 = load double, double* %68
%70 = call double @llvm.fabs.f64(double %69)
%71 = load double*, double** %21
%72 = load double, double* %71
%73 = fcmp oge double %70, %72
br i1 %73, label %74, label %76
74: ; preds = %64
%75 = load i32*, i32** %19
store i32 1, i32* %75
br label %78
76: ; preds = %64
%77 = load i32*, i32** %19
store i32 0, i32* %77
br label %78
78: ; preds = %76, %74
store i32 0, i32* %11
br label %79
79: ; preds = %78, %36
%80 = load i32, i32* %11
ret i32 %80
}

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