#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 */
struct SimpleTreeNode {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ predict_regression_(double *, struct SimpleTreeNode *,
                                       double *, double *);
void predict_regression(double *x, int size, struct SimpleTreeNode *node,
                        int num_attrs, double *p) {
  int i;
  double sum, n;
  for (i = 0; i < size; i++) {
    sum = n = 0;
    predict_regression_(x + i * num_attrs, node, &sum, &n);
    p[i] = sum / n;
  }
}


x86 assembly (clang, -O0):
<predict_regression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1197 <predict_regression+0x87>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1030 <predict_regression_@plt>
movsd  -0x38(%rbp),%xmm0
divsd  -0x40(%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    1131 <predict_regression+0x21>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<predict_regression>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    1185 <predict_regression+0x75>
mov    %r8,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
movslq %ecx,%rbp
mov    %esi,%r12d
shl    $0x3,%rbp
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1030 <predict_regression_@plt>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14,%r13,8)
add    $0x1,%r13
add    %rbp,%rbx
cmp    %r13,%r12
jne    1140 <predict_regression+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.SimpleTreeNode = type { i32 }
define void @predict_regression(double* %0, i32 %1, %struct.SimpleTreeNode* %2, i32 %3, double* %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca %struct.SimpleTreeNode*
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca double
%13 = alloca double
store double* %0, double** %6
store i32 %1, i32* %7
store %struct.SimpleTreeNode* %2, %struct.SimpleTreeNode** %8
store i32 %3, i32* %9
store double* %4, double** %10
store i32 0, i32* %11
br label %14
14: ; preds = %34, %5
%15 = load i32, i32* %11
%16 = load i32, i32* %7
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %37
18: ; preds = %14
store double 0.000000e+00, double* %13
store double 0.000000e+00, double* %12
%19 = load double*, double** %6
%20 = load i32, i32* %11
%21 = load i32, i32* %9
%22 = mul nsw i32 %20, %21
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds double, double* %19, i64 %23
%25 = load %struct.SimpleTreeNode*, %struct.SimpleTreeNode** %8
%26 = call i32 @predict_regression_(double* %24, %struct.SimpleTreeNode* %25, double* %12, double* %13)
%27 = load double, double* %12
%28 = load double, double* %13
%29 = fdiv double %27, %28
%30 = load double*, double** %10
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
store double %29, double* %33
br label %34
34: ; preds = %18
%35 = load i32, i32* %11
%36 = add nsw i32 %35, 1
store i32 %36, i32* %11
br label %14
37: ; preds = %14
ret void
}

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