#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, ...);
void printHistogram(int **hist, int rank, int numSubjects) {
  int rc;
  int sum;
  sum = 0;
  printf("\nHistgram of recognition counts at rank %d", rank);
  for (rc = 0; rc <= numSubjects; rc++) {
    printf("\n  %3d \t %d", rc, hist[rank][rc]);
    sum = sum + hist[rank][rc];
  }
  printf("\n  Sums to %d", sum);
}


x86 assembly (clang, -O0):
<printHistogram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%esi
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1198 <printHistogram+0x88>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0xc(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
movslq -0x14(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <printHistogram+0x31>
mov    -0x18(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printHistogram>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xed6(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1030 <printf@plt>
test   %r12d,%r12d
js     116f <printHistogram+0x5f>
movslq %ebx,%r13
add    $0x1,%r12d
mov    (%r14,%r13,8),%rax
lea    0xee1(%rip),%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%rax,%rbx,4),%edx
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%r14,%r13,8),%rax
add    (%rax,%rbx,4),%ebp
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1150 <printHistogram+0x40>
lea    0xec1(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"\0AHistgram of recognition counts at rank %d\00"
@.str.1 = [12 x i8] c"\0A %3d \09 %d\00"
@.str.2 = [14 x i8] c"\0A Sums to %d\00"
define void @printHistogram(i32** %0, i32 %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32** %0, i32*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %8
%9 = load i32, i32* %5
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 0, i32* %7
br label %11
11: ; preds = %38, %3
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %41
15: ; preds = %11
%16 = load i32, i32* %7
%17 = load i32**, i32*** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32*, i32** %17, i64 %19
%21 = load i32*, i32** %20
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %25)
%27 = load i32, i32* %8
%28 = load i32**, i32*** %4
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32*, i32** %28, i64 %30
%32 = load i32*, i32** %31
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = add nsw i32 %27, %36
store i32 %37, i32* %8
br label %38
38: ; preds = %15
%39 = load i32, i32* %7
%40 = add nsw i32 %39, 1
store i32 %40, i32* %7
br label %11
41: ; preds = %11
%42 = load i32, i32* %8
%43 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %42)
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"\0AHistgram of recognition counts at rank %d\00"
@.str.1 = [12 x i8] c"\0A %3d \09 %d\00"
@.str.2 = [14 x i8] c"\0A Sums to %d\00"
define void @printHistogram(i32** nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %1)
%5 = icmp slt i32 %2, 0
br i1 %5, label %26, label %6
6: ; preds = %3
%7 = sext i32 %1 to i64
%8 = getelementptr inbounds i32*, i32** %0, i64 %7
%9 = add nuw i32 %2, 1
%10 = zext i32 %9 to i64
%11 = load i32*, i32** %8
br label %12
12: ; preds = %6, %12
%13 = phi i32* [ %11, %6 ], [ %20, %12 ]
%14 = phi i64 [ 0, %6 ], [ %24, %12 ]
%15 = phi i32 [ 0, %6 ], [ %23, %12 ]
%16 = getelementptr inbounds i32, i32* %13, i64 %14
%17 = load i32, i32* %16
%18 = trunc i64 %14 to i32
%19 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %17)
%20 = load i32*, i32** %8
%21 = getelementptr inbounds i32, i32* %20, i64 %14
%22 = load i32, i32* %21
%23 = add nsw i32 %22, %15
%24 = add nuw nsw i64 %14, 1
%25 = icmp eq i64 %24, %10
br i1 %25, label %26, label %12
26: ; preds = %12, %3
%27 = phi i32 [ 0, %3 ], [ %23, %12 ]
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %27)
ret void
}