#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 pow(double const, double);
double bessel(double x) {
  double sum = 0.0;
  for (size_t i = 1; i < 10; ++i) {
    const double xpow = pow(x / 2.0, (double)i);
    size_t factorial = 1;
    for (size_t j = 1; j <= i; ++j)
      factorial *= j;
    sum += pow(xpow / (double)factorial, 2.0);
  }
  return 1.0 + sum;
}


x86 assembly (clang, -O0):
<bessel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
cmpq   $0xa,-0x18(%rbp)
jae    120e <bessel+0xfe>
movsd  -0x8(%rbp),%xmm0
movsd  0xec3(%rip),%xmm1
divsd  %xmm1,%xmm0
movaps 0xec0(%rip),%xmm2
movq   -0x18(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xebf(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x20(%rbp)
movq   $0x1,-0x28(%rbp)
movq   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     11b6 <bessel+0xa6>
mov    -0x30(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    118a <bessel+0x7a>
movsd  -0x20(%rbp),%xmm0
movaps 0xe4e(%rip),%xmm2
movq   -0x28(%rbp),%xmm1
punpckldq %xmm2,%xmm1
movapd 0xe4d(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  0xe1a(%rip),%xmm1
call   1030 <pow@plt>
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112d <bessel+0x1d>
movsd  0xdea(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bessel>:
sub    $0x48,%rsp
movsd  0xee4(%rip),%xmm2
mulsd  %xmm2,%xmm0
movapd %xmm0,%xmm3
movsd  %xmm0,0x8(%rsp)
mulsd  %xmm0,%xmm3
xorpd  %xmm1,%xmm1
addsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm3
mulsd  %xmm3,%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,0x10(%rsp)
movsd  0xeb8(%rip),%xmm1
call   1030 <pow@plt>
divsd  0xeb3(%rip),%xmm0
mulsd  %xmm0,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0xea3(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movaps %xmm0,0x10(%rsp)
movsd  0xe93(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movapd 0x10(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
divpd  0xea6(%rip),%xmm1
mulpd  %xmm1,%xmm1
movapd %xmm1,0x10(%rsp)
movsd  0x20(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0xe3e(%rip),%xmm1
call   1030 <pow@plt>
movaps %xmm0,0x30(%rsp)
movapd 0x10(%rsp),%xmm0
unpckhpd %xmm0,%xmm0
addsd  0x20(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0xe2e(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movapd 0x30(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
divpd  0xe49(%rip),%xmm1
mulpd  %xmm1,%xmm1
movapd %xmm1,0x30(%rsp)
movapd 0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
movsd  0xdf7(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movaps %xmm0,0x20(%rsp)
movapd 0x30(%rsp),%xmm0
unpckhpd %xmm0,%xmm0
addsd  0x10(%rsp),%xmm0
movapd %xmm0,0x30(%rsp)
movsd  0xdd1(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
call   1030 <pow@plt>
movapd 0x20(%rsp),%xmm1
unpcklpd %xmm0,%xmm1
divpd  0xdec(%rip),%xmm1
mulpd  %xmm1,%xmm1
movapd 0x30(%rsp),%xmm0
addsd  %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
addsd  0xd9e(%rip),%xmm1
movapd %xmm1,%xmm0
add    $0x48,%rsp
ret

LLVM IR (-O0):
define double @bessel(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i64
%5 = alloca double
%6 = alloca i64
%7 = alloca i64
store double %0, double* %2
store double 0.000000e+00, double* %3
store i64 1, i64* %4
br label %8
8: ; preds = %36, %1
%9 = load i64, i64* %4
%10 = icmp ult i64 %9, 10
br i1 %10, label %11, label %39
11: ; preds = %8
%12 = load double, double* %2
%13 = fdiv double %12, 2.000000e+00
%14 = load i64, i64* %4
%15 = uitofp i64 %14 to double
%16 = call double @pow(double %13, double %15)
store double %16, double* %5
store i64 1, i64* %6
store i64 1, i64* %7
br label %17
17: ; preds = %25, %11
%18 = load i64, i64* %7
%19 = load i64, i64* %4
%20 = icmp ule i64 %18, %19
br i1 %20, label %21, label %28
21: ; preds = %17
%22 = load i64, i64* %7
%23 = load i64, i64* %6
%24 = mul i64 %23, %22
store i64 %24, i64* %6
br label %25
25: ; preds = %21
%26 = load i64, i64* %7
%27 = add i64 %26, 1
store i64 %27, i64* %7
br label %17
28: ; preds = %17
%29 = load double, double* %5
%30 = load i64, i64* %6
%31 = uitofp i64 %30 to double
%32 = fdiv double %29, %31
%33 = call double @pow(double %32, double 2.000000e+00)
%34 = load double, double* %3
%35 = fadd double %34, %33
store double %35, double* %3
br label %36
36: ; preds = %28
%37 = load i64, i64* %4
%38 = add i64 %37, 1
store i64 %38, i64* %4
br label %8
39: ; preds = %8
%40 = load double, double* %3
%41 = fadd double 1.000000e+00, %40
ret double %41
}

LLVM IR (-O2):
define double @bessel(double %0) {
%2 = fmul double %0, 5.000000e-01
%3 = fmul double %2, %2
%4 = fmul double %2, %2
%5 = fadd double %3, 0.000000e+00
%6 = fmul double %4, 5.000000e-01
%7 = fmul double %6, %6
%8 = tail call double @pow(double %2, double 3.000000e+00)
%9 = fadd double %5, %7
%10 = fdiv double %8, 6.000000e+00
%11 = fmul double %10, %10
%12 = tail call double @pow(double %2, double 4.000000e+00)
%13 = fadd double %9, %11
%14 = tail call double @pow(double %2, double 5.000000e+00)
%15 = insertelement <2 x double> poison, double %12, i64 0
%16 = insertelement <2 x double> %15, double %14, i64 1
%17 = fdiv <2 x double> %16, <double 2.400000e+01, double 1.200000e+02>
%18 = fmul <2 x double> %17, %17
%19 = extractelement <2 x double> %18, i64 0
%20 = fadd double %13, %19
%21 = tail call double @pow(double %2, double 6.000000e+00)
%22 = extractelement <2 x double> %18, i64 1
%23 = fadd double %20, %22
%24 = tail call double @pow(double %2, double 7.000000e+00)
%25 = insertelement <2 x double> poison, double %21, i64 0
%26 = insertelement <2 x double> %25, double %24, i64 1
%27 = fdiv <2 x double> %26, <double 7.200000e+02, double 5.040000e+03>
%28 = fmul <2 x double> %27, %27
%29 = extractelement <2 x double> %28, i64 0
%30 = fadd double %23, %29
%31 = tail call double @pow(double %2, double 8.000000e+00)
%32 = extractelement <2 x double> %28, i64 1
%33 = fadd double %30, %32
%34 = tail call double @pow(double %2, double 9.000000e+00)
%35 = insertelement <2 x double> poison, double %31, i64 0
%36 = insertelement <2 x double> %35, double %34, i64 1
%37 = fdiv <2 x double> %36, <double 4.032000e+04, double 3.628800e+05>
%38 = fmul <2 x double> %37, %37
%39 = extractelement <2 x double> %38, i64 0
%40 = fadd double %33, %39
%41 = extractelement <2 x double> %38, i64 1
%42 = fadd double %40, %41
%43 = fadd double %42, 1.000000e+00
ret double %43
}