#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*/ calc_bars(int *, int, int *, int);
int /*<<< orphan*/ print_bar(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ putchar(char);
void print_graph(int values[], int size, int max_bar_size) {
  int bars[size];
  calc_bars(values, size, bars, max_bar_size);
  int i;
  for (i = 0; i < size; i++) {
    if (values[i] > 0) {
      printf("'%c' (%3d) %4d ", i, i, values[i]);
      print_bar(bars[i]);
      putchar('\n');
    }
  }
}


x86 assembly (clang, -O0):
<print_graph>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%ecx
call   1040 <calc_bars@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f7 <print_graph+0xb7>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    11e4 <print_graph+0xa4>
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe3b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1060 <print_bar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11e9 <print_graph+0xa9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118f <print_graph+0x4f>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_graph>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ecx
mov    %esi,%ebx
mov    %rdi,%r15
mov    %esi,%r13d
mov    %rsp,%r14
lea    0xf(,%r13,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r14,%rdx
call   1040 <calc_bars@plt>
test   %ebx,%ebx
jle    11c2 <print_graph+0x82>
xor    %ebx,%ebx
lea    0xe7e(%rip),%r12
jmp    1199 <print_graph+0x59>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r13
je     11c2 <print_graph+0x82>
mov    (%r15,%rbx,4),%ecx
test   %ecx,%ecx
jle    1190 <print_graph+0x50>
mov    %r12,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
call   1050 <printf@plt>
mov    (%r14,%rbx,4),%edi
call   1060 <print_bar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1190 <print_graph+0x50>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"'%c' (%3d) %4d \00"
define void @print_graph(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = load i32, i32* %5
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i32, i64 %11
store i64 %11, i64* %8
%14 = load i32*, i32** %4
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = call i32 @calc_bars(i32* %14, i32 %15, i32* %13, i32 %16)
store i32 0, i32* %9
br label %18
18: ; preds = %45, %3
%19 = load i32, i32* %9
%20 = load i32, i32* %5
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %48
22: ; preds = %18
%23 = load i32*, i32** %4
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %44
29: ; preds = %22
%30 = load i32, i32* %9
%31 = load i32, i32* %9
%32 = load i32*, i32** %4
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %30, i32 %31, i32 %36)
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i32, i32* %13, i64 %39
%41 = load i32, i32* %40
%42 = call i32 @print_bar(i32 %41)
%43 = call i32 @putchar(i8 signext 10)
br label %44
44: ; preds = %29, %22
br label %45
45: ; preds = %44
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %18
48: ; preds = %18
%49 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"'%c' (%3d) %4d \00"
define void @print_graph(i32* %0, i32 %1, i32 %2) {
%4 = zext i32 %1 to i64
%5 = alloca i32, i64 %4
%6 = call i32 @calc_bars(i32* %0, i32 %1, i32* %5, i32 %2)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %23
8: ; preds = %3, %20
%9 = phi i64 [ %21, %20 ], [ 0, %3 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = trunc i64 %9 to i32
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %14, i32 %11)
%16 = getelementptr inbounds i32, i32* %5, i64 %9
%17 = load i32, i32* %16
%18 = call i32 @print_bar(i32 %17)
%19 = call i32 @putchar(i8 signext 10)
br label %20
20: ; preds = %8, %13
%21 = add nuw nsw i64 %9, 1
%22 = icmp eq i64 %21, %4
br i1 %22, label %23, label %8
23: ; preds = %20, %3
ret void
}