#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 */
int exp(int);
void integral_recur(int nmin, int nmax, double vals[]) {
  vals[nmax] = .003678;
  for (int n = nmax - 1; n >= nmin; n--) {
    vals[n] = (vals[n + 1] + 1 / (exp(1))) / (n + 1);
  }
}


x86 assembly (clang, -O0):
<integral_recur>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsd  0xece(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     11ad <integral_recur+0x9d>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    $0x1,%edi
call   1030 <exp@plt>
movsd  -0x20(%rbp),%xmm0
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <integral_recur+0x30>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integral_recur>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movslq %esi,%rbx
movabs $0x3f6e215336deb95e,%rax
21 6e 3f
mov    %rax,(%rdx,%rbx,8)
cmp    %edi,%ebx
jle    1195 <integral_recur+0x85>
mov    %rdx,%r14
movslq %edi,%r15
movsd  0xec1(%rip),%xmm0
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
lea    -0x1(%rbx),%rbp
mov    $0x1,%edi
call   1030 <exp@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
cmovae %r12d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebx,%xmm1
addsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%r14,%rbx,8)
mov    %rbp,%rbx
cmp    %r15,%rbp
jg     1150 <integral_recur+0x40>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @integral_recur(i32 %0, i32 %1, double* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store double* %2, double** %6
%8 = load double*, double** %6
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds double, double* %8, i64 %10
store double 3.678000e-03, double* %11
%12 = load i32, i32* %5
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %7
br label %14
14: ; preds = %37, %3
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = icmp sge i32 %15, %16
br i1 %17, label %18, label %40
18: ; preds = %14
%19 = load double*, double** %6
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %19, i64 %22
%24 = load double, double* %23
%25 = call i32 @exp(i32 1)
%26 = sdiv i32 1, %25
%27 = sitofp i32 %26 to double
%28 = fadd double %24, %27
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
%31 = sitofp i32 %30 to double
%32 = fdiv double %28, %31
%33 = load double*, double** %6
%34 = load i32, i32* %7
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
store double %32, double* %36
br label %37
37: ; preds = %18
%38 = load i32, i32* %7
%39 = add nsw i32 %38, -1
store i32 %39, i32* %7
br label %14
40: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @integral_recur(i32 %0, i32 %1, double* nocapture %2) {
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds double, double* %2, i64 %4
store double 3.678000e-03, double* %5
%6 = icmp sgt i32 %1, %0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = sext i32 %0 to i64
br label %10
9: ; preds = %10, %3
ret void
10: ; preds = %7, %10
%11 = phi double [ 3.678000e-03, %7 ], [ %22, %10 ]
%12 = phi i64 [ %4, %7 ], [ %13, %10 ]
%13 = add nsw i64 %12, -1
%14 = tail call i32 @exp(i32 1)
%15 = add i32 %14, 1
%16 = icmp ult i32 %15, 3
%17 = select i1 %16, i32 %14, i32 0
%18 = sitofp i32 %17 to double
%19 = fadd double %11, %18
%20 = trunc i64 %12 to i32
%21 = sitofp i32 %20 to double
%22 = fdiv double %19, %21
%23 = getelementptr inbounds double, double* %2, i64 %13
store double %22, double* %23
%24 = icmp sgt i64 %13, %8
br i1 %24, label %10, label %9
}