#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 */
scalar_t__ fabs(double);
double pchi(double, int);
int cont22(int *sw, double a, double b, double c, double d, double al,
           double *x20, double *x2) {
  double w1, w2, w3, w21, w22, w23, w24;
  if (al <= 0.0 || al >= 1.0)
    return 999;
  w1 = a + b + c + d;
  w3 = (a + b) * (c + d) * (a + c) * (b + d);
  w21 = a * d - b * c;
  if (*sw >= 0)
    w2 = w21 * w21;
  else {
    w22 = w1 * 0.5;
    w23 = w21 + w22;
    w24 = w21 - w22;
    if (fabs(w23) > fabs(w24))
      w2 = w24 * w24;
    else
      w2 = w23 * w23;
  }
  *x20 = w1 * w2 / w3;
  *x2 = pchi(al, 1);
  if (*x20 >= *x2)
    *sw = 1;
  else
    *sw = 0;
  return 0;
}


x86 assembly (clang, -O0):
<cont22>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
movsd  %xmm3,-0x30(%rbp)
movsd  %xmm4,-0x38(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdx,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x38(%rbp),%xmm0
jae    1175 <cont22+0x55>
movsd  -0x38(%rbp),%xmm0
movsd  0xe95(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1181 <cont22+0x61>
movl   $0x3e7,-0x4(%rbp)
jmp    1316 <cont22+0x1f6>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jl     122c <cont22+0x10c>
movsd  -0x68(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12b2 <cont22+0x192>
movsd  0xdd4(%rip),%xmm0
mulsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x78(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x88(%rbp)
movsd  -0x80(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
cmp    %rcx,%rax
jle    129e <cont22+0x17e>
movsd  -0x80(%rbp),%xmm0
mulsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12ad <cont22+0x18d>
movsd  -0x78(%rbp),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12b2 <cont22+0x192>
movsd  -0x50(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
mov    -0x40(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%edi
call   1040 <pchi@plt>
mov    -0x48(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x48(%rbp),%rax
ucomisd (%rax),%xmm0
jb     1305 <cont22+0x1e5>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    130f <cont22+0x1ef>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cont22>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movapd %xmm0,%xmm6
xorpd  %xmm0,%xmm0
ucomisd %xmm4,%xmm0
mov    $0x3e7,%eax
jae    124a <cont22+0x12a>
ucomisd 0xeb6(%rip),%xmm4
jae    124a <cont22+0x12a>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
movapd %xmm6,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm2,%xmm5
addsd  %xmm3,%xmm5
mulsd  %xmm0,%xmm5
movapd %xmm0,%xmm7
addsd  %xmm2,%xmm7
addsd  %xmm3,%xmm7
movapd %xmm6,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm5,%xmm0
movapd %xmm1,%xmm5
addsd  %xmm3,%xmm5
mulsd  %xmm0,%xmm5
mulsd  %xmm2,%xmm1
mulsd  %xmm3,%xmm6
subsd  %xmm1,%xmm6
cmpl   $0x0,(%rdi)
js     11a8 <cont22+0x88>
mulsd  %xmm6,%xmm6
jmp    1218 <cont22+0xf8>
movsd  %xmm5,(%rsp)
movsd  %xmm4,0x10(%rsp)
movsd  0xe4d(%rip),%xmm1
movsd  %xmm7,0x8(%rsp)
mulsd  %xmm7,%xmm1
movapd %xmm6,%xmm0
addsd  %xmm1,%xmm0
subsd  %xmm1,%xmm6
movsd  %xmm6,0x18(%rsp)
movsd  %xmm0,0x20(%rsp)
call   1030 <fabs@plt>
mov    %rax,%r12
movsd  0x18(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%r12
jle    11fd <cont22+0xdd>
movsd  0x18(%rsp),%xmm6
jmp    1203 <cont22+0xe3>
movsd  0x20(%rsp),%xmm6
mulsd  %xmm6,%xmm6
movsd  0x10(%rsp),%xmm4
movsd  0x8(%rsp),%xmm7
movsd  (%rsp),%xmm5
mulsd  %xmm6,%xmm7
divsd  %xmm5,%xmm7
movsd  %xmm7,(%r14)
movapd %xmm4,%xmm0
mov    $0x1,%edi
call   1040 <pchi@plt>
movsd  %xmm0,(%r15)
movsd  (%r14),%xmm1
xor    %eax,%eax
ucomisd %xmm0,%xmm1
setae  %al
mov    %eax,(%rbx)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @cont22(i32* %0, double %1, double %2, double %3, double %4, double %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 double
%16 = alloca double*
%17 = alloca double*
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = 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 double %5, double* %15
store double* %6, double** %16
store double* %7, double** %17
%25 = load double, double* %15
%26 = fcmp ole double %25, 0.000000e+00
br i1 %26, label %30, label %27
27: ; preds = %8
%28 = load double, double* %15
%29 = fcmp oge double %28, 1.000000e+00
br i1 %29, label %30, label %31
30: ; preds = %27, %8
store i32 999, i32* %9
br label %111
31: ; preds = %27
%32 = load double, double* %11
%33 = load double, double* %12
%34 = fadd double %32, %33
%35 = load double, double* %13
%36 = fadd double %34, %35
%37 = load double, double* %14
%38 = fadd double %36, %37
store double %38, double* %18
%39 = load double, double* %11
%40 = load double, double* %12
%41 = fadd double %39, %40
%42 = load double, double* %13
%43 = load double, double* %14
%44 = fadd double %42, %43
%45 = fmul double %41, %44
%46 = load double, double* %11
%47 = load double, double* %13
%48 = fadd double %46, %47
%49 = fmul double %45, %48
%50 = load double, double* %12
%51 = load double, double* %14
%52 = fadd double %50, %51
%53 = fmul double %49, %52
store double %53, double* %20
%54 = load double, double* %11
%55 = load double, double* %14
%56 = load double, double* %12
%57 = load double, double* %13
%58 = fmul double %56, %57
%59 = fneg double %58
%60 = call double @llvm.fmuladd.f64(double %54, double %55, double %59)
store double %60, double* %21
%61 = load i32*, i32** %10
%62 = load i32, i32* %61
%63 = icmp sge i32 %62, 0
br i1 %63, label %64, label %68
64: ; preds = %31
%65 = load double, double* %21
%66 = load double, double* %21
%67 = fmul double %65, %66
store double %67, double* %19
br label %91
68: ; preds = %31
%69 = load double, double* %18
%70 = fmul double %69, 5.000000e-01
store double %70, double* %22
%71 = load double, double* %21
%72 = load double, double* %22
%73 = fadd double %71, %72
store double %73, double* %23
%74 = load double, double* %21
%75 = load double, double* %22
%76 = fsub double %74, %75
store double %76, double* %24
%77 = load double, double* %23
%78 = call i64 @fabs(double %77)
%79 = load double, double* %24
%80 = call i64 @fabs(double %79)
%81 = icmp sgt i64 %78, %80
br i1 %81, label %82, label %86
82: ; preds = %68
%83 = load double, double* %24
%84 = load double, double* %24
%85 = fmul double %83, %84
store double %85, double* %19
br label %90
86: ; preds = %68
%87 = load double, double* %23
%88 = load double, double* %23
%89 = fmul double %87, %88
store double %89, double* %19
br label %90
90: ; preds = %86, %82
br label %91
91: ; preds = %90, %64
%92 = load double, double* %18
%93 = load double, double* %19
%94 = fmul double %92, %93
%95 = load double, double* %20
%96 = fdiv double %94, %95
%97 = load double*, double** %16
store double %96, double* %97
%98 = load double, double* %15
%99 = call double @pchi(double %98, i32 1)
%100 = load double*, double** %17
store double %99, double* %100
%101 = load double*, double** %16
%102 = load double, double* %101
%103 = load double*, double** %17
%104 = load double, double* %103
%105 = fcmp oge double %102, %104
br i1 %105, label %106, label %108
106: ; preds = %91
%107 = load i32*, i32** %10
store i32 1, i32* %107
br label %110
108: ; preds = %91
%109 = load i32*, i32** %10
store i32 0, i32* %109
br label %110
110: ; preds = %108, %106
store i32 0, i32* %9
br label %111
111: ; preds = %110, %30
%112 = load i32, i32* %9
ret i32 %112
}

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