void vote(double occur[10], double voting[10][784], double **trainingData,
          int trainingPicNum) {
  int ctr0;
  for (ctr0 = 0; ctr0 < trainingPicNum; ctr0++) {
    int sampleIndex = trainingData[ctr0][0];
    occur[sampleIndex]++;
    int ctr1;
    for (ctr1 = 1; ctr1 <= 784; ctr1++) {
      if (trainingData[ctr0][ctr1] > 0)
        voting[sampleIndex][ctr1] += 1;
    }
  }
}


x86 assembly (clang, -O0):
<vote>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11d7 <vote+0xd7>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cvttsd2si (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  0xeb7(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x1,-0x28(%rbp)
cmpl   $0x310,-0x28(%rbp)
jg     11c4 <vote+0xc4>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11b1 <vote+0xb1>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x1880,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  0xe59(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    11b6 <vote+0xb6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    115a <vote+0x5a>
jmp    11c9 <vote+0xc9>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    111a <vote+0x1a>
pop    %rbp
ret

x86 assembly (clang, -O2):
<vote>:
test   %ecx,%ecx
jle    11a5 <vote+0xa5>
mov    %ecx,%r8d
xor    %r9d,%r9d
movsd  0xeea(%rip),%xmm0
xorpd  %xmm1,%xmm1
jmp    1129 <vote+0x29>
nopl   0x0(%rax)
add    $0x1,%r9
cmp    %r8,%r9
je     11a5 <vote+0xa5>
mov    (%rdx,%r9,8),%r10
cvttsd2si (%r10),%eax
cltq
movsd  (%rdi,%rax,8),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,(%rdi,%rax,8)
imul   $0x1880,%rax,%rcx
add    %rsi,%rcx
mov    $0x2,%eax
jmp    116c <vote+0x6c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x2,%rax
cmp    $0x312,%rax
je     1120 <vote+0x20>
movsd  -0x8(%r10,%rax,8),%xmm2
ucomisd %xmm1,%xmm2
jbe    1189 <vote+0x89>
movsd  -0x8(%rcx,%rax,8),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,-0x8(%rcx,%rax,8)
movsd  (%r10,%rax,8),%xmm2
ucomisd %xmm1,%xmm2
jbe    1160 <vote+0x60>
movsd  (%rcx,%rax,8),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,(%rcx,%rax,8)
jmp    1160 <vote+0x60>
ret

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

LLVM IR (-O2):
define void @vote(double* nocapture %0, [784 x double]* nocapture %1, double** nocapture %2, i32 %3) {
%5 = icmp sgt i32 %3, 0
br i1 %5, label %6, label %42
6: ; preds = %4
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %6, %39
%9 = phi i64 [ 0, %6 ], [ %40, %39 ]
%10 = getelementptr inbounds double*, double** %2, i64 %9
%11 = load double*, double** %10
%12 = load double, double* %11
%13 = fptosi double %12 to i32
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds double, double* %0, i64 %14
%16 = load double, double* %15
%17 = fadd double %16, 1.000000e+00
store double %17, double* %15
br label %18
18: ; preds = %36, %8
%19 = phi i64 [ 1, %8 ], [ %37, %36 ]
%20 = getelementptr inbounds double, double* %11, i64 %19
%21 = load double, double* %20
%22 = fcmp ogt double %21, 0.000000e+00
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = getelementptr inbounds [784 x double], [784 x double]* %1, i64 %14, i64 %19
%25 = load double, double* %24
%26 = fadd double %25, 1.000000e+00
store double %26, double* %24
br label %27
27: ; preds = %18, %23
%28 = add nuw nsw i64 %19, 1
%29 = getelementptr inbounds double, double* %11, i64 %28
%30 = load double, double* %29
%31 = fcmp ogt double %30, 0.000000e+00
br i1 %31, label %32, label %36
32: ; preds = %27
%33 = getelementptr inbounds [784 x double], [784 x double]* %1, i64 %14, i64 %28
%34 = load double, double* %33
%35 = fadd double %34, 1.000000e+00
store double %35, double* %33
br label %36
36: ; preds = %32, %27
%37 = add nuw nsw i64 %19, 2
%38 = icmp eq i64 %37, 785
br i1 %38, label %39, label %18
39: ; preds = %36
%40 = add nuw nsw i64 %9, 1
%41 = icmp eq i64 %40, %7
br i1 %41, label %42, label %8
42: ; preds = %39, %4
ret void
}