#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 INFINITY;
double NAN;
double exp(double const);
double limitK0_08(double const);
double limitK0e_upper(double const);
double sqrt(double const);
void bessel0e(const double *x, double *res, const int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (x[i] < 0)
      res[i] = NAN;
    else if (x[i] == 0)
      res[i] = INFINITY;
    else if (x[i] < 0.8) {
      res[i] = limitK0_08(x[i]);
      res[i] *= exp(x[i]) * sqrt(x[i]);
    } else
      res[i] = limitK0e_upper(x[i]);
  }
}


x86 assembly (clang, -O0):
<bessel0e>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1298 <bessel0e+0x158>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    1199 <bessel0e+0x59>
mov    0x2e75(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1285 <bessel0e+0x145>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11d6 <bessel0e+0x96>
jp     11d6 <bessel0e+0x96>
mov    0x2e20(%rip),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1280 <bessel0e+0x140>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  0xe1a(%rip),%xmm0
ucomisd (%rax,%rcx,8),%xmm0
jbe    125c <bessel0e+0x11c>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <limitK0_08@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    127b <bessel0e+0x13b>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1060 <limitK0e_upper@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1280 <bessel0e+0x140>
jmp    1285 <bessel0e+0x145>
jmp    128a <bessel0e+0x14a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115a <bessel0e+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bessel0e>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1225 <bessel0e+0xe5>
mov    %rsi,%r14
mov    %rdi,%r12
mov    %edx,%r15d
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
mov    0x2e8f(%rip),%r13
mov    0x2e70(%rip),%rbp
jmp    1199 <bessel0e+0x59>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x0(%r13),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1225 <bessel0e+0xe5>
movsd  (%r12,%rbx,8),%xmm0
ucomisd %xmm0,%xmm1
ja     1180 <bessel0e+0x40>
ucomisd %xmm1,%xmm0
jne    11b4 <bessel0e+0x74>
jp     11b4 <bessel0e+0x74>
movsd  0x0(%rbp),%xmm0
jmp    1186 <bessel0e+0x46>
movsd  0xe44(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    11f2 <bessel0e+0xb2>
call   1030 <limitK0_08@plt>
movsd  %xmm0,(%r14,%rbx,8)
movsd  (%r12,%rbx,8),%xmm0
call   1040 <exp@plt>
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm2
movsd  (%r12,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11fd <bessel0e+0xbd>
sqrtsd %xmm0,%xmm0
jmp    1210 <bessel0e+0xd0>
call   1060 <limitK0e_upper@plt>
xorpd  %xmm1,%xmm1
jmp    1186 <bessel0e+0x46>
movsd  %xmm2,(%rsp)
call   1050 <sqrt@plt>
movsd  (%rsp),%xmm2
xorpd  %xmm1,%xmm1
mulsd  %xmm0,%xmm2
mulsd  (%r14,%rbx,8),%xmm2
movsd  %xmm2,(%r14,%rbx,8)
jmp    118c <bessel0e+0x4c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
define void @bessel0e(double* %0, double* %1, i32 %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %89, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %92
12: ; preds = %8
%13 = load double*, double** %4
%14 = load i32, i32* %7
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds double, double* %13, i64 %15
%17 = load double, double* %16
%18 = fcmp olt double %17, 0.000000e+00
br i1 %18, label %19, label %25
19: ; preds = %12
%20 = load double, double* @NAN
%21 = load double*, double** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %21, i64 %23
store double %20, double* %24
br label %88
25: ; preds = %12
%26 = load double*, double** %4
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds double, double* %26, i64 %28
%30 = load double, double* %29
%31 = fcmp oeq double %30, 0.000000e+00
br i1 %31, label %32, label %38
32: ; preds = %25
%33 = load double, double* @INFINITY
%34 = load double*, double** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
store double %33, double* %37
br label %87
38: ; preds = %25
%39 = load double*, double** %4
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = fcmp olt double %43, 8.000000e-01
br i1 %44, label %45, label %75
45: ; preds = %38
%46 = load double*, double** %4
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %46, i64 %48
%50 = load double, double* %49
%51 = call double @limitK0_08(double %50)
%52 = load double*, double** %5
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds double, double* %52, i64 %54
store double %51, double* %55
%56 = load double*, double** %4
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds double, double* %56, i64 %58
%60 = load double, double* %59
%61 = call double @exp(double %60)
%62 = load double*, double** %4
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds double, double* %62, i64 %64
%66 = load double, double* %65
%67 = call double @sqrt(double %66)
%68 = fmul double %61, %67
%69 = load double*, double** %5
%70 = load i32, i32* %7
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %69, i64 %71
%73 = load double, double* %72
%74 = fmul double %73, %68
store double %74, double* %72
br label %86
75: ; preds = %38
%76 = load double*, double** %4
%77 = load i32, i32* %7
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
%80 = load double, double* %79
%81 = call double @limitK0e_upper(double %80)
%82 = load double*, double** %5
%83 = load i32, i32* %7
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds double, double* %82, i64 %84
store double %81, double* %85
br label %86
86: ; preds = %75, %45
br label %87
87: ; preds = %86, %32
br label %88
88: ; preds = %87, %19
br label %89
89: ; preds = %88
%90 = load i32, i32* %7
%91 = add nsw i32 %90, 1
store i32 %91, i32* %7
br label %8
92: ; preds = %8
ret void
}

LLVM IR (-O2):
@NAN = global double 0.000000e+00
@INFINITY = global double 0.000000e+00
define void @bessel0e(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %38
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %35
%8 = phi i64 [ 0, %5 ], [ %36, %35 ]
%9 = getelementptr inbounds double, double* %0, i64 %8
%10 = load double, double* %9
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load double, double* @NAN
%14 = getelementptr inbounds double, double* %1, i64 %8
store double %13, double* %14
br label %35
15: ; preds = %7
%16 = fcmp oeq double %10, 0.000000e+00
br i1 %16, label %17, label %20
17: ; preds = %15
%18 = load double, double* @INFINITY
%19 = getelementptr inbounds double, double* %1, i64 %8
store double %18, double* %19
br label %35
20: ; preds = %15
%21 = fcmp olt double %10, 8.000000e-01
br i1 %21, label %22, label %32
22: ; preds = %20
%23 = tail call double @limitK0_08(double %10)
%24 = getelementptr inbounds double, double* %1, i64 %8
store double %23, double* %24
%25 = load double, double* %9
%26 = tail call double @exp(double %25)
%27 = load double, double* %9
%28 = tail call double @sqrt(double %27)
%29 = fmul double %26, %28
%30 = load double, double* %24
%31 = fmul double %30, %29
store double %31, double* %24
br label %35
32: ; preds = %20
%33 = tail call double @limitK0e_upper(double %10)
%34 = getelementptr inbounds double, double* %1, i64 %8
store double %33, double* %34
br label %35
35: ; preds = %12, %22, %32, %17
%36 = add nuw nsw i64 %8, 1
%37 = icmp eq i64 %36, %6
br i1 %37, label %38, label %7
38: ; preds = %35, %3
ret void
}