#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 mdest1(int n1, int n2, double xbar1, double xbar2, double pv1, double pv2,
           double g, double *xl, double *xu) {
  double xb, w;
  if (n1 < 1 || n2 < 1 || g <= 0.0 || g >= 1.0)
    return 999;
  xb = fabs(xbar1 - xbar2);
  w = pnorm((1.0 + g) * 0.5) * sqrt(pv1 / (double)n1 + pv2 / (double)n2);
  *xl = xb - w;
  *xu = xb + w;
  return 0;
}


x86 assembly (clang, -O0):
<mdest1>:
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)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
mov    %rdx,-0x40(%rbp)
mov    %rcx,-0x48(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     1188 <mdest1+0x68>
cmpl   $0x1,-0xc(%rbp)
jl     1188 <mdest1+0x68>
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jae    1188 <mdest1+0x68>
movsd  -0x38(%rbp),%xmm0
movsd  0xe82(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1194 <mdest1+0x74>
movl   $0x3e7,-0x4(%rbp)
jmp    1232 <mdest1+0x112>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movaps 0xe6b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe4a(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xe45(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <pnorm@plt>
movsd  %xmm0,-0x60(%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>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x50(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mdest1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
ucomisd 0xece(%rip),%xmm4
mov    $0x3e7,%eax
jae    120c <mdest1+0xec>
mov    %edi,%ebx
test   %edi,%edi
jle    120c <mdest1+0xec>
mov    %esi,%ebp
test   %esi,%esi
jle    120c <mdest1+0xec>
xorpd  %xmm5,%xmm5
ucomisd %xmm4,%xmm5
jae    120c <mdest1+0xec>
mov    %rcx,%r14
mov    %rdx,%r15
subsd  %xmm1,%xmm0
andpd  0xeaf(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
addsd  0xe81(%rip),%xmm4
mulsd  0xe81(%rip),%xmm4
movapd %xmm4,%xmm0
movsd  %xmm3,(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1030 <pnorm@plt>
movsd  (%rsp),%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
movapd %xmm0,%xmm3
movsd  0x8(%rsp),%xmm4
divsd  %xmm1,%xmm4
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
divsd  %xmm0,%xmm2
addsd  %xmm4,%xmm2
ucomisd 0xe44(%rip),%xmm2
jb     11d7 <mdest1+0xb7>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    11ea <mdest1+0xca>
movapd %xmm2,%xmm0
movsd  %xmm3,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm3
mulsd  %xmm0,%xmm3
movapd 0x10(%rsp),%xmm1
movapd %xmm1,%xmm0
subsd  %xmm3,%xmm0
movsd  %xmm0,(%r15)
addsd  %xmm1,%xmm3
movsd  %xmm3,(%r14)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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