#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 besj1(double x) {
  int i;
  double w, wp, wq, wx4;
  static double a[7] = {1.9999999998,  -3.999999971, 2.6666660544,
                        -0.8888839649, 0.1777582922, -0.0236616773,
                        0.0022069155};
  static double c[5] = {0.3989422819, 0.0029218256, -0.000223203, 0.0000580759,
                        -0.000020092};
  static double k[5] = {0.0374008364, -0.00063904, 0.0001064741, -0.0000398708,
                        0.00001622};
  if (x < 0.) {
    fprintf(stderr, "Error : x < 0 in besj1()\n");
    return 0.;
  }
  wx4 = x * x / 16.;
  if (x <= 4.) {
    w = -0.0001289769;
    for (i = 6; i >= 0; i--)
      w = w * wx4 + a[i];
    return w * x / 4.;
  }
  wx4 = 1. / wx4;
  wp = 0.0000042414;
  wq = -0.0000036594;
  for (i = 4; i >= 0; i--) {
    wp = wp * wx4 + c[i];
    wq = wq * wx4 + k[i];
  }
  w = x - 2.356194490192345;
  wp *= cos(w);
  wq *= sin(w);
  return 2. / sqrt(x) * (wp - 4. * wq / x);
}


x86 assembly (clang, -O0):
<besj1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    117d <besj1+0x3d>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xed5(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1333 <besj1+0x1f3>
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     121e <besj1+0xde>
movsd  0xe85(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x6,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11fe <besj1+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 <besj1+0x7f>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xdf0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1333 <besj1+0x1f3>
movsd  0xdfa(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xde0(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdcb(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x4,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     12b7 <besj1+0x177>
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e20(%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    0x2e29(%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    1251 <besj1+0x111>
movsd  -0x10(%rbp),%xmm0
movsd  0xd6c(%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  0xd1d(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xce4(%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):
<besj1>:
sub    $0x48,%rsp
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jbe    1170 <besj1+0x30>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xf7e(%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 <besj1+0x186>
movsd  0xebe(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  0xeba(%rip),%xmm3
mulsd  %xmm0,%xmm3
addsd  0xeb6(%rip),%xmm3
movsd  0xeb6(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xeb2(%rip),%xmm1
mulsd  %xmm0,%xmm3
addsd  0xeae(%rip),%xmm3
mulsd  %xmm0,%xmm1
addsd  0xeaa(%rip),%xmm1
mulsd  %xmm0,%xmm3
addsd  0xea6(%rip),%xmm3
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
movsd  %xmm3,0x8(%rsp)
mulsd  %xmm0,%xmm1
addsd  0xe8c(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xe86(%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 0xe37(%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
mulsd  %xmm2,%xmm0
mulsd  0xd22(%rip),%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
@besj1.a = internal global [7 x double] [double 0x3FFFFFFFFFF24190, double 0xC00FFFFFFC1B914D, double 0x40055555032802C7, double 0xBFEC71BCC8E5E5E2, double 0x3FC6C0C8A1CBC07E, double 0xBF983AC448B0223B, double 0x3F62143CBCB89C58]
@besj1.c = internal global [5 x double] [double 0x3FD988453570229D, double 0x3F67EF832CB11327, double -2.232030e-04, double 5.807590e-05, double -2.009200e-05]
@besj1.k = internal global [5 x double] [double 0x3FA32633D25CB21C, double -6.390400e-04, double 0x3F1BE95B1C0726F9, double -3.987080e-05, double 1.622000e-05]
@stderr = global i32 0
@.str = [26 x i8] c"Error : x < 0 in besj1()\0A\00"
define double @besj1(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 %87
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 %41
21: ; preds = %14
store double 0xBF20E7BF22876CDB, 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]* @besj1.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
%38 = load double, double* %3
%39 = fmul double %37, %38
%40 = fdiv double %39, 4.000000e+00
store double %40, double* %2
br label %87
41: ; preds = %14
%42 = load double, double* %8
%43 = fdiv double 1.000000e+00, %42
store double %43, double* %8
store double 4.241400e-06, double* %6
store double -3.659400e-06, double* %7
store i32 4, i32* %4
br label %44
44: ; preds = %62, %41
%45 = load i32, i32* %4
%46 = icmp sge i32 %45, 0
br i1 %46, label %47, label %65
47: ; preds = %44
%48 = load double, double* %6
%49 = load double, double* %8
%50 = load i32, i32* %4
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [5 x double], [5 x double]* @besj1.c, i64 0, i64 %51
%53 = load double, double* %52
%54 = call double @llvm.fmuladd.f64(double %48, double %49, double %53)
store double %54, double* %6
%55 = load double, double* %7
%56 = load double, double* %8
%57 = load i32, i32* %4
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [5 x double], [5 x double]* @besj1.k, i64 0, i64 %58
%60 = load double, double* %59
%61 = call double @llvm.fmuladd.f64(double %55, double %56, double %60)
store double %61, double* %7
br label %62
62: ; preds = %47
%63 = load i32, i32* %4
%64 = add nsw i32 %63, -1
store i32 %64, i32* %4
br label %44
65: ; preds = %44
%66 = load double, double* %3
%67 = fsub double %66, 0x4002D97C7F3321D2
store double %67, double* %5
%68 = load double, double* %5
%69 = call double @cos(double %68)
%70 = load double, double* %6
%71 = fmul double %70, %69
store double %71, double* %6
%72 = load double, double* %5
%73 = call double @sin(double %72)
%74 = load double, double* %7
%75 = fmul double %74, %73
store double %75, double* %7
%76 = load double, double* %3
%77 = call i32 @sqrt(double %76)
%78 = sitofp i32 %77 to double
%79 = fdiv double 2.000000e+00, %78
%80 = load double, double* %6
%81 = load double, double* %7
%82 = fmul double 4.000000e+00, %81
%83 = load double, double* %3
%84 = fdiv double %82, %83
%85 = fsub double %80, %84
%86 = fmul double %79, %85
store double %86, double* %2
br label %87
87: ; preds = %65, %36, %11
%88 = load double, double* %2
ret double %88
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Error : x < 0 in besj1()\0A\00"
define double @besj1(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 %48
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 %20, label %10
10: ; preds = %6
%11 = tail call double @llvm.fmuladd.f64(double %8, double 0xBF20E7BF22876CDB, double 0x3F62143CBCB89C58)
%12 = tail call double @llvm.fmuladd.f64(double %11, double %8, double 0xBF983AC448B0223B)
%13 = tail call double @llvm.fmuladd.f64(double %12, double %8, double 0x3FC6C0C8A1CBC07E)
%14 = tail call double @llvm.fmuladd.f64(double %13, double %8, double 0xBFEC71BCC8E5E5E2)
%15 = tail call double @llvm.fmuladd.f64(double %14, double %8, double 0x40055555032802C7)
%16 = tail call double @llvm.fmuladd.f64(double %15, double %8, double 0xC00FFFFFFC1B914D)
%17 = tail call double @llvm.fmuladd.f64(double %16, double %8, double 0x3FFFFFFFFFF24190)
%18 = fmul double %17, %0
%19 = fmul double %18, 2.500000e-01
br label %48
20: ; preds = %6
%21 = fdiv double 1.000000e+00, %8
%22 = tail call double @llvm.fmuladd.f64(double %21, double 4.241400e-06, double -2.009200e-05)
%23 = tail call double @llvm.fmuladd.f64(double %21, double -3.659400e-06, double 1.622000e-05)
%24 = tail call double @llvm.fmuladd.f64(double %22, double %21, double 5.807590e-05)
%25 = tail call double @llvm.fmuladd.f64(double %23, double %21, double -3.987080e-05)
%26 = tail call double @llvm.fmuladd.f64(double %24, double %21, double -2.232030e-04)
%27 = tail call double @llvm.fmuladd.f64(double %25, double %21, double 0x3F1BE95B1C0726F9)
%28 = tail call double @llvm.fmuladd.f64(double %26, double %21, double 0x3F67EF832CB11327)
%29 = tail call double @llvm.fmuladd.f64(double %27, double %21, double -6.390400e-04)
%30 = tail call double @llvm.fmuladd.f64(double %28, double %21, double 0x3FD988453570229D)
%31 = tail call double @llvm.fmuladd.f64(double %29, double %21, double 0x3FA32633D25CB21C)
%32 = fadd double %0, 0xC002D97C7F3321D2
%33 = tail call double @cos(double %32)
%34 = fmul double %30, %33
%35 = tail call double @sin(double %32)
%36 = fmul double %31, %35
%37 = tail call i32 @sqrt(double %0)
%38 = sitofp i32 %37 to double
%39 = fmul double %36, 4.000000e+00
%40 = insertelement <2 x double> <double 2.000000e+00, double poison>, double %39, i64 1
%41 = insertelement <2 x double> poison, double %0, i64 1
%42 = insertelement <2 x double> %41, double %38, i64 0
%43 = fdiv <2 x double> %40, %42
%44 = extractelement <2 x double> %43, i64 1
%45 = fsub double %34, %44
%46 = extractelement <2 x double> %43, i64 0
%47 = fmul double %46, %45
br label %48
48: ; preds = %20, %10, %3
%49 = phi double [ 0.000000e+00, %3 ], [ %19, %10 ], [ %47, %20 ]
ret double %49
}