#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 factorial(int);
double pow(double, int);
double besseli0(double x) {
  int k;
  double result = 0.0;
  for (k = 1; k < 25; k++) {
    double temp;
    temp = pow(0.5 * x, k) / factorial(k);
    result += temp * temp;
  };
  return 1.0 + result;
}


x86 assembly (clang, -O0):
<besseli0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x19,-0xc(%rbp)
jge    11a3 <besseli0+0x83>
movsd  0xeba(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%edi
call   1040 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <factorial@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113c <besseli0+0x1c>
movsd  0xe55(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<besseli0>:
push   %rbx
sub    $0x20,%rsp
mulsd  0xed3(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
mov    $0x1,%ebx
nopl   0x0(%rax)
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edi
call   1040 <pow@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1030 <factorial@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%ebx
cmp    $0x19,%ebx
jne    1140 <besseli0+0x20>
addsd  0xe80(%rip),%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @besseli0(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store double %0, double* %2
store double 0.000000e+00, double* %4
store i32 1, i32* %3
br label %6
6: ; preds = %21, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 25
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load double, double* %2
%11 = fmul double 5.000000e-01, %10
%12 = load i32, i32* %3
%13 = call double @pow(double %11, i32 %12)
%14 = load i32, i32* %3
%15 = call double @factorial(i32 %14)
%16 = fdiv double %13, %15
store double %16, double* %5
%17 = load double, double* %5
%18 = load double, double* %5
%19 = load double, double* %4
%20 = call double @llvm.fmuladd.f64(double %17, double %18, double %19)
store double %20, double* %4
br label %21
21: ; preds = %9
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %6
24: ; preds = %6
%25 = load double, double* %4
%26 = fadd double 1.000000e+00, %25
ret double %26
}

LLVM IR (-O2):
define double @besseli0(double %0) {
%2 = fmul double %0, 5.000000e-01
br label %3
3: ; preds = %1, %3
%4 = phi i32 [ 1, %1 ], [ %10, %3 ]
%5 = phi double [ 0.000000e+00, %1 ], [ %9, %3 ]
%6 = tail call double @pow(double %2, i32 %4)
%7 = tail call double @factorial(i32 %4)
%8 = fdiv double %6, %7
%9 = tail call double @llvm.fmuladd.f64(double %8, double %8, double %5)
%10 = add nuw nsw i32 %4, 1
%11 = icmp eq i32 %10, 25
br i1 %11, label %12, label %3
12: ; preds = %3
%13 = fadd double %9, 1.000000e+00
ret double %13
}