#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 exp(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double log(double);
double sqrt(double);
int /*<<< orphan*/ stderr;
double besk1(double x) {
  int i;
  double bi1, w, wx2, wx375;
  static double a[6] = {1.0,         0.15443144,  -0.67278579,
                        -0.18156897, -0.01919402, -0.00110404};
  static double b[6] = {0.5,        0.87890594, 0.51498869,
                        0.15084934, 0.02658733, 0.003011532};
  static double c[6] = {1.25331414, 0.23498619,  -0.0365562,
                        0.01504268, -0.00780353, 0.00325614};
  if (x <= 0.) {
    fprintf(stderr, "Error : x <= 0  in besk1()\n");
    return 0.;
  }
  if (x <= 2.) {
    wx2 = x * x / 4.;
    wx375 = x * x / 14.0625;
    w = -0.00004686;
    bi1 = 0.00032411;
    for (i = 5; i >= 0; i--) {
      w = w * wx2 + a[i];
      bi1 = bi1 * wx375 + b[i];
    }
    return w / x + log(x / 2.) * bi1 * x;
  }
  wx2 = 2. / x;
  w = -0.00068245;
  for (i = 5; i >= 0; i--)
    w = w * wx2 + c[i];
  return w / sqrt(x) / exp(x);
}


x86 assembly (clang, -O0):
<besk1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     117d <besk1+0x3d>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xec5(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1338 <besk1+0x1f8>
movsd  0xe7b(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1293 <besk1+0x153>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe86(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe63(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe4a(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe35(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x5,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     124d <besk1+0x10d>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e4a(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e53(%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    11e7 <besk1+0xa7>
movsd  -0x28(%rbp),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xd97(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log@plt>
movsd  -0x40(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1338 <besk1+0x1f8>
movsd  0xd65(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xd5b(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x5,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     12f8 <besk1+0x1b8>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2dd8(%rip),%rax
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    12b9 <besk1+0x179>
movsd  -0x28(%rbp),%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,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<besk1>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jae    11db <besk1+0x9b>
movsd  0xea2(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    11f9 <besk1+0xb9>
divsd  %xmm1,%xmm0
movsd  0xf14(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xf10(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xf0c(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xf08(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xf04(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xf00(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xefc(%rip),%xmm2
movsd  %xmm2,(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     12f1 <besk1+0x1b1>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    1306 <besk1+0x1c6>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xed5(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
ret
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm1,%xmm2
movsd  0xdfb(%rip),%xmm1
mulsd  %xmm0,%xmm1
divsd  0xdf7(%rip),%xmm0
movsd  0xdf7(%rip),%xmm3
mulsd  %xmm1,%xmm3
addsd  0xdf3(%rip),%xmm3
movsd  0xdf3(%rip),%xmm4
mulsd  %xmm0,%xmm4
addsd  0xdef(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xdeb(%rip),%xmm3
mulsd  %xmm0,%xmm4
addsd  0xde7(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xde3(%rip),%xmm3
mulsd  %xmm0,%xmm4
addsd  0xddf(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xddb(%rip),%xmm3
mulsd  %xmm0,%xmm4
addsd  0xdd7(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xdd3(%rip),%xmm3
mulsd  %xmm0,%xmm4
addsd  0xdcf(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xdcb(%rip),%xmm3
mulsd  %xmm0,%xmm4
movsd  0xdc7(%rip),%xmm0
addsd  %xmm0,%xmm4
movsd  %xmm4,0x10(%rsp)
movsd  %xmm2,0x8(%rsp)
divsd  %xmm2,%xmm3
movsd  %xmm3,(%rsp)
mulsd  %xmm2,%xmm0
call   1050 <log@plt>
mulsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
add    $0x18,%rsp
ret
movapd %xmm1,%xmm0
movsd  %xmm1,0x8(%rsp)
call   1060 <sqrt@plt>
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
movapd %xmm1,%xmm0
call   1040 <exp@plt>
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@besk1.a = internal global [6 x double] [double 1.000000e+00, double 0x3FC3C468D0231889, double 0xBFE5877610A86ECA, double 0xBFC73DA6EA0F27E6, double 0xBF93A798E0B70F76, double -1.104040e-03]
@besk1.b = internal global [6 x double] [double 5.000000e-01, double 0x3FEC1FFF5991ECA7, double 0x3FE07AC98FAB8428, double 0x3FC34F07FAF62AEA, double 0x3F9B39B5835A121A, double 0x3F68ABA3EE6D6CA6]
@besk1.c = internal global [6 x double] [double 0x3FF40D9320AEA13E, double 0x3FCE14070887E3E5, double -3.655620e-02, double 0x3F8ECEB255274ECE, double -7.803530e-03, double 3.256140e-03]
@stderr = global i32 0
@.str = [28 x i8] c"Error : x <= 0 in besk1()\0A\00"
define double @besk1(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 ole 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 ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %83
14: ; preds = %1
%15 = load double, double* %3
%16 = fcmp ole double %15, 2.000000e+00
br i1 %16, label %17, label %58
17: ; preds = %14
%18 = load double, double* %3
%19 = load double, double* %3
%20 = fmul double %18, %19
%21 = fdiv double %20, 4.000000e+00
store double %21, double* %7
%22 = load double, double* %3
%23 = load double, double* %3
%24 = fmul double %22, %23
%25 = fdiv double %24, 1.406250e+01
store double %25, double* %8
store double -4.686000e-05, double* %6
store double 3.241100e-04, double* %5
store i32 5, i32* %4
br label %26
26: ; preds = %44, %17
%27 = load i32, i32* %4
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %47
29: ; preds = %26
%30 = load double, double* %6
%31 = load double, double* %7
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [6 x double], [6 x double]* @besk1.a, i64 0, i64 %33
%35 = load double, double* %34
%36 = call double @llvm.fmuladd.f64(double %30, double %31, double %35)
store double %36, double* %6
%37 = load double, double* %5
%38 = load double, double* %8
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [6 x double], [6 x double]* @besk1.b, i64 0, i64 %40
%42 = load double, double* %41
%43 = call double @llvm.fmuladd.f64(double %37, double %38, double %42)
store double %43, double* %5
br label %44
44: ; preds = %29
%45 = load i32, i32* %4
%46 = add nsw i32 %45, -1
store i32 %46, i32* %4
br label %26
47: ; preds = %26
%48 = load double, double* %6
%49 = load double, double* %3
%50 = fdiv double %48, %49
%51 = load double, double* %3
%52 = fdiv double %51, 2.000000e+00
%53 = call double @log(double %52)
%54 = load double, double* %5
%55 = fmul double %53, %54
%56 = load double, double* %3
%57 = call double @llvm.fmuladd.f64(double %55, double %56, double %50)
store double %57, double* %2
br label %83
58: ; preds = %14
%59 = load double, double* %3
%60 = fdiv double 2.000000e+00, %59
store double %60, double* %7
store double -6.824500e-04, double* %6
store i32 5, i32* %4
br label %61
61: ; preds = %72, %58
%62 = load i32, i32* %4
%63 = icmp sge i32 %62, 0
br i1 %63, label %64, label %75
64: ; preds = %61
%65 = load double, double* %6
%66 = load double, double* %7
%67 = load i32, i32* %4
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [6 x double], [6 x double]* @besk1.c, i64 0, i64 %68
%70 = load double, double* %69
%71 = call double @llvm.fmuladd.f64(double %65, double %66, double %70)
store double %71, double* %6
br label %72
72: ; preds = %64
%73 = load i32, i32* %4
%74 = add nsw i32 %73, -1
store i32 %74, i32* %4
br label %61
75: ; preds = %61
%76 = load double, double* %6
%77 = load double, double* %3
%78 = call double @sqrt(double %77)
%79 = fdiv double %76, %78
%80 = load double, double* %3
%81 = call double @exp(double %80)
%82 = fdiv double %79, %81
store double %82, double* %2
br label %83
83: ; preds = %75, %47, %11
%84 = load double, double* %2
ret double %84
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Error : x <= 0 in besk1()\0A\00"
define double @besk1(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 %41
6: ; preds = %1
%7 = fcmp ugt double %0, 2.000000e+00
br i1 %7, label %29, label %8
8: ; preds = %6
%9 = fmul double %0, %0
%10 = fmul double %9, 2.500000e-01
%11 = fdiv double %9, 1.406250e+01
%12 = tail call double @llvm.fmuladd.f64(double %10, double -4.686000e-05, double -1.104040e-03)
%13 = tail call double @llvm.fmuladd.f64(double %11, double 3.241100e-04, double 0x3F68ABA3EE6D6CA6)
%14 = tail call double @llvm.fmuladd.f64(double %12, double %10, double 0xBF93A798E0B70F76)
%15 = tail call double @llvm.fmuladd.f64(double %13, double %11, double 0x3F9B39B5835A121A)
%16 = tail call double @llvm.fmuladd.f64(double %14, double %10, double 0xBFC73DA6EA0F27E6)
%17 = tail call double @llvm.fmuladd.f64(double %15, double %11, double 0x3FC34F07FAF62AEA)
%18 = tail call double @llvm.fmuladd.f64(double %16, double %10, double 0xBFE5877610A86ECA)
%19 = tail call double @llvm.fmuladd.f64(double %17, double %11, double 0x3FE07AC98FAB8428)
%20 = tail call double @llvm.fmuladd.f64(double %18, double %10, double 0x3FC3C468D0231889)
%21 = tail call double @llvm.fmuladd.f64(double %19, double %11, double 0x3FEC1FFF5991ECA7)
%22 = tail call double @llvm.fmuladd.f64(double %20, double %10, double 1.000000e+00)
%23 = tail call double @llvm.fmuladd.f64(double %21, double %11, double 5.000000e-01)
%24 = fdiv double %22, %0
%25 = fmul double %0, 5.000000e-01
%26 = tail call double @log(double %25)
%27 = fmul double %23, %26
%28 = tail call double @llvm.fmuladd.f64(double %27, double %0, double %24)
br label %41
29: ; preds = %6
%30 = fdiv double 2.000000e+00, %0
%31 = tail call double @llvm.fmuladd.f64(double %30, double -6.824500e-04, double 3.256140e-03)
%32 = tail call double @llvm.fmuladd.f64(double %31, double %30, double -7.803530e-03)
%33 = tail call double @llvm.fmuladd.f64(double %32, double %30, double 0x3F8ECEB255274ECE)
%34 = tail call double @llvm.fmuladd.f64(double %33, double %30, double -3.655620e-02)
%35 = tail call double @llvm.fmuladd.f64(double %34, double %30, double 0x3FCE14070887E3E5)
%36 = tail call double @llvm.fmuladd.f64(double %35, double %30, double 0x3FF40D9320AEA13E)
%37 = tail call double @sqrt(double %0)
%38 = fdiv double %36, %37
%39 = tail call double @exp(double %0)
%40 = fdiv double %38, %39
br label %41
41: ; preds = %29, %8, %3
%42 = phi double [ 0.000000e+00, %3 ], [ %28, %8 ], [ %40, %29 ]
ret double %42
}