#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int hshistogram(FILE *out, int a[], int size, char *name[]) {
  int i, j;
  for (i = 0; i < size; i++) {
    fprintf(out, "%5s|", name[i]);
    for (j = 0; j < a[i]; j++) {
      fputc('*', out);
    }
    fputc('\n', out);
  }
  return 0;
}


x86 assembly (clang, -O0):
<hshistogram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b9 <hshistogram+0x99>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe9f(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x24(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    119d <hshistogram+0x7d>
mov    -0x8(%rbp),%rsi
mov    $0x2a,%edi
call   1030 <fputc@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    116d <hshistogram+0x4d>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113e <hshistogram+0x1e>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hshistogram>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1199 <hshistogram+0x79>
mov    %rcx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %edx,%r13d
xor    %ebp,%ebp
jmp    1156 <hshistogram+0x36>
nop
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbp
cmp    %r13,%rbp
je     1199 <hshistogram+0x79>
mov    (%r14,%rbp,8),%rdx
mov    %rbx,%rdi
lea    0xe9c(%rip),%rsi
call   1040 <fprintf@plt>
cmpl   $0x0,(%r15,%rbp,4)
jle    1140 <hshistogram+0x20>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2a,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x1,%r12d
cmp    (%r15,%rbp,4),%r12d
jl     1180 <hshistogram+0x60>
jmp    1140 <hshistogram+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%5s|\00"
define i32 @hshistogram(i32* nocapture %0, i32* nocapture %1, i32 %2, i8** nocapture %3) {
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %26
6: ; preds = %4
%7 = zext i32 %2 to i64
br label %8
8: ; preds = %6, %22
%9 = phi i64 [ 0, %6 ], [ %24, %22 ]
%10 = getelementptr inbounds i8*, i8** %3, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds i32, i32* %1, i64 %9
%14 = load i32, i32* %13
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %8, %16
%17 = phi i32 [ %19, %16 ], [ 0, %8 ]
%18 = tail call i32 @fputc(i8 signext 42, i32* %0)
%19 = add nuw nsw i32 %17, 1
%20 = load i32, i32* %13
%21 = icmp slt i32 %19, %20
br i1 %21, label %16, label %22
22: ; preds = %16, %8
%23 = tail call i32 @fputc(i8 signext 10, i32* %0)
%24 = add nuw nsw i64 %9, 1
%25 = icmp eq i64 %24, %7
br i1 %25, label %26, label %8
26: ; preds = %22, %4
ret i32 0
}