#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 /*<<< orphan*/ cumchn(double *, double *, double *, double *, double *);
void nchi_cdfc(int n, double a, double b, double *x, double *array) {
  int i;
  double p, q;
  for (i = 0; i < n; i++) {
    cumchn(&x[i], &a, &b, &p, &q);
    *(array + i) = p;
  }
}


x86 assembly (clang, -O0):
<nchi_cdfc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1184 <nchi_cdfc+0x74>
mov    -0x20(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x40(%rbp),%r8
call   1030 <cumchn@plt>
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1134 <nchi_cdfc+0x24>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nchi_cdfc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
test   %edi,%edi
jle    117e <nchi_cdfc+0x6e>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%r15d
shl    $0x3,%r15
xor    %r12d,%r12d
lea    0x8(%rsp),%r13
lea    0x20(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
lea    (%rbx,%r12,1),%rdi
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %r13,%rcx
mov    %rbp,%r8
call   1030 <cumchn@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%r12,1)
add    $0x8,%r12
cmp    %r12,%r15
jne    1150 <nchi_cdfc+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @nchi_cdfc(i32 %0, double %1, double %2, double* %3, double* nocapture writeonly %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %1, double* %6
store double %2, double* %7
%10 = bitcast double* %8 to i8*
%11 = bitcast double* %9 to i8*
%12 = icmp sgt i32 %0, 0
br i1 %12, label %13, label %23
13: ; preds = %5
%14 = zext i32 %0 to i64
br label %15
15: ; preds = %13, %15
%16 = phi i64 [ 0, %13 ], [ %21, %15 ]
%17 = getelementptr inbounds double, double* %3, i64 %16
%18 = call i32 @cumchn(double* %17, double* %6, double* %7, double* %8, double* %9)
%19 = load double, double* %8
%20 = getelementptr inbounds double, double* %4, i64 %16
store double %19, double* %20
%21 = add nuw nsw i64 %16, 1
%22 = icmp eq i64 %21, %14
br i1 %22, label %23, label %15
23: ; preds = %15, %5
ret void
}