void count_hash_results(unsigned long hash, int counts[10][10]) {
  int srv, nsrv;
  for (nsrv = 0; nsrv < 10; nsrv++) {
    srv = hash % (nsrv + 1);
    counts[nsrv][srv]++;
  }
}


x86 assembly (clang, -O0):
<count_hash_results>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jge    115e <count_hash_results+0x5e>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1113 <count_hash_results+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_hash_results>:
addl   $0x1,(%rsi)
mov    %edi,%eax
and    $0x1,%eax
addl   $0x1,0x28(%rsi,%rax,4)
movabs $0xaaaaaaaaaaaaaaab,%rcx
aa aa aa
mov    %rdi,%rax
mul    %rcx
mov    %rdx,%rcx
shr    %rcx
lea    (%rcx,%rcx,2),%rax
mov    %rdi,%rdx
sub    %rax,%rdx
addl   $0x1,0x50(%rsi,%rdx,4)
mov    %edi,%eax
and    $0x3,%eax
addl   $0x1,0x78(%rsi,%rax,4)
movabs $0xcccccccccccccccd,%rdx
cc cc cc
mov    %rdi,%rax
mul    %rdx
mov    %rdx,%r8
shr    $0x2,%r8
lea    (%r8,%r8,4),%rax
mov    %rdi,%rdx
sub    %rax,%rdx
addl   $0x1,0xa0(%rsi,%rdx,4)
01
and    $0xfffffffffffffffe,%rcx
lea    (%rcx,%rcx,2),%rax
mov    %rdi,%rcx
sub    %rax,%rcx
addl   $0x1,0xc8(%rsi,%rcx,4)
01
movabs $0x2492492492492493,%rcx
49 92 24
mov    %rdi,%rax
mul    %rcx
mov    %rdi,%rax
sub    %rdx,%rax
shr    %rax
add    %rdx,%rax
shr    $0x2,%rax
lea    0x0(,%rax,8),%rcx
sub    %rcx,%rax
add    %rdi,%rax
addl   $0x1,0xf0(%rsi,%rax,4)
01
mov    %edi,%eax
and    $0x7,%eax
addl   $0x1,0x118(%rsi,%rax,4)
01
movabs $0xe38e38e38e38e38f,%rcx
38 8e e3
mov    %rdi,%rax
mul    %rcx
shr    $0x3,%rdx
lea    (%rdx,%rdx,8),%rax
mov    %rdi,%rcx
sub    %rax,%rcx
addl   $0x1,0x140(%rsi,%rcx,4)
01
and    $0xfffffffffffffffe,%r8
lea    (%r8,%r8,4),%rax
sub    %rax,%rdi
addl   $0x1,0x168(%rsi,%rdi,4)
01
ret

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

LLVM IR (-O2):
define void @count_hash_results(i64 %0, [10 x i32]* nocapture %1) {
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = load i32, i32* %3
%5 = add nsw i32 %4, 1
store i32 %5, i32* %3
%6 = and i64 %0, 1
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 1, i64 %6
%8 = load i32, i32* %7
%9 = add nsw i32 %8, 1
store i32 %9, i32* %7
%10 = urem i64 %0, 3
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 2, i64 %10
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
store i32 %13, i32* %11
%14 = and i64 %0, 3
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 3, i64 %14
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
store i32 %17, i32* %15
%18 = urem i64 %0, 5
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 4, i64 %18
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
%22 = urem i64 %0, 6
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 5, i64 %22
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
store i32 %25, i32* %23
%26 = urem i64 %0, 7
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 6, i64 %26
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 1
store i32 %29, i32* %27
%30 = and i64 %0, 7
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 7, i64 %30
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
store i32 %33, i32* %31
%34 = urem i64 %0, 9
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 8, i64 %34
%36 = load i32, i32* %35
%37 = add nsw i32 %36, 1
store i32 %37, i32* %35
%38 = urem i64 %0, 10
%39 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 9, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %39
ret void
}