#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 besk0(double x) {
  int i;
  double bi0, w, wx2, wx375;
  static double a[6] = {-0.57721566, 0.42278442, 0.23069756,
                        0.0348859,   0.00262698, 0.0001075};
  static double b[6] = {1.0,       3.5156229, 3.0899424,
                        1.2067492, 0.2659732, 0.0360768};
  static double c[6] = {1.25331414,  -0.07832358, 0.02189568,
                        -0.01062446, 0.00587872,  -0.0025154};
  if (x <= 0.) {
    fprintf(stderr, "Error : x <= 0  in besk0()\n");
    return 0.;
  }
  if (x <= 2.) {
    wx2 = x * x / 4.;
    wx375 = x * x / 14.0625;
    w = 0.0000074;
    bi0 = 0.0045813;
    for (i = 5; i >= 0; i--) {
      w = w * wx2 + a[i];
      bi0 = bi0 * wx375 + b[i];
    }
    return w - log(x / 2.) * bi0;
  }
  wx2 = 2. / x;
  w = 0.00053208;
  for (i = 5; i >= 0; i--)
    w = w * wx2 + c[i];
  return w / sqrt(x) / exp(x);
}


x86 assembly (clang, -O0):
<besk0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     117d <besk0+0x3d>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xec5(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1345 <besk0+0x205>
movsd  0xe7b(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     12a0 <besk0+0x160>
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 <besk0+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 <besk0+0xa7>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xd9c(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <log@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1345 <besk0+0x205>
movsd  0xd58(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xd4e(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x5,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1305 <besk0+0x1c5>
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2dcb(%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    12c6 <besk0+0x186>
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):
<besk0>:
sub    $0x18,%rsp
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jae    11dc <besk0+0x9c>
movsd  0xea2(%rip),%xmm0
ucomisd %xmm2,%xmm0
jae    11fa <besk0+0xba>
divsd  %xmm2,%xmm0
movsd  0xf1c(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf18(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf14(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf10(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf0c(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf08(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xf04(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jb     12e5 <besk0+0x1a5>
xorps  %xmm0,%xmm0
sqrtsd %xmm2,%xmm0
jmp    12fa <besk0+0x1ba>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
ret
movapd %xmm2,%xmm0
mulsd  %xmm2,%xmm0
movsd  0xdfe(%rip),%xmm1
mulsd  %xmm0,%xmm1
divsd  0xdfa(%rip),%xmm0
movsd  0xdfa(%rip),%xmm3
mulsd  %xmm1,%xmm3
addsd  0xdf6(%rip),%xmm3
movsd  0xdf6(%rip),%xmm4
mulsd  %xmm0,%xmm4
addsd  0xdf2(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xdee(%rip),%xmm3
mulsd  %xmm0,%xmm4
addsd  0xdea(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xde6(%rip),%xmm3
mulsd  %xmm0,%xmm4
addsd  0xde2(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xdde(%rip),%xmm3
mulsd  %xmm0,%xmm4
addsd  0xdda(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xdd6(%rip),%xmm3
mulsd  %xmm0,%xmm4
addsd  0xdd2(%rip),%xmm4
mulsd  %xmm1,%xmm3
addsd  0xdce(%rip),%xmm3
movsd  %xmm3,0x8(%rsp)
mulsd  %xmm0,%xmm4
addsd  0xdc4(%rip),%xmm4
movsd  %xmm4,0x10(%rsp)
mulsd  0xdbe(%rip),%xmm2
movapd %xmm2,%xmm0
call   1050 <log@plt>
mulsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
jmp    131d <besk0+0x1dd>
movapd %xmm2,%xmm0
movsd  %xmm2,0x10(%rsp)
call   1060 <sqrt@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm2,%xmm0
call   1040 <exp@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@besk0.a = internal global [6 x double] [double 0xBFE2788CF9CE0CBE, double 0x3FDB0EE6624A220D, double 0x3FCD877F65BBC695, double 3.488590e-02, double 2.626980e-03, double 1.075000e-04]
@besk0.b = internal global [6 x double] [double 1.000000e+00, double 0x400C1FFEE6248CA7, double 0x4008B833B89430A4, double 0x3FF34ED83FC7962C, double 0x3FD105B474E732AA, double 3.607680e-02]
@besk0.c = internal global [6 x double] [double 0x3FF40D9320AEA13E, double 0xBFB40D039E9B0B34, double 0x3F966BD236183FE8, double 0xBF85C246E1E6BA5F, double 5.878720e-03, double -2.515400e-03]
@stderr = global i32 0
@.str = [28 x i8] c"Error : x <= 0 in besk0()\0A\00"
define double @besk0(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 %80
14: ; preds = %1
%15 = load double, double* %3
%16 = fcmp ole double %15, 2.000000e+00
br i1 %16, label %17, label %55
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 7.400000e-06, double* %6
store double 4.581300e-03, 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]* @besk0.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]* @besk0.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 %49, 2.000000e+00
%51 = call double @log(double %50)
%52 = load double, double* %5
%53 = fneg double %51
%54 = call double @llvm.fmuladd.f64(double %53, double %52, double %48)
store double %54, double* %2
br label %80
55: ; preds = %14
%56 = load double, double* %3
%57 = fdiv double 2.000000e+00, %56
store double %57, double* %7
store double 5.320800e-04, double* %6
store i32 5, i32* %4
br label %58
58: ; preds = %69, %55
%59 = load i32, i32* %4
%60 = icmp sge i32 %59, 0
br i1 %60, label %61, label %72
61: ; preds = %58
%62 = load double, double* %6
%63 = load double, double* %7
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [6 x double], [6 x double]* @besk0.c, i64 0, i64 %65
%67 = load double, double* %66
%68 = call double @llvm.fmuladd.f64(double %62, double %63, double %67)
store double %68, double* %6
br label %69
69: ; preds = %61
%70 = load i32, i32* %4
%71 = add nsw i32 %70, -1
store i32 %71, i32* %4
br label %58
72: ; preds = %58
%73 = load double, double* %6
%74 = load double, double* %3
%75 = call double @sqrt(double %74)
%76 = fdiv double %73, %75
%77 = load double, double* %3
%78 = call double @exp(double %77)
%79 = fdiv double %76, %78
store double %79, double* %2
br label %80
80: ; preds = %72, %47, %11
%81 = load double, double* %2
ret double %81
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Error : x <= 0 in besk0()\0A\00"
define double @besk0(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 %40
6: ; preds = %1
%7 = fcmp ugt double %0, 2.000000e+00
br i1 %7, label %28, 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 7.400000e-06, double 1.075000e-04)
%13 = tail call double @llvm.fmuladd.f64(double %11, double 4.581300e-03, double 3.607680e-02)
%14 = tail call double @llvm.fmuladd.f64(double %12, double %10, double 2.626980e-03)
%15 = tail call double @llvm.fmuladd.f64(double %13, double %11, double 0x3FD105B474E732AA)
%16 = tail call double @llvm.fmuladd.f64(double %14, double %10, double 3.488590e-02)
%17 = tail call double @llvm.fmuladd.f64(double %15, double %11, double 0x3FF34ED83FC7962C)
%18 = tail call double @llvm.fmuladd.f64(double %16, double %10, double 0x3FCD877F65BBC695)
%19 = tail call double @llvm.fmuladd.f64(double %17, double %11, double 0x4008B833B89430A4)
%20 = tail call double @llvm.fmuladd.f64(double %18, double %10, double 0x3FDB0EE6624A220D)
%21 = tail call double @llvm.fmuladd.f64(double %19, double %11, double 0x400C1FFEE6248CA7)
%22 = tail call double @llvm.fmuladd.f64(double %20, double %10, double 0xBFE2788CF9CE0CBE)
%23 = tail call double @llvm.fmuladd.f64(double %21, double %11, double 1.000000e+00)
%24 = fmul double %0, 5.000000e-01
%25 = tail call double @log(double %24)
%26 = fneg double %25
%27 = tail call double @llvm.fmuladd.f64(double %26, double %23, double %22)
br label %40
28: ; preds = %6
%29 = fdiv double 2.000000e+00, %0
%30 = tail call double @llvm.fmuladd.f64(double %29, double 5.320800e-04, double -2.515400e-03)
%31 = tail call double @llvm.fmuladd.f64(double %30, double %29, double 5.878720e-03)
%32 = tail call double @llvm.fmuladd.f64(double %31, double %29, double 0xBF85C246E1E6BA5F)
%33 = tail call double @llvm.fmuladd.f64(double %32, double %29, double 0x3F966BD236183FE8)
%34 = tail call double @llvm.fmuladd.f64(double %33, double %29, double 0xBFB40D039E9B0B34)
%35 = tail call double @llvm.fmuladd.f64(double %34, double %29, double 0x3FF40D9320AEA13E)
%36 = tail call double @sqrt(double %0)
%37 = fdiv double %35, %36
%38 = tail call double @exp(double %0)
%39 = fdiv double %37, %38
br label %40
40: ; preds = %28, %8, %3
%41 = phi double [ 0.000000e+00, %3 ], [ %27, %8 ], [ %39, %28 ]
ret double %41
}