#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 *, int, int);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int hhistogram(FILE *out, int a[], int size, int start, int end) {
  int i, j;
  for (i = 0; i < size; i++) {
    fprintf(out, "%02d-%02d|", i, i);
    for (j = 0; j < a[i]; j++) {
      fputc('*', out);
    }
    fputc('\n', out);
  }
  return 0;
}


x86 assembly (clang, -O0):
<hhistogram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b6 <hhistogram+0x96>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xea2(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x20(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    119a <hhistogram+0x7a>
mov    -0x8(%rbp),%rsi
mov    $0x2a,%edi
call   1030 <fputc@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116a <hhistogram+0x4a>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1141 <hhistogram+0x21>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hhistogram>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1198 <hhistogram+0x78>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%r13d
xor    %ebx,%ebx
lea    0xebf(%rip),%r12
jmp    1166 <hhistogram+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbx
cmp    %r13,%rbx
je     1198 <hhistogram+0x78>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
mov    %ebx,%ecx
call   1040 <fprintf@plt>
cmpl   $0x0,(%r14,%rbx,4)
jle    1150 <hhistogram+0x30>
xor    %ebp,%ebp
xchg   %ax,%ax
mov    $0x2a,%edi
mov    %r15,%rsi
call   1030 <fputc@plt>
add    $0x1,%ebp
cmp    (%r14,%rbx,4),%ebp
jl     1180 <hhistogram+0x60>
jmp    1150 <hhistogram+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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