#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 */
typedef int /*<<< orphan*/ esp;

/* Variables and functions */
int fabs(int /*<<< orphan*/);
double s3j(double, double, double, double, double, double);
double sqrt(int);
double cg(double j1, double m1, double j2, double m2, double j, double m) {
  int esp = (int)(j1 - j2 + m);
  double cgris;
  if (!(fabs((esp) - (j1 - j2 + m)) < 1e-10))
    return 0;
  if (esp % 2 == 0)
    cgris = 1.0;
  else
    cgris = -1.0;
  cgris *= sqrt(2 * j + 1) * s3j(j1, j2, j, m1, m2, -m);
  return cgris;
}


x86 assembly (clang, -O0):
<cg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x3c(%rbp)
cvtsi2sdl -0x3c(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe67(%rip),%xmm0
ucomisd %xmm1,%xmm0
ja     11b0 <cg+0x80>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1260 <cg+0x130>
mov    -0x3c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d6 <cg+0xa6>
movsd  0xe44(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11e3 <cg+0xb3>
movsd  0xe2a(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  %xmm0,%xmm0
movsd  0xe1c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
movq   %xmm5,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm5
call   1030 <s3j@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cg>:
push   %rbx
sub    $0x50,%rsp
movsd  %xmm0,0x30(%rsp)
movapd %xmm0,%xmm6
movsd  %xmm2,0x38(%rsp)
subsd  %xmm2,%xmm6
movapd %xmm5,0x40(%rsp)
addsd  %xmm5,%xmm6
cvttpd2dq %xmm6,%xmm0
cvtdq2pd %xmm0,%xmm0
movsd  %xmm4,0x8(%rsp)
movsd  %xmm3,0x28(%rsp)
movsd  %xmm1,0x20(%rsp)
movapd %xmm6,0x10(%rsp)
subsd  %xmm6,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <fabs@plt>
xorpd  %xmm0,%xmm0
test   %eax,%eax
jg     11f3 <cg+0xc3>
cvttsd2si 0x10(%rsp),%ebx
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
addsd  0xe60(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <sqrt@plt>
movsd  %xmm0,0x10(%rsp)
movapd 0x40(%rsp),%xmm5
xorpd  0xe53(%rip),%xmm5
movsd  0x30(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x28(%rsp),%xmm4
call   1030 <s3j@plt>
mulsd  0x10(%rsp),%xmm0
test   $0x1,%bl
je     11f3 <cg+0xc3>
xorpd  0xe1d(%rip),%xmm0
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @cg(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
%15 = alloca double
store double %0, double* %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
%16 = load double, double* %8
%17 = load double, double* %10
%18 = fsub double %16, %17
%19 = load double, double* %13
%20 = fadd double %18, %19
%21 = fptosi double %20 to i32
store i32 %21, i32* %14
%22 = load i32, i32* %14
%23 = sitofp i32 %22 to double
%24 = load double, double* %8
%25 = load double, double* %10
%26 = fsub double %24, %25
%27 = load double, double* %13
%28 = fadd double %26, %27
%29 = fsub double %23, %28
%30 = fptosi double %29 to i32
%31 = call i32 @fabs(i32 %30)
%32 = sitofp i32 %31 to double
%33 = fcmp olt double %32, 1.000000e-10
br i1 %33, label %35, label %34
34: ; preds = %6
store double 0.000000e+00, double* %7
br label %58
35: ; preds = %6
%36 = load i32, i32* %14
%37 = srem i32 %36, 2
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store double 1.000000e+00, double* %15
br label %41
40: ; preds = %35
store double -1.000000e+00, double* %15
br label %41
41: ; preds = %40, %39
%42 = load double, double* %12
%43 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %42, double 1.000000e+00)
%44 = fptosi double %43 to i32
%45 = call double @sqrt(i32 %44)
%46 = load double, double* %8
%47 = load double, double* %10
%48 = load double, double* %12
%49 = load double, double* %9
%50 = load double, double* %11
%51 = load double, double* %13
%52 = fneg double %51
%53 = call double @s3j(double %46, double %47, double %48, double %49, double %50, double %52)
%54 = fmul double %45, %53
%55 = load double, double* %15
%56 = fmul double %55, %54
store double %56, double* %15
%57 = load double, double* %15
store double %57, double* %7
br label %58
58: ; preds = %41, %34
%59 = load double, double* %7
ret double %59
}

LLVM IR (-O2):
define double @cg(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = fsub double %0, %2
%8 = fadd double %7, %5
%9 = fptosi double %8 to i32
%10 = sitofp i32 %9 to double
%11 = fsub double %10, %8
%12 = fptosi double %11 to i32
%13 = tail call i32 @fabs(i32 %12)
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %26
15: ; preds = %6
%16 = and i32 %9, 1
%17 = icmp eq i32 %16, 0
%18 = tail call double @llvm.fmuladd.f64(double %4, double 2.000000e+00, double 1.000000e+00)
%19 = fptosi double %18 to i32
%20 = tail call double @sqrt(i32 %19)
%21 = fneg double %5
%22 = tail call double @s3j(double %0, double %2, double %4, double %1, double %3, double %21)
%23 = fmul double %20, %22
%24 = fneg double %23
%25 = select i1 %17, double %23, double %24
br label %26
26: ; preds = %6, %15
%27 = phi double [ %25, %15 ], [ 0.000000e+00, %6 ]
ret double %27
}