#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 sqrt(double);
int /*<<< orphan*/ stderr;
double besi1(double x) {
  int i;
  double w, wx375;
  static double a[6] = {0.5,        0.87890594, 0.51498869,
                        0.15084934, 0.02658733, 0.00301532};
  static double b[8] = {0.39894228,  -0.039880242, -0.003620183, 0.001638014,
                        -0.01031555, 0.022829673,  -0.028953121, 0.017876535};
  if (x < 0.) {
    fprintf(stderr, "Error : x < 0  in besi1()\n");
    return 0.;
  }
  if (x <= 3.75) {
    wx375 = x * x / 14.0625;
    w = 0.00032411;
    for (i = 5; i >= 0; i--)
      w = w * wx375 + a[i];
    return w * x;
  }
  wx375 = 3.75 / x;
  w = -0.004200587;
  for (i = 7; i >= 0; i--)
    w = w * wx375 + b[i];
  return w / sqrt(x) * exp(x);
}


x86 assembly (clang, -O0):
<besi1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    116d <besi1+0x3d>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xec5(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a7 <besi1+0x177>
movsd  0xe8b(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1202 <besi1+0xd2>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe86(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe6d(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x5,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11ee <besi1+0xbe>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%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    11af <besi1+0x7f>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a7 <besi1+0x177>
movsd  0xdf6(%rip),%xmm0
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdec(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1267 <besi1+0x137>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movslq -0x14(%rbp),%rcx
lea    0x2e29(%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    1228 <besi1+0xf8>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <exp@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<besi1>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1160 <besi1+0x30>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xf3e(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
add    $0x18,%rsp
ret
movsd  0xe98(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    11f7 <besi1+0xc7>
divsd  %xmm1,%xmm0
movsd  0xeca(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xec6(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xec2(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xebe(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xeba(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xeb6(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xeb2(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xeae(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xeaa(%rip),%xmm2
movsd  %xmm2,0x8(%rsp)
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jb     1260 <besi1+0x130>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    1275 <besi1+0x145>
movapd %xmm1,%xmm2
mulsd  %xmm1,%xmm2
divsd  0xe01(%rip),%xmm2
movsd  0xe01(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xdfd(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xdf9(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xdf5(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xdf1(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xded(%rip),%xmm0
mulsd  %xmm2,%xmm0
addsd  0xde9(%rip),%xmm0
mulsd  %xmm1,%xmm0
add    $0x18,%rsp
ret
movapd %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
call   1050 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd %xmm1,%xmm0
call   1040 <exp@plt>
mulsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@besi1.a = internal global [6 x double] [double 5.000000e-01, double 0x3FEC1FFF5991ECA7, double 0x3FE07AC98FAB8428, double 0x3FC34F07FAF62AEA, double 0x3F9B39B5835A121A, double 3.015320e-03]
@besi1.b = internal global [8 x double] [double 0x3FD988453365DE00, double 0xBFA46B2EDE4B0AA7, double 0xBF6DA812F2E5AA02, double 0x3F5AD65423DD6E9F, double 0xBF852051AF1F3CDC, double 0x3F9760A96BA74B92, double 0xBF9DA5E30F3F9F38, double 0x3F924E39F4C360E8]
@stderr = global i32 0
@.str = [27 x i8] c"Error : x < 0 in besi1()\0A\00"
define double @besi1(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
store double %0, double* %3
%7 = load double, double* %3
%8 = fcmp olt double %7, 0.000000e+00
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %2
br label %63
12: ; preds = %1
%13 = load double, double* %3
%14 = fcmp ole double %13, 3.750000e+00
br i1 %14, label %15, label %38
15: ; preds = %12
%16 = load double, double* %3
%17 = load double, double* %3
%18 = fmul double %16, %17
%19 = fdiv double %18, 1.406250e+01
store double %19, double* %6
store double 3.241100e-04, double* %5
store i32 5, i32* %4
br label %20
20: ; preds = %31, %15
%21 = load i32, i32* %4
%22 = icmp sge i32 %21, 0
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load double, double* %5
%25 = load double, double* %6
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [6 x double], [6 x double]* @besi1.a, i64 0, i64 %27
%29 = load double, double* %28
%30 = call double @llvm.fmuladd.f64(double %24, double %25, double %29)
store double %30, double* %5
br label %31
31: ; preds = %23
%32 = load i32, i32* %4
%33 = add nsw i32 %32, -1
store i32 %33, i32* %4
br label %20
34: ; preds = %20
%35 = load double, double* %5
%36 = load double, double* %3
%37 = fmul double %35, %36
store double %37, double* %2
br label %63
38: ; preds = %12
%39 = load double, double* %3
%40 = fdiv double 3.750000e+00, %39
store double %40, double* %6
store double 0xBF7134A27C9FC15A, double* %5
store i32 7, i32* %4
br label %41
41: ; preds = %52, %38
%42 = load i32, i32* %4
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %55
44: ; preds = %41
%45 = load double, double* %5
%46 = load double, double* %6
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [8 x double], [8 x double]* @besi1.b, 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* %5
br label %52
52: ; preds = %44
%53 = load i32, i32* %4
%54 = add nsw i32 %53, -1
store i32 %54, i32* %4
br label %41
55: ; preds = %41
%56 = load double, double* %5
%57 = load double, double* %3
%58 = call double @sqrt(double %57)
%59 = fdiv double %56, %58
%60 = load double, double* %3
%61 = call double @exp(double %60)
%62 = fmul double %59, %61
store double %62, double* %2
br label %63
63: ; preds = %55, %34, %9
%64 = load double, double* %2
ret double %64
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"Error : x < 0 in besi1()\0A\00"
define double @besi1(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 ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
br label %32
6: ; preds = %1
%7 = fcmp ugt double %0, 3.750000e+00
br i1 %7, label %18, label %8
8: ; preds = %6
%9 = fmul double %0, %0
%10 = fdiv double %9, 1.406250e+01
%11 = tail call double @llvm.fmuladd.f64(double %10, double 3.241100e-04, double 3.015320e-03)
%12 = tail call double @llvm.fmuladd.f64(double %11, double %10, double 0x3F9B39B5835A121A)
%13 = tail call double @llvm.fmuladd.f64(double %12, double %10, double 0x3FC34F07FAF62AEA)
%14 = tail call double @llvm.fmuladd.f64(double %13, double %10, double 0x3FE07AC98FAB8428)
%15 = tail call double @llvm.fmuladd.f64(double %14, double %10, double 0x3FEC1FFF5991ECA7)
%16 = tail call double @llvm.fmuladd.f64(double %15, double %10, double 5.000000e-01)
%17 = fmul double %16, %0
br label %32
18: ; preds = %6
%19 = fdiv double 3.750000e+00, %0
%20 = tail call double @llvm.fmuladd.f64(double %19, double 0xBF7134A27C9FC15A, double 0x3F924E39F4C360E8)
%21 = tail call double @llvm.fmuladd.f64(double %20, double %19, double 0xBF9DA5E30F3F9F38)
%22 = tail call double @llvm.fmuladd.f64(double %21, double %19, double 0x3F9760A96BA74B92)
%23 = tail call double @llvm.fmuladd.f64(double %22, double %19, double 0xBF852051AF1F3CDC)
%24 = tail call double @llvm.fmuladd.f64(double %23, double %19, double 0x3F5AD65423DD6E9F)
%25 = tail call double @llvm.fmuladd.f64(double %24, double %19, double 0xBF6DA812F2E5AA02)
%26 = tail call double @llvm.fmuladd.f64(double %25, double %19, double 0xBFA46B2EDE4B0AA7)
%27 = tail call double @llvm.fmuladd.f64(double %26, double %19, double 0x3FD988453365DE00)
%28 = tail call double @sqrt(double %0)
%29 = fdiv double %27, %28
%30 = tail call double @exp(double %0)
%31 = fmul double %29, %30
br label %32
32: ; preds = %18, %8, %3
%33 = phi double [ 0.000000e+00, %3 ], [ %17, %8 ], [ %31, %18 ]
ret double %33
}