#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 pt(double, int);
double sqrt(double);
int mest2(int n, double xbar, double squv, double g, double *xl, double *xu) {
  double w;
  if (n < 1 || g <= 0.0 || g >= 1.0)
    return 999;
  w = pt(1.0 - g, n - 1) * squv / sqrt((double)n);
  *xl = xbar - w;
  *xu = xbar + w;
  return 0;
}


x86 assembly (clang, -O0):
<mest2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
cmpl   $0x1,-0x8(%rbp)
jl     1171 <mest2+0x51>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jae    1171 <mest2+0x51>
movsd  -0x20(%rbp),%xmm0
movsd  0xe99(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     117d <mest2+0x5d>
movl   $0x3e7,-0x4(%rbp)
jmp    11e5 <mest2+0xc5>
movsd  0xe7b(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1030 <pt@plt>
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mest2>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
ucomisd 0xecf(%rip),%xmm2
mov    $0x3e7,%eax
jae    11c6 <mest2+0xa6>
mov    %edi,%ebx
test   %edi,%edi
jle    11c6 <mest2+0xa6>
xorpd  %xmm3,%xmm3
ucomisd %xmm2,%xmm3
jae    11c6 <mest2+0xa6>
mov    %rdx,%r14
mov    %rsi,%r15
movsd  %xmm0,0x8(%rsp)
movsd  0xe9c(%rip),%xmm0
subsd  %xmm2,%xmm0
lea    -0x1(%rbx),%edi
movsd  %xmm1,(%rsp)
call   1030 <pt@plt>
movapd %xmm0,%xmm2
mulsd  (%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
ucomisd 0xe7b(%rip),%xmm0
jb     1195 <mest2+0x75>
sqrtsd %xmm0,%xmm0
jmp    11a4 <mest2+0x84>
movsd  %xmm2,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,(%r15)
addsd  %xmm1,%xmm2
movsd  %xmm2,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @mest2(i32 %0, double %1, double %2, double %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double*
%13 = alloca double*
%14 = alloca double
store i32 %0, i32* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double* %4, double** %12
store double* %5, double** %13
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 1
br i1 %16, label %23, label %17
17: ; preds = %6
%18 = load double, double* %11
%19 = fcmp ole double %18, 0.000000e+00
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load double, double* %11
%22 = fcmp oge double %21, 1.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %20, %17, %6
store i32 999, i32* %7
br label %44
24: ; preds = %20
%25 = load double, double* %11
%26 = fsub double 1.000000e+00, %25
%27 = load i32, i32* %8
%28 = sub nsw i32 %27, 1
%29 = call double @pt(double %26, i32 %28)
%30 = load double, double* %10
%31 = fmul double %29, %30
%32 = load i32, i32* %8
%33 = sitofp i32 %32 to double
%34 = call double @sqrt(double %33)
%35 = fdiv double %31, %34
store double %35, double* %14
%36 = load double, double* %9
%37 = load double, double* %14
%38 = fsub double %36, %37
%39 = load double*, double** %12
store double %38, double* %39
%40 = load double, double* %9
%41 = load double, double* %14
%42 = fadd double %40, %41
%43 = load double*, double** %13
store double %42, double* %43
store i32 0, i32* %7
br label %44
44: ; preds = %24, %23
%45 = load i32, i32* %7
ret i32 %45
}

LLVM IR (-O2):
define i32 @mest2(i32 %0, double %1, double %2, double %3, double* nocapture writeonly %4, double* nocapture writeonly %5) {
%7 = icmp slt i32 %0, 1
%8 = fcmp ole double %3, 0.000000e+00
%9 = or i1 %7, %8
%10 = fcmp oge double %3, 1.000000e+00
%11 = or i1 %10, %9
br i1 %11, label %22, label %12
12: ; preds = %6
%13 = fsub double 1.000000e+00, %3
%14 = add nsw i32 %0, -1
%15 = tail call double @pt(double %13, i32 %14)
%16 = fmul double %15, %2
%17 = sitofp i32 %0 to double
%18 = tail call double @sqrt(double %17)
%19 = fdiv double %16, %18
%20 = fsub double %1, %19
store double %20, double* %4
%21 = fadd double %19, %1
store double %21, double* %5
br label %22
22: ; preds = %6, %12
%23 = phi i32 [ 0, %12 ], [ 999, %6 ]
ret i32 %23
}