#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
double incomplete_gamma(double, double, char const *);
int /*<<< orphan*/ stderr;
double chi_square(double n, double x, const char *prompt) {
  if (n <= 0) {
    fprintf(stderr,
            "%s: IMPLEMENTATION ERROR! (Invalid argument in function "
            "\"chi_square\")\n",
            prompt);
    exit(4);
  }
  return x <= 0 ? 0 : incomplete_gamma(n / 2, x / 2, prompt);
}


x86 assembly (clang, -O0):
<chi_square>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jb     1177 <chi_square+0x47>
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xea0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x4,%edi
call   1050 <exit@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1192 <chi_square+0x62>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11c2 <chi_square+0x92>
movsd  -0x8(%rbp),%xmm0
movsd  0xe61(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe50(%rip),%xmm2
divsd  %xmm2,%xmm1
mov    -0x18(%rbp),%rdi
call   1030 <incomplete_gamma@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chi_square>:
push   %rax
mov    %rdi,%rdx
xorpd  %xmm2,%xmm2
ucomisd %xmm0,%xmm2
jae    1163 <chi_square+0x33>
ucomisd %xmm1,%xmm2
jae    115d <chi_square+0x2d>
movsd  0xeb4(%rip),%xmm2
mulsd  %xmm2,%xmm0
mulsd  %xmm2,%xmm1
mov    %rdx,%rdi
pop    %rax
jmp    1030 <incomplete_gamma@plt>
xorpd  %xmm0,%xmm0
pop    %rax
ret
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x4,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [71 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22chi_square\22)\0A\00"
define double @chi_square(double %0, double %1, i8* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i8*
store double %0, double* %4
store double %1, double* %5
store i8* %2, i8** %6
%7 = load double, double* %4
%8 = fcmp ole double %7, 0.000000e+00
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %6
%12 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = call i32 @exit(i32 4)
unreachable
14: ; preds = %3
%15 = load double, double* %5
%16 = fcmp ole double %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %14
br label %25
18: ; preds = %14
%19 = load double, double* %4
%20 = fdiv double %19, 2.000000e+00
%21 = load double, double* %5
%22 = fdiv double %21, 2.000000e+00
%23 = load i8*, i8** %6
%24 = call double @incomplete_gamma(double %20, double %22, i8* %23)
br label %25
25: ; preds = %18, %17
%26 = phi double [ 0.000000e+00, %17 ], [ %24, %18 ]
ret double %26
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [71 x i8] c"%s: IMPLEMENTATION ERROR! (Invalid argument in function \22chi_square\22)\0A\00"
define double @chi_square(double %0, double %1, i8* %2) {
%4 = fcmp ugt double %0, 0.000000e+00
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str, i64 0, i64 0), i8* %2)
%8 = tail call i32 @exit(i32 4)
unreachable
9: ; preds = %3
%10 = fcmp ugt double %1, 0.000000e+00
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = fmul double %0, 5.000000e-01
%13 = fmul double %1, 5.000000e-01
%14 = tail call double @incomplete_gamma(double %12, double %13, i8* %2)
br label %15
15: ; preds = %9, %11
%16 = phi double [ %14, %11 ], [ 0.000000e+00, %9 ]
ret double %16
}