#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 cos(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double sin(double);
int sqrt(double);
int /*<<< orphan*/ stderr;
double besj0(double x) {
  int i;
  double w, wp, wq, wx4;
  static double a[7] = {1.0,           -3.9999998721, 3.9999973021,
                        -1.7777560599, 0.4443584263,  -0.0709253492,
                        0.0076771853};
  static double c[5] = {0.3989422793, -0.00175302, 0.00017343, -0.0000487613,
                        0.0000173565};
  static double k[5] = {-0.0124669441, 0.0004564324, -0.0000869791,
                        0.0000342468, -0.0000142078};
  if (x < 0.) {
    fprintf(stderr, "Error : x < 0 in besj0()\n");
    return 0.;
  }
  wx4 = x * x / 16.;
  if (x <= 4.) {
    w = -0.0005014415;
    for (i = 6; i >= 0; i--)
      w = w * wx4 + a[i];
    return w;
  }
  wx4 = 1. / wx4;
  wp = -0.0000037043;
  wq = 0.0000032312;
  for (i = 4; i >= 0; i--) {
    wp = wp * wx4 + c[i];
    wq = wq * wx4 + k[i];
  }
  w = x - 0.78539816339744831;
  wp *= cos(w);
  wq *= sin(w);
  return 2. / sqrt(x) * (wp - 4. * wq / x);
}


