#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*/ fprintf(int /*<<< orphan*/, char *);
double log(double);
double sin(double);
double sqrt(double);
int /*<<< orphan*/ stderr;
double besy0(double x) {
  int i;
  double bj0, w, wf, wp, wx3;
  static double a[6] = {0.36746691, 0.60559366,  -0.74350384,
                        0.25300117, -0.04261214, 0.00427916};
  static double b[6] = {1.0,        -2.2499997, 1.2656208,
                        -0.3163866, 0.0444479,  -0.0039444};
  static double c[6] = {0.79788456,  -0.00000077, -0.0055274,
                        -0.00009512, 0.00137237,  -0.00072805};
  static double k[6] = {0.78539816,  0.04166397, 0.00003954,
                        -0.00262573, 0.00054125, 0.00029333};
  if (x <= 0.) {
    fprintf(stderr, "Error : x <= 0  in besy0()\n");
    return 0.;
  }
  if (x <= 3.) {
    w = -0.00024846;
    bj0 = 0.00021;
    wx3 = x * x / 9.;
    for (i = 5; i >= 0; i--) {
      w = w * wx3 + a[i];
      bj0 = bj0 * wx3 + b[i];
    }
    return w + 0.636619772367581 * log(x / 2.) * bj0;
  }
  wx3 = 3. / x;
  wf = 0.00014476;
  wp = -0.00013558;
  for (i = 5; i >= 0; i--) {
    wf = wf * wx3 + c[i];
    wp = wp * wx3 + k[i];
  }
  return wf * sin(x - wp) / sqrt(x);
}


