#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 */
scalar_t__ factorielle(size_t, int);
double pow(double, size_t);
double dl_exponential(double x, long ordre) {
  size_t i = 0;
  double value = 0;
  for (i = 0; i <= ordre; i++)
    value += pow(x, i) / (double)factorielle(i, 1);
  return value;
}


x86 assembly (clang, -O0):
<dl_exponential>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     11a1 <dl_exponential+0x81>
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rdi
call   1030 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1040 <factorielle@plt>
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %rax,%xmm1
divsd  %xmm1,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1149 <dl_exponential+0x29>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dl_exponential>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
movsd  %xmm0,(%rsp)
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
mov    %rbx,%rdi
call   1030 <pow@plt>
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <factorielle@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0x1,%rbx
cmp    %r14,%rbx
jbe    1140 <dl_exponential+0x20>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @dl_exponential(double %0, i64 %1) {
%3 = alloca double
%4 = alloca i64
%5 = alloca i64
%6 = alloca double
store double %0, double* %3
store i64 %1, i64* %4
store i64 0, i64* %5
store double 0.000000e+00, double* %6
store i64 0, i64* %5
br label %7
7: ; preds = %21, %2
%8 = load i64, i64* %5
%9 = load i64, i64* %4
%10 = icmp ule i64 %8, %9
br i1 %10, label %11, label %24
11: ; preds = %7
%12 = load double, double* %3
%13 = load i64, i64* %5
%14 = call double @pow(double %12, i64 %13)
%15 = load i64, i64* %5
%16 = call i64 @factorielle(i64 %15, i32 1)
%17 = sitofp i64 %16 to double
%18 = fdiv double %14, %17
%19 = load double, double* %6
%20 = fadd double %19, %18
store double %20, double* %6
br label %21
21: ; preds = %11
%22 = load i64, i64* %5
%23 = add i64 %22, 1
store i64 %23, i64* %5
br label %7
24: ; preds = %7
%25 = load double, double* %6
ret double %25
}

LLVM IR (-O2):
define double @dl_exponential(double %0, i64 %1) {
br label %3
3: ; preds = %2, %3
%4 = phi double [ 0.000000e+00, %2 ], [ %10, %3 ]
%5 = phi i64 [ 0, %2 ], [ %11, %3 ]
%6 = tail call double @pow(double %0, i64 %5)
%7 = tail call i64 @factorielle(i64 %5, i32 1)
%8 = sitofp i64 %7 to double
%9 = fdiv double %6, %8
%10 = fadd double %4, %9
%11 = add i64 %5, 1
%12 = icmp ugt i64 %11, %1
br i1 %12, label %13, label %3
13: ; preds = %3
ret double %10
}