#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 single_prob(int, int, int, int, double, int);
void single_cdf(int *A, int *n0, int *A0, double *psi, int *c, double *cdf) {
  int n;
  for (n = 0; n < (*n0 + 1); n++) {
    if (n == 0) {
      cdf[n] = single_prob(n, *A, *n0, *A0, *psi, *c);
    } else {
      cdf[n] = cdf[n - 1] + single_prob(n, *A, *n0, *A0, *psi, *c);
    }
  }
}


x86 assembly (clang, -O0):
<single_cdf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11fc <single_cdf+0xec>
cmpl   $0x0,-0x34(%rbp)
jne    1190 <single_cdf+0x80>
mov    -0x34(%rbp),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
mov    (%rax),%r8d
call   1030 <single_prob@plt>
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11e9 <single_cdf+0xd9>
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
mov    (%rax),%r8d
call   1030 <single_prob@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11ee <single_cdf+0xde>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1137 <single_cdf+0x27>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<single_cdf>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r13
mov    %rdx,%rcx
mov    (%rsi),%edx
test   %edx,%edx
js     11d3 <single_cdf+0xc3>
mov    %rsi,%rbx
mov    (%rdi),%esi
mov    %rcx,0x10(%rsp)
mov    0x10(%rsp),%rcx
mov    (%rcx),%ecx
movsd  0x0(%r13),%xmm0
mov    %r8,%r12
mov    (%r8),%r8d
mov    %rdi,%rbp
xor    %edi,%edi
mov    %r9,%r15
call   1030 <single_prob@plt>
mov    %r15,%rax
movsd  %xmm0,(%r15)
mov    (%rbx),%edx
test   %edx,%edx
jle    11d3 <single_cdf+0xc3>
mov    %rbp,%rcx
mov    %r13,%rax
mov    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x8(%rsp)
mov    (%rcx),%esi
mov    0x10(%rsp),%rcx
mov    (%rcx),%ecx
movsd  (%rax),%xmm0
mov    (%r12),%r8d
mov    %r14d,%edi
call   1030 <single_prob@plt>
mov    %rbp,%rcx
mov    %r15,%rax
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r15,%r14,8)
movslq (%rbx),%rdx
lea    0x1(%r14),%rax
cmp    %rdx,%r14
mov    %rax,%r14
mov    %r13,%rax
jl     1180 <single_cdf+0x70>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @single_cdf(i32* %0, i32* %1, i32* %2, double* %3, i32* %4, double* %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca double*
%11 = alloca i32*
%12 = alloca double*
%13 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store double* %3, double** %10
store i32* %4, i32** %11
store double* %5, double** %12
store i32 0, i32* %13
br label %14
14: ; preds = %65, %6
%15 = load i32, i32* %13
%16 = load i32*, i32** %8
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
%19 = icmp slt i32 %15, %18
br i1 %19, label %20, label %68
20: ; preds = %14
%21 = load i32, i32* %13
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %40
23: ; preds = %20
%24 = load i32, i32* %13
%25 = load i32*, i32** %7
%26 = load i32, i32* %25
%27 = load i32*, i32** %8
%28 = load i32, i32* %27
%29 = load i32*, i32** %9
%30 = load i32, i32* %29
%31 = load double*, double** %10
%32 = load double, double* %31
%33 = load i32*, i32** %11
%34 = load i32, i32* %33
%35 = call double @single_prob(i32 %24, i32 %26, i32 %28, i32 %30, double %32, i32 %34)
%36 = load double*, double** %12
%37 = load i32, i32* %13
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %36, i64 %38
store double %35, double* %39
br label %64
40: ; preds = %20
%41 = load double*, double** %12
%42 = load i32, i32* %13
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %41, i64 %44
%46 = load double, double* %45
%47 = load i32, i32* %13
%48 = load i32*, i32** %7
%49 = load i32, i32* %48
%50 = load i32*, i32** %8
%51 = load i32, i32* %50
%52 = load i32*, i32** %9
%53 = load i32, i32* %52
%54 = load double*, double** %10
%55 = load double, double* %54
%56 = load i32*, i32** %11
%57 = load i32, i32* %56
%58 = call double @single_prob(i32 %47, i32 %49, i32 %51, i32 %53, double %55, i32 %57)
%59 = fadd double %46, %58
%60 = load double*, double** %12
%61 = load i32, i32* %13
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
store double %59, double* %63
br label %64
64: ; preds = %40, %23
br label %65
65: ; preds = %64
%66 = load i32, i32* %13
%67 = add nsw i32 %66, 1
store i32 %67, i32* %13
br label %14
68: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @single_cdf(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2, double* nocapture %3, i32* nocapture %4, double* nocapture %5) {
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %33, label %9
9: ; preds = %6
%10 = load i32, i32* %0
%11 = load i32, i32* %2
%12 = load double, double* %3
%13 = load i32, i32* %4
%14 = tail call double @single_prob(i32 0, i32 %10, i32 %7, i32 %11, double %12, i32 %13)
store double %14, double* %5
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %9, %17
%18 = phi double [ %27, %17 ], [ %14, %9 ]
%19 = phi i64 [ %30, %17 ], [ 1, %9 ]
%20 = phi i32 [ %29, %17 ], [ %15, %9 ]
%21 = load i32, i32* %0
%22 = load i32, i32* %2
%23 = load double, double* %3
%24 = load i32, i32* %4
%25 = trunc i64 %19 to i32
%26 = tail call double @single_prob(i32 %25, i32 %21, i32 %20, i32 %22, double %23, i32 %24)
%27 = fadd double %18, %26
%28 = getelementptr inbounds double, double* %5, i64 %19
store double %27, double* %28
%29 = load i32, i32* %1
%30 = add nuw nsw i64 %19, 1
%31 = sext i32 %29 to i64
%32 = icmp slt i64 %19, %31
br i1 %32, label %17, label %33
33: ; preds = %17, %9, %6
ret void
}