x86 assembly (clang, -O0):
<besj0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    117d <besj0+0x3d>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xed5(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1322 <besj0+0x1e2>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe79(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe60(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     120d <besj0+0xcd>
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x6,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11fe <besj0+0xbe>
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e72(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11bf <besj0+0x7f>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1322 <besj0+0x1e2>
movsd  0xe0b(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdf1(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xddc(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x4,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     12a6 <besj0+0x166>
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e31(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e3a(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1240 <besj0+0x100>
movsd  -0x10(%rbp),%xmm0
movsd  0xd7d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1050 <cos@plt>
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <sin@plt>
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <sqrt@plt>
cvtsi2sd %eax,%xmm1
movsd  0xd2e(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xcf5(%rip),%xmm2
mulsd  -0x30(%rbp),%xmm2
divsd  -0x10(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<besj0>:
sub    $0x48,%rsp
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jbe    1170 <besj0+0x30>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xf6e(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
add    $0x48,%rsp
ret
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
mulsd  0xe80(%rip),%xmm1
movsd  0xe80(%rip),%xmm0
ucomisd %xmm2,%xmm0
jae    12c6 <besj0+0x186>
movsd  0xeae(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  0xeaa(%rip),%xmm3
mulsd  %xmm0,%xmm3
addsd  0xea6(%rip),%xmm3
movsd  0xea6(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xea2(%rip),%xmm1
mulsd  %xmm0,%xmm3
addsd  0xe9e(%rip),%xmm3
mulsd  %xmm0,%xmm1
addsd  0xe9a(%rip),%xmm1
mulsd  %xmm0,%xmm3
addsd  0xe96(%rip),%xmm3
mulsd  %xmm0,%xmm1
addsd  0xe92(%rip),%xmm1
mulsd  %xmm0,%xmm3
addsd  0xe8e(%rip),%xmm3
mulsd  %xmm0,%xmm1
addsd  0xe8a(%rip),%xmm1
mulsd  %xmm0,%xmm3
addsd  0xe86(%rip),%xmm3
movsd  %xmm3,0x8(%rsp)
mulsd  %xmm0,%xmm1
addsd  0xe7c(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xe76(%rip),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x28(%rsp)
movapd %xmm2,0x30(%rsp)
call   1050 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x10(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
movaps 0x30(%rsp),%xmm0
call   1060 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd 0x10(%rsp),%xmm2
mulsd  0xd77(%rip),%xmm2
movapd 0xe27(%rip),%xmm1
unpcklpd %xmm2,%xmm1
unpcklpd 0x30(%rsp),%xmm0
divpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm2
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
mulsd  %xmm1,%xmm0
add    $0x48,%rsp
ret
movsd  0xd42(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xd3e(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xd3a(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xd36(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xd32(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xd2e(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xd2a(%rip),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xd26(%rip),%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
@besj0.a = internal global [7 x double] [double 1.000000e+00, double 0xC00FFFFFEED563B4, double 0x400FFFFE95E4DCA3, double 0xBFFC71B0569894C1, double 0x3FDC705E532A4610, double 0xBFB22829E7457925, double 0x3F7F721CBC9F0E40]
@besj0.c = internal global [5 x double] [double 0x3FD9884532A573E1, double -1.753020e-03, double 1.734300e-04, double -4.876130e-05, double 1.735650e-05]
@besj0.k = internal global [5 x double] [double 0xBF898844E9864467, double 0x3F3DE9AA3B17FD24, double -8.697910e-05, double 3.424680e-05, double -1.420780e-05]
@stderr = global i32 0
@.str = [26 x i8] c"Error : x < 0 in besj0()\0A\00"
define double @besj0(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %3
%9 = load double, double* %3
%10 = fcmp olt double %9, 0.000000e+00
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %84
14: ; preds = %1
%15 = load double, double* %3
%16 = load double, double* %3
%17 = fmul double %15, %16
%18 = fdiv double %17, 1.600000e+01
store double %18, double* %8
%19 = load double, double* %3
%20 = fcmp ole double %19, 4.000000e+00
br i1 %20, label %21, label %38
21: ; preds = %14
store double 0xBF406E656BF320D2, double* %5
store i32 6, i32* %4
br label %22
22: ; preds = %33, %21
%23 = load i32, i32* %4
%24 = icmp sge i32 %23, 0
br i1 %24, label %25, label %36
25: ; preds = %22
%26 = load double, double* %5
%27 = load double, double* %8
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [7 x double], [7 x double]* @besj0.a, i64 0, i64 %29
%31 = load double, double* %30
%32 = call double @llvm.fmuladd.f64(double %26, double %27, double %31)
store double %32, double* %5
br label %33
33: ; preds = %25
%34 = load i32, i32* %4
%35 = add nsw i32 %34, -1
store i32 %35, i32* %4
br label %22
36: ; preds = %22
%37 = load double, double* %5
store double %37, double* %2
br label %84
38: ; preds = %14
%39 = load double, double* %8
%40 = fdiv double 1.000000e+00, %39
store double %40, double* %8
store double -3.704300e-06, double* %6
store double 3.231200e-06, double* %7
store i32 4, i32* %4
br label %41
41: ; preds = %59, %38
%42 = load i32, i32* %4
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %62
44: ; preds = %41
%45 = load double, double* %6
%46 = load double, double* %8
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [5 x double], [5 x double]* @besj0.c, i64 0, i64 %48
%50 = load double, double* %49
%51 = call double @llvm.fmuladd.f64(double %45, double %46, double %50)
store double %51, double* %6
%52 = load double, double* %7
%53 = load double, double* %8
%54 = load i32, i32* %4
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [5 x double], [5 x double]* @besj0.k, i64 0, i64 %55
%57 = load double, double* %56
%58 = call double @llvm.fmuladd.f64(double %52, double %53, double %57)
store double %58, double* %7
br label %59
59: ; preds = %44
%60 = load i32, i32* %4
%61 = add nsw i32 %60, -1
store i32 %61, i32* %4
br label %41
62: ; preds = %41
%63 = load double, double* %3
%64 = fsub double %63, 0x3FE921FB54442D18
store double %64, double* %5
%65 = load double, double* %5
%66 = call double @cos(double %65)
%67 = load double, double* %6
%68 = fmul double %67, %66
store double %68, double* %6
%69 = load double, double* %5
%70 = call double @sin(double %69)
%71 = load double, double* %7
%72 = fmul double %71, %70
store double %72, double* %7
%73 = load double, double* %3
%74 = call i32 @sqrt(double %73)
%75 = sitofp i32 %74 to double
%76 = fdiv double 2.000000e+00, %75
%77 = load double, double* %6
%78 = load double, double* %7
%79 = fmul double 4.000000e+00, %78
%80 = load double, double* %3
%81 = fdiv double %79, %80
%82 = fsub double %77, %81
%83 = fmul double %76, %82
store double %83, double* %2
br label %84
84: ; preds = %62, %36, %11
%85 = load double, double* %2
ret double %85
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Error : x < 0 in besj0()\0A\00"
define double @besj0(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %46
6: ; preds = %1
%7 = fmul double %0, %0
%8 = fmul double %7, 6.250000e-02
%9 = fcmp ugt double %0, 4.000000e+00
br i1 %9, label %18, label %10
10: ; preds = %6
%11 = tail call double @llvm.fmuladd.f64(double %8, double 0xBF406E656BF320D2, double 0x3F7F721CBC9F0E40)
%12 = tail call double @llvm.fmuladd.f64(double %11, double %8, double 0xBFB22829E7457925)
%13 = tail call double @llvm.fmuladd.f64(double %12, double %8, double 0x3FDC705E532A4610)
%14 = tail call double @llvm.fmuladd.f64(double %13, double %8, double 0xBFFC71B0569894C1)
%15 = tail call double @llvm.fmuladd.f64(double %14, double %8, double 0x400FFFFE95E4DCA3)
%16 = tail call double @llvm.fmuladd.f64(double %15, double %8, double 0xC00FFFFFEED563B4)
%17 = tail call double @llvm.fmuladd.f64(double %16, double %8, double 1.000000e+00)
br label %46
18: ; preds = %6
%19 = fdiv double 1.000000e+00, %8
%20 = tail call double @llvm.fmuladd.f64(double %19, double -3.704300e-06, double 1.735650e-05)
%21 = tail call double @llvm.fmuladd.f64(double %19, double 3.231200e-06, double -1.420780e-05)
%22 = tail call double @llvm.fmuladd.f64(double %20, double %19, double -4.876130e-05)
%23 = tail call double @llvm.fmuladd.f64(double %21, double %19, double 3.424680e-05)
%24 = tail call double @llvm.fmuladd.f64(double %22, double %19, double 1.734300e-04)
%25 = tail call double @llvm.fmuladd.f64(double %23, double %19, double -8.697910e-05)
%26 = tail call double @llvm.fmuladd.f64(double %24, double %19, double -1.753020e-03)
%27 = tail call double @llvm.fmuladd.f64(double %25, double %19, double 0x3F3DE9AA3B17FD24)
%28 = tail call double @llvm.fmuladd.f64(double %26, double %19, double 0x3FD9884532A573E1)
%29 = tail call double @llvm.fmuladd.f64(double %27, double %19, double 0xBF898844E9864467)
%30 = fadd double %0, 0xBFE921FB54442D18
%31 = tail call double @cos(double %30)
%32 = fmul double %28, %31
%33 = tail call double @sin(double %30)
%34 = fmul double %29, %33
%35 = tail call i32 @sqrt(double %0)
%36 = sitofp i32 %35 to double
%37 = fmul double %34, 4.000000e+00
%38 = insertelement <2 x double> <double 2.000000e+00, double poison>, double %37, i64 1
%39 = insertelement <2 x double> poison, double %0, i64 1
%40 = insertelement <2 x double> %39, double %36, i64 0
%41 = fdiv <2 x double> %38, %40
%42 = extractelement <2 x double> %41, i64 1
%43 = fsub double %32, %42
%44 = extractelement <2 x double> %41, i64 0
%45 = fmul double %44, %43
br label %46
46: ; preds = %10, %18, %3
%47 = phi double [ 0.000000e+00, %3 ], [ %45, %18 ], [ %17, %10 ]
ret double %47
}