void weighting(double occur[10], double voting[10][784],
               double weighting[10][784]) {
  int ctr0, ctr1;
  for (ctr0 = 0; ctr0 < 10; ctr0++) {
    int appearedTime = occur[ctr0];
    for (ctr1 = 0; ctr1 < 784; ctr1++) {
      weighting[ctr0][ctr1] = voting[ctr0][ctr1] / appearedTime;
    }
  }
}


x86 assembly (clang, -O0):
<weighting>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    11a5 <weighting+0xa5>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x310,-0x20(%rbp)
jge    1192 <weighting+0x92>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x1880,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x1880,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1138 <weighting+0x38>
jmp    1197 <weighting+0x97>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1117 <weighting+0x17>
pop    %rbp
ret

x86 assembly (clang, -O2):
<weighting>:
push   %r14
push   %rbx
lea    0x10(%rsi),%r8
lea    0x10(%rdx),%r9
lea    0x8(%rsi),%r11
lea    0x8(%rdx),%rcx
xor    %r10d,%r10d
jmp    114a <weighting+0x4a>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r10
add    $0x1880,%r8
add    $0x1880,%r9
add    $0x1880,%r11
add    $0x1880,%rcx
cmp    $0xa,%r10
je     1213 <weighting+0x113>
movsd  (%rdi,%r10,8),%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
imul   $0x1880,%r10,%rax
lea    (%rsi,%rax,1),%r14
add    $0x1880,%r14
lea    (%rdx,%rax,1),%rbx
cmp    %r14,%rbx
jae    11d0 <weighting+0xd0>
lea    (%rsi,%rax,1),%rbx
add    %rdx,%rax
add    $0x1880,%rax
cmp    %rax,%rbx
jae    11d0 <weighting+0xd0>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movsd  -0x8(%r11,%rax,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x8(%rcx,%rax,8)
movsd  (%r11,%rax,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rcx,%rax,8)
add    $0x2,%rax
cmp    $0x310,%rax
jne    1190 <weighting+0x90>
jmp    1120 <weighting+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
unpcklpd %xmm0,%xmm0
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movupd -0x10(%r8,%rax,8),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,-0x10(%r9,%rax,8)
movupd (%r8,%rax,8),%xmm1
divpd  %xmm0,%xmm1
movupd %xmm1,(%r9,%rax,8)
add    $0x4,%rax
cmp    $0x310,%rax
jne    11e0 <weighting+0xe0>
jmp    1120 <weighting+0x20>
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @weighting(double* %0, [784 x double]* %1, [784 x double]* %2) {
%4 = alloca double*
%5 = alloca [784 x double]*
%6 = alloca [784 x double]*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store double* %0, double** %4
store [784 x double]* %1, [784 x double]** %5
store [784 x double]* %2, [784 x double]** %6
store i32 0, i32* %7
br label %10
10: ; preds = %46, %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 10
br i1 %12, label %13, label %49
13: ; preds = %10
%14 = load double*, double** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = fptosi double %18 to i32
store i32 %19, i32* %9
store i32 0, i32* %8
br label %20
20: ; preds = %42, %13
%21 = load i32, i32* %8
%22 = icmp slt i32 %21, 784
br i1 %22, label %23, label %45
23: ; preds = %20
%24 = load [784 x double]*, [784 x double]** %5
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [784 x double], [784 x double]* %24, i64 %26
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [784 x double], [784 x double]* %27, i64 0, i64 %29
%31 = load double, double* %30
%32 = load i32, i32* %9
%33 = sitofp i32 %32 to double
%34 = fdiv double %31, %33
%35 = load [784 x double]*, [784 x double]** %6
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [784 x double], [784 x double]* %35, i64 %37
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [784 x double], [784 x double]* %38, i64 0, i64 %40
store double %34, double* %41
br label %42
42: ; preds = %23
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %20
45: ; preds = %20
br label %46
46: ; preds = %45
%47 = load i32, i32* %7
%48 = add nsw i32 %47, 1
store i32 %48, i32* %7
br label %10
49: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @weighting(double* nocapture %0, [784 x double]* nocapture %1, [784 x double]* nocapture writeonly %2) {
br label %4
4: ; preds = %3, %51
%5 = phi i64 [ 0, %3 ], [ %52, %51 ]
%6 = add nuw i64 %5, 1
%7 = getelementptr inbounds double, double* %0, i64 %5
%8 = load double, double* %7
%9 = fptosi double %8 to i32
%10 = sitofp i32 %9 to double
%11 = getelementptr [784 x double], [784 x double]* %1, i64 %6, i64 0
%12 = getelementptr [784 x double], [784 x double]* %1, i64 %5, i64 0
%13 = getelementptr [784 x double], [784 x double]* %2, i64 %6, i64 0
%14 = getelementptr [784 x double], [784 x double]* %2, i64 %5, i64 0
%15 = icmp ult double* %14, %11
%16 = icmp ult double* %12, %13
%17 = and i1 %15, %16
br i1 %17, label %38, label %18
18: ; preds = %4
%19 = insertelement <2 x double> poison, double %10, i64 0
%20 = shufflevector <2 x double> %19, <2 x double> poison, <2 x i32> zeroinitializer
br label %21
21: ; preds = %21, %18
%22 = phi i64 [ 0, %18 ], [ %36, %21 ]
%23 = getelementptr inbounds [784 x double], [784 x double]* %1, i64 %5, i64 %22
%24 = bitcast double* %23 to <2 x double>*
%25 = load <2 x double>, <2 x double>* %24
%26 = fdiv <2 x double> %25, %20
%27 = getelementptr inbounds [784 x double], [784 x double]* %2, i64 %5, i64 %22
%28 = bitcast double* %27 to <2 x double>*
store <2 x double> %26, <2 x double>* %28
%29 = or i64 %22, 2
%30 = getelementptr inbounds [784 x double], [784 x double]* %1, i64 %5, i64 %29
%31 = bitcast double* %30 to <2 x double>*
%32 = load <2 x double>, <2 x double>* %31
%33 = fdiv <2 x double> %32, %20
%34 = getelementptr inbounds [784 x double], [784 x double]* %2, i64 %5, i64 %29
%35 = bitcast double* %34 to <2 x double>*
store <2 x double> %33, <2 x double>* %35
%36 = add nuw nsw i64 %22, 4
%37 = icmp eq i64 %36, 784
br i1 %37, label %51, label %21
38: ; preds = %4, %38
%39 = phi i64 [ %49, %38 ], [ 0, %4 ]
%40 = getelementptr inbounds [784 x double], [784 x double]* %1, i64 %5, i64 %39
%41 = load double, double* %40
%42 = fdiv double %41, %10
%43 = getelementptr inbounds [784 x double], [784 x double]* %2, i64 %5, i64 %39
store double %42, double* %43
%44 = or i64 %39, 1
%45 = getelementptr inbounds [784 x double], [784 x double]* %1, i64 %5, i64 %44
%46 = load double, double* %45
%47 = fdiv double %46, %10
%48 = getelementptr inbounds [784 x double], [784 x double]* %2, i64 %5, i64 %44
store double %47, double* %48
%49 = add nuw nsw i64 %39, 2
%50 = icmp eq i64 %49, 784
br i1 %50, label %51, label %38
51: ; preds = %21, %38
%52 = add nuw nsw i64 %5, 1
%53 = icmp eq i64 %52, 10
br i1 %53, label %54, label %4
54: ; preds = %51
ret void
}