x86 assembly (clang, -O0):
<besy0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     117d <besy0+0x3d>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xed5(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    135b <besy0+0x21b>
movsd  0xe7b(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     127d <besy0+0x13d>
movsd  0xe90(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe7b(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe5c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x5,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1232 <besy0+0xf2>
movsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e65(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e6e(%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    11cc <besy0+0x8c>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xdef(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  0xdce(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    135b <besy0+0x21b>
movsd  0xd7b(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xd79(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xd64(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x5,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1316 <besy0+0x1d6>
movsd  -0x30(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2de1(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2dea(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    12b0 <besy0+0x170>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<besy0>:
sub    $0x18,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jae    124d <besy0+0x10d>
movsd  0xea6(%rip),%xmm2
ucomisd %xmm0,%xmm2
jae    126b <besy0+0x12b>
divsd  %xmm0,%xmm2
movsd  0xf20(%rip),%xmm3
mulsd  %xmm2,%xmm3
addsd  0xf1c(%rip),%xmm3
movsd  %xmm0,0x8(%rsp)
movsd  0xf16(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  0xf12(%rip),%xmm1
mulsd  %xmm2,%xmm3
addsd  0xf0e(%rip),%xmm3
mulsd  %xmm2,%xmm1
addsd  0xf0a(%rip),%xmm1
mulsd  %xmm2,%xmm3
addsd  0xf06(%rip),%xmm3
mulsd  %xmm2,%xmm1
addsd  0xf02(%rip),%xmm1
mulsd  %xmm2,%xmm3
addsd  0xefe(%rip),%xmm3
mulsd  %xmm2,%xmm1
addsd  0xefa(%rip),%xmm1
mulsd  %xmm2,%xmm3
addsd  0xef6(%rip),%xmm3
mulsd  %xmm2,%xmm1
addsd  0xef2(%rip),%xmm1
mulsd  %xmm2,%xmm3
addsd  0xeee(%rip),%xmm3
movsd  %xmm3,0x10(%rsp)
mulsd  %xmm2,%xmm1
addsd  0xee4(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
call   1040 <sin@plt>
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
mulsd  0x10(%rsp),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     134d <besy0+0x20d>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    1362 <besy0+0x222>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
lea    0xea3(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm2,%xmm2
jmp    1366 <besy0+0x226>
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
divsd  0xd8d(%rip),%xmm1
movsd  0xd8d(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0xd89(%rip),%xmm2
movsd  0xd89(%rip),%xmm3
mulsd  %xmm1,%xmm3
addsd  0xd85(%rip),%xmm3
mulsd  %xmm1,%xmm2
addsd  0xd81(%rip),%xmm2
mulsd  %xmm1,%xmm3
addsd  0xd7d(%rip),%xmm3
mulsd  %xmm1,%xmm2
addsd  0xd79(%rip),%xmm2
mulsd  %xmm1,%xmm3
addsd  0xd75(%rip),%xmm3
mulsd  %xmm1,%xmm2
addsd  0xd71(%rip),%xmm2
mulsd  %xmm1,%xmm3
addsd  0xd6d(%rip),%xmm3
mulsd  %xmm1,%xmm2
addsd  0xd69(%rip),%xmm2
mulsd  %xmm1,%xmm3
addsd  0xd65(%rip),%xmm3
mulsd  %xmm1,%xmm2
addsd  0xd61(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm1,%xmm3
addsd  0xd57(%rip),%xmm3
movsd  %xmm3,0x10(%rsp)
mulsd  0xd51(%rip),%xmm0
call   1050 <log@plt>
mulsd  0xd4c(%rip),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret
movapd %xmm1,%xmm0
movsd  %xmm2,0x8(%rsp)
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@besy0.a = internal global [6 x double] [double 0x3FD78493EE33FAAE, double 0x3FE36105F48BAD9E, double 0xBFE7CAC890A8036A, double 0x3FD0312BD1BFFBAE, double 0xBFA5D142276CD66D, double 4.279160e-03]
@besy0.b = internal global [6 x double] [double 1.000000e+00, double 0xC001FFFFD7BC1418, double 0x3FF43FFB9892329D, double 0xBFD43FAD94F920E9, double 4.444790e-02, double -3.944400e-03]
@besy0.c = internal global [6 x double] [double 0x3FE988453365DE00, double -7.700000e-07, double -5.527400e-03, double 0xBF18EF652822DED2, double 1.372370e-03, double -7.280500e-04]
@besy0.k = internal global [6 x double] [double 0x3FE921FB52713C02, double 0x3FA554FAD9249EF1, double 3.954000e-05, double -2.625730e-03, double 5.412500e-04, double 2.933300e-04]
@stderr = global i32 0
@.str = [28 x i8] c"Error : x <= 0 in besy0()\0A\00"
define double @besy0(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %3
%10 = load double, double* %3
%11 = fcmp ole double %10, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %86
15: ; preds = %1
%16 = load double, double* %3
%17 = fcmp ole double %16, 3.000000e+00
br i1 %17, label %18, label %52
18: ; preds = %15
store double -2.484600e-04, double* %6
store double 2.100000e-04, double* %5
%19 = load double, double* %3
%20 = load double, double* %3
%21 = fmul double %19, %20
%22 = fdiv double %21, 9.000000e+00
store double %22, double* %9
store i32 5, i32* %4
br label %23
23: ; preds = %41, %18
%24 = load i32, i32* %4
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %44
26: ; preds = %23
%27 = load double, double* %6
%28 = load double, double* %9
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [6 x double], [6 x double]* @besy0.a, i64 0, i64 %30
%32 = load double, double* %31
%33 = call double @llvm.fmuladd.f64(double %27, double %28, double %32)
store double %33, double* %6
%34 = load double, double* %5
%35 = load double, double* %9
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [6 x double], [6 x double]* @besy0.b, i64 0, i64 %37
%39 = load double, double* %38
%40 = call double @llvm.fmuladd.f64(double %34, double %35, double %39)
store double %40, double* %5
br label %41
41: ; preds = %26
%42 = load i32, i32* %4
%43 = add nsw i32 %42, -1
store i32 %43, i32* %4
br label %23
44: ; preds = %23
%45 = load double, double* %6
%46 = load double, double* %3
%47 = fdiv double %46, 2.000000e+00
%48 = call double @log(double %47)
%49 = fmul double 0x3FE45F306DC9C880, %48
%50 = load double, double* %5
%51 = call double @llvm.fmuladd.f64(double %49, double %50, double %45)
store double %51, double* %2
br label %86
52: ; preds = %15
%53 = load double, double* %3
%54 = fdiv double 3.000000e+00, %53
store double %54, double* %9
store double 1.447600e-04, double* %7
store double -1.355800e-04, double* %8
store i32 5, i32* %4
br label %55
55: ; preds = %73, %52
%56 = load i32, i32* %4
%57 = icmp sge i32 %56, 0
br i1 %57, label %58, label %76
58: ; preds = %55
%59 = load double, double* %7
%60 = load double, double* %9
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [6 x double], [6 x double]* @besy0.c, i64 0, i64 %62
%64 = load double, double* %63
%65 = call double @llvm.fmuladd.f64(double %59, double %60, double %64)
store double %65, double* %7
%66 = load double, double* %8
%67 = load double, double* %9
%68 = load i32, i32* %4
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [6 x double], [6 x double]* @besy0.k, i64 0, i64 %69
%71 = load double, double* %70
%72 = call double @llvm.fmuladd.f64(double %66, double %67, double %71)
store double %72, double* %8
br label %73
73: ; preds = %58
%74 = load i32, i32* %4
%75 = add nsw i32 %74, -1
store i32 %75, i32* %4
br label %55
76: ; preds = %55
%77 = load double, double* %7
%78 = load double, double* %3
%79 = load double, double* %8
%80 = fsub double %78, %79
%81 = call double @sin(double %80)
%82 = fmul double %77, %81
%83 = load double, double* %3
%84 = call double @sqrt(double %83)
%85 = fdiv double %82, %84
store double %85, double* %2
br label %86
86: ; preds = %76, %44, %12
%87 = load double, double* %2
ret double %87
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Error : x <= 0 in besy0()\0A\00"
define double @besy0(double %0) {
%2 = fcmp ugt double %0, 0.000000e+00
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %46
6: ; preds = %1
%7 = fcmp ugt double %0, 3.000000e+00
br i1 %7, label %27, label %8
8: ; preds = %6
%9 = fmul double %0, %0
%10 = fdiv double %9, 9.000000e+00
%11 = tail call double @llvm.fmuladd.f64(double %10, double -2.484600e-04, double 4.279160e-03)
%12 = tail call double @llvm.fmuladd.f64(double %10, double 2.100000e-04, double -3.944400e-03)
%13 = tail call double @llvm.fmuladd.f64(double %11, double %10, double 0xBFA5D142276CD66D)
%14 = tail call double @llvm.fmuladd.f64(double %12, double %10, double 4.444790e-02)
%15 = tail call double @llvm.fmuladd.f64(double %13, double %10, double 0x3FD0312BD1BFFBAE)
%16 = tail call double @llvm.fmuladd.f64(double %14, double %10, double 0xBFD43FAD94F920E9)
%17 = tail call double @llvm.fmuladd.f64(double %15, double %10, double 0xBFE7CAC890A8036A)
%18 = tail call double @llvm.fmuladd.f64(double %16, double %10, double 0x3FF43FFB9892329D)
%19 = tail call double @llvm.fmuladd.f64(double %17, double %10, double 0x3FE36105F48BAD9E)
%20 = tail call double @llvm.fmuladd.f64(double %18, double %10, double 0xC001FFFFD7BC1418)
%21 = tail call double @llvm.fmuladd.f64(double %19, double %10, double 0x3FD78493EE33FAAE)
%22 = tail call double @llvm.fmuladd.f64(double %20, double %10, double 1.000000e+00)
%23 = fmul double %0, 5.000000e-01
%24 = tail call double @log(double %23)
%25 = fmul double %24, 0x3FE45F306DC9C880
%26 = tail call double @llvm.fmuladd.f64(double %25, double %22, double %21)
br label %46
27: ; preds = %6
%28 = fdiv double 3.000000e+00, %0
%29 = tail call double @llvm.fmuladd.f64(double %28, double 1.447600e-04, double -7.280500e-04)
%30 = tail call double @llvm.fmuladd.f64(double %28, double -1.355800e-04, double 2.933300e-04)
%31 = tail call double @llvm.fmuladd.f64(double %29, double %28, double 1.372370e-03)
%32 = tail call double @llvm.fmuladd.f64(double %30, double %28, double 5.412500e-04)
%33 = tail call double @llvm.fmuladd.f64(double %31, double %28, double 0xBF18EF652822DED2)
%34 = tail call double @llvm.fmuladd.f64(double %32, double %28, double -2.625730e-03)
%35 = tail call double @llvm.fmuladd.f64(double %33, double %28, double -5.527400e-03)
%36 = tail call double @llvm.fmuladd.f64(double %34, double %28, double 3.954000e-05)
%37 = tail call double @llvm.fmuladd.f64(double %35, double %28, double -7.700000e-07)
%38 = tail call double @llvm.fmuladd.f64(double %36, double %28, double 0x3FA554FAD9249EF1)
%39 = tail call double @llvm.fmuladd.f64(double %37, double %28, double 0x3FE988453365DE00)
%40 = tail call double @llvm.fmuladd.f64(double %38, double %28, double 0x3FE921FB52713C02)
%41 = fsub double %0, %40
%42 = tail call double @sin(double %41)
%43 = fmul double %39, %42
%44 = tail call double @sqrt(double %0)
%45 = fdiv double %43, %44
br label %46
46: ; preds = %27, %8, %3
%47 = phi double [ 0.000000e+00, %3 ], [ %26, %8 ], [ %45, %27 ]
ret double %47
}