#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_classification_(double *, struct SimpleTreeNode *,
                                           int, double *);
void predict_classification(double *x, int size, struct SimpleTreeNode *node,
                            int num_attrs, int cls_vals, double *p) {
  int i, j;
  double *xx, *pp;
  for (i = 0; i < size; i++) {
    xx = x + i * num_attrs;
    pp = p + i * cls_vals;
    predict_classification_(xx, node, cls_vals, pp);
    double sum = 0;
    for (j = 0; j < cls_vals; j++) {
      sum += pp[j];
    }
    for (j = 0; j < cls_vals; j++) {
      pp[j] /= sum;
    }
  }
}


x86 assembly (clang, -O0):
<predict_classification>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1216 <predict_classification+0x106>
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x40(%rbp),%rcx
call   1030 <predict_classification_@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11c7 <predict_classification+0xb7>
mov    -0x40(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1196 <predict_classification+0x86>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1203 <predict_classification+0xf3>
movsd  -0x48(%rbp),%xmm1
mov    -0x40(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11ce <predict_classification+0xbe>
jmp    1208 <predict_classification+0xf8>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1135 <predict_classification+0x25>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<predict_classification>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9,0x8(%rsp)
mov    %r8d,0x4(%rsp)
mov    %rdx,0x60(%rsp)
mov    %rdi,0x58(%rsp)
test   %esi,%esi
jle    1357 <predict_classification+0x247>
movslq %ecx,%rax
mov    %rax,0x50(%rsp)
movslq 0x4(%rsp),%rax
mov    %esi,%ecx
mov    %rcx,0x40(%rsp)
mov    %eax,%ebp
lea    -0x1(%rbp),%rcx
mov    %rcx,0x30(%rsp)
mov    %ebp,%ecx
and    $0xfffffffe,%ecx
mov    %rcx,0x28(%rsp)
add    $0xfffffffffffffffe,%rcx
mov    %rcx,0x20(%rsp)
mov    %rcx,%rsi
shr    %rsi
add    $0x1,%rsi
mov    %ebp,%r15d
and    $0x7,%r15d
mov    %ebp,%r14d
and    $0xfffffff8,%r14d
mov    %rsi,%rcx
mov    %rsi,0x18(%rsp)
and    $0xfffffffffffffffe,%rsi
mov    %rsi,0x10(%rsp)
mov    0x8(%rsp),%rbx
lea    0x38(%rbx),%r13
mov    %rax,0x48(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x38(%rsp)
xor    %esi,%esi
mov    0x48(%rsp),%r12
jmp    11df <predict_classification+0xcf>
nopl   0x0(%rax)
mov    0x70(%rsp),%rsi
add    $0x1,%rsi
mov    0x38(%rsp),%rax
add    %rax,%r13
add    %rax,%rbx
cmp    0x40(%rsp),%rsi
je     1357 <predict_classification+0x247>
mov    %rsi,%rax
imul   0x50(%rsp),%rax
mov    0x58(%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    %rsi,0x70(%rsp)
mov    %rsi,%rax
imul   %r12,%rax
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,8),%rcx
mov    0x60(%rsp),%rsi
mov    %r12d,%edx
mov    %rcx,0x68(%rsp)
call   1030 <predict_classification_@plt>
test   %r12d,%r12d
jle    11c0 <predict_classification+0xb0>
cmpq   $0x7,0x30(%rsp)
jae    1230 <predict_classification+0x120>
xorpd  %xmm0,%xmm0
xor    %eax,%eax
jmp    1281 <predict_classification+0x171>
nopl   (%rax)
xorpd  %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
addsd  -0x38(%r13,%rax,8),%xmm0
addsd  -0x30(%r13,%rax,8),%xmm0
addsd  -0x28(%r13,%rax,8),%xmm0
addsd  -0x20(%r13,%rax,8),%xmm0
addsd  -0x18(%r13,%rax,8),%xmm0
addsd  -0x10(%r13,%rax,8),%xmm0
addsd  -0x8(%r13,%rax,8),%xmm0
addsd  0x0(%r13,%rax,8),%xmm0
add    $0x8,%rax
cmp    %rax,%r14
jne    1240 <predict_classification+0x130>
test   %r15,%r15
je     129e <predict_classification+0x18e>
lea    (%rbx,%rax,8),%rax
xor    %ecx,%ecx
nopl   0x0(%rax)
addsd  (%rax,%rcx,8),%xmm0
add    $0x1,%rcx
cmp    %rcx,%r15
jne    1290 <predict_classification+0x180>
cmpl   $0x0,0x4(%rsp)
jle    11c0 <predict_classification+0xb0>
cmpl   $0x1,0x4(%rsp)
jne    12b4 <predict_classification+0x1a4>
xor    %eax,%eax
jmp    1330 <predict_classification+0x220>
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
cmpq   $0x0,0x20(%rsp)
je     134c <predict_classification+0x23c>
mov    0x10(%rsp),%rcx
xor    %eax,%eax
nop
movupd (%rbx,%rax,8),%xmm2
movupd 0x10(%rbx,%rax,8),%xmm3
divpd  %xmm1,%xmm2
movupd %xmm2,(%rbx,%rax,8)
divpd  %xmm1,%xmm3
movupd %xmm3,0x10(%rbx,%rax,8)
add    $0x4,%rax
add    $0xfffffffffffffffe,%rcx
jne    12d0 <predict_classification+0x1c0>
testb  $0x1,0x18(%rsp)
je     1312 <predict_classification+0x202>
mov    0x68(%rsp),%rcx
movupd (%rcx,%rax,8),%xmm2
divpd  %xmm1,%xmm2
movupd %xmm2,(%rcx,%rax,8)
mov    0x28(%rsp),%rcx
mov    %rcx,%rax
cmp    %rbp,%rcx
je     11c0 <predict_classification+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%rbx,%rax,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%rax,8)
add    $0x1,%rax
cmp    %rax,%rbp
jne    1330 <predict_classification+0x220>
jmp    11c0 <predict_classification+0xb0>
xor    %eax,%eax
testb  $0x1,0x18(%rsp)
jne    12ff <predict_classification+0x1ef>
jmp    1312 <predict_classification+0x202>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.SimpleTreeNode = type { i32 }
define void @predict_classification(double* %0, i32 %1, %struct.SimpleTreeNode* %2, i32 %3, i32 %4, double* %5) {
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %135
8: ; preds = %6
%9 = icmp sgt i32 %4, 0
%10 = sext i32 %3 to i64
%11 = sext i32 %4 to i64
%12 = zext i32 %1 to i64
%13 = zext i32 %4 to i64
%14 = zext i32 %4 to i64
%15 = add nsw i64 %13, -1
%16 = and i64 %13, 4294967294
%17 = add nsw i64 %16, -2
%18 = lshr exact i64 %17, 1
%19 = add nuw i64 %18, 1
%20 = and i64 %13, 7
%21 = icmp ult i64 %15, 7
%22 = and i64 %13, 4294967288
%23 = icmp eq i64 %20, 0
%24 = icmp eq i32 %4, 1
%25 = and i64 %13, 4294967294
%26 = and i64 %19, 1
%27 = icmp eq i64 %17, 0
%28 = and i64 %19, -2
%29 = icmp eq i64 %26, 0
%30 = icmp eq i64 %25, %13
br label %31
31: ; preds = %8, %132
%32 = phi i64 [ 0, %8 ], [ %133, %132 ]
%33 = mul nsw i64 %32, %10
%34 = getelementptr inbounds double, double* %0, i64 %33
%35 = mul nsw i64 %32, %11
%36 = getelementptr inbounds double, double* %5, i64 %35
%37 = tail call i32 @predict_classification_(double* %34, %struct.SimpleTreeNode* %2, i32 %4, double* %36)
br i1 %9, label %38, label %132
38: ; preds = %31
br i1 %21, label %39, label %87
39: ; preds = %87, %38
%40 = phi double [ undef, %38 ], [ %121, %87 ]
%41 = phi i64 [ 0, %38 ], [ %122, %87 ]
%42 = phi double [ 0.000000e+00, %38 ], [ %121, %87 ]
br i1 %23, label %53, label %43
43: ; preds = %39, %43
%44 = phi i64 [ %50, %43 ], [ %41, %39 ]
%45 = phi double [ %49, %43 ], [ %42, %39 ]
%46 = phi i64 [ %51, %43 ], [ 0, %39 ]
%47 = getelementptr inbounds double, double* %36, i64 %44
%48 = load double, double* %47
%49 = fadd double %45, %48
%50 = add nuw nsw i64 %44, 1
%51 = add i64 %46, 1
%52 = icmp eq i64 %51, %20
br i1 %52, label %53, label %43
53: ; preds = %43, %39
%54 = phi double [ %40, %39 ], [ %49, %43 ]
br i1 %9, label %55, label %132
55: ; preds = %53
br i1 %24, label %85, label %56
56: ; preds = %55
%57 = insertelement <2 x double> poison, double %54, i64 0
%58 = shufflevector <2 x double> %57, <2 x double> poison, <2 x i32> zeroinitializer
br i1 %27, label %76, label %59
59: ; preds = %56, %59
%60 = phi i64 [ %73, %59 ], [ 0, %56 ]
%61 = phi i64 [ %74, %59 ], [ 0, %56 ]
%62 = getelementptr inbounds double, double* %36, i64 %60
%63 = bitcast double* %62 to <2 x double>*
%64 = load <2 x double>, <2 x double>* %63
%65 = fdiv <2 x double> %64, %58
%66 = bitcast double* %62 to <2 x double>*
store <2 x double> %65, <2 x double>* %66
%67 = or i64 %60, 2
%68 = getelementptr inbounds double, double* %36, i64 %67
%69 = bitcast double* %68 to <2 x double>*
%70 = load <2 x double>, <2 x double>* %69
%71 = fdiv <2 x double> %70, %58
%72 = bitcast double* %68 to <2 x double>*
store <2 x double> %71, <2 x double>* %72
%73 = add nuw i64 %60, 4
%74 = add nuw i64 %61, 2
%75 = icmp eq i64 %74, %28
br i1 %75, label %76, label %59
76: ; preds = %59, %56
%77 = phi i64 [ 0, %56 ], [ %73, %59 ]
br i1 %29, label %84, label %78
78: ; preds = %76
%79 = getelementptr inbounds double, double* %36, i64 %77
%80 = bitcast double* %79 to <2 x double>*
%81 = load <2 x double>, <2 x double>* %80
%82 = fdiv <2 x double> %81, %58
%83 = bitcast double* %79 to <2 x double>*
store <2 x double> %82, <2 x double>* %83
br label %84
84: ; preds = %76, %78
br i1 %30, label %132, label %85
85: ; preds = %55, %84
%86 = phi i64 [ 0, %55 ], [ %25, %84 ]
br label %125
87: ; preds = %38, %87
%88 = phi i64 [ %122, %87 ], [ 0, %38 ]
%89 = phi double [ %121, %87 ], [ 0.000000e+00, %38 ]
%90 = phi i64 [ %123, %87 ], [ 0, %38 ]
%91 = getelementptr inbounds double, double* %36, i64 %88
%92 = load double, double* %91
%93 = fadd double %89, %92
%94 = or i64 %88, 1
%95 = getelementptr inbounds double, double* %36, i64 %94
%96 = load double, double* %95
%97 = fadd double %93, %96
%98 = or i64 %88, 2
%99 = getelementptr inbounds double, double* %36, i64 %98
%100 = load double, double* %99
%101 = fadd double %97, %100
%102 = or i64 %88, 3
%103 = getelementptr inbounds double, double* %36, i64 %102
%104 = load double, double* %103
%105 = fadd double %101, %104
%106 = or i64 %88, 4
%107 = getelementptr inbounds double, double* %36, i64 %106
%108 = load double, double* %107
%109 = fadd double %105, %108
%110 = or i64 %88, 5
%111 = getelementptr inbounds double, double* %36, i64 %110
%112 = load double, double* %111
%113 = fadd double %109, %112
%114 = or i64 %88, 6
%115 = getelementptr inbounds double, double* %36, i64 %114
%116 = load double, double* %115
%117 = fadd double %113, %116
%118 = or i64 %88, 7
%119 = getelementptr inbounds double, double* %36, i64 %118
%120 = load double, double* %119
%121 = fadd double %117, %120
%122 = add nuw nsw i64 %88, 8
%123 = add i64 %90, 8
%124 = icmp eq i64 %123, %22
br i1 %124, label %39, label %87
125: ; preds = %85, %125
%126 = phi i64 [ %130, %125 ], [ %86, %85 ]
%127 = getelementptr inbounds double, double* %36, i64 %126
%128 = load double, double* %127
%129 = fdiv double %128, %54
store double %129, double* %127
%130 = add nuw nsw i64 %126, 1
%131 = icmp eq i64 %130, %14
br i1 %131, label %132, label %125
132: ; preds = %125, %84, %31, %53
%133 = add nuw nsw i64 %32, 1
%134 = icmp eq i64 %133, %12
br i1 %134, label %135, label %31
135: ; preds = %132, %6
ret void
}