#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 maxelem(int *, int);
int hhist(FILE *out, int wlc[], int size, int step) {
  int maxvalue = 0;
  int i;
  maxvalue = maxelem(wlc, size);
  int len;
  int unit = 100 / maxvalue;
  int begin = 0;
  int end = step;
  for (i = 0; i < size; i++) {
    fprintf(out, "%02d-%02d |", begin, end);
    begin = end;
    end += step;
    if (wlc[i] > 0) {
      len = unit * wlc[i];
      if (len <= 0) {
        len = 1;
      }
    } else {
      len = 0;
    }
    while (len > 0) {
      fputc('*', out);
      len--;
    }
    fputc('\n', out);
  }
  return 0;
}


x86 assembly (clang, -O0):
<hhist>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <maxelem@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x64,%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1235 <hhist+0x105>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    11e7 <hhist+0xb7>
mov    -0x28(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x20(%rbp),%rdx
imul   (%rcx,%rdx,4),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jg     11e2 <hhist+0xb2>
movl   $0x1,-0x24(%rbp)
jmp    11ee <hhist+0xbe>
movl   $0x0,-0x24(%rbp)
jmp    11f3 <hhist+0xc3>
cmpl   $0x0,-0x24(%rbp)
jle    1219 <hhist+0xe9>
mov    -0x8(%rbp),%rsi
mov    $0x2a,%edi
call   1030 <fputc@plt>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11f3 <hhist+0xc3>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117c <hhist+0x4c>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hhist>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x10(%rsp)
mov    %edx,%r13d
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %edx,%esi
call   1050 <maxelem@plt>
mov    %eax,%ecx
xor    %r12d,%r12d
mov    $0x64,%eax
xor    %edx,%edx
idiv   %ecx
mov    %eax,0xc(%rsp)
test   %r13d,%r13d
jle    11f9 <hhist+0xc9>
mov    %r13d,%r13d
xor    %ebp,%ebp
mov    0x10(%rsp),%rax
mov    %eax,%r14d
jmp    119f <hhist+0x6f>
mov    0x10(%rsp),%rax
lea    (%r12,%rax,1),%r14d
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x1,%rbp
cmp    %r13,%rbp
je     11f9 <hhist+0xc9>
mov    %r12d,%edx
mov    %r14d,%r12d
mov    %rbx,%rdi
lea    0xe51(%rip),%rsi
mov    %r14d,%ecx
call   1040 <fprintf@plt>
mov    (%r15,%rbp,4),%r14d
test   %r14d,%r14d
jle    1180 <hhist+0x50>
imul   0xc(%rsp),%r14d
test   %r14d,%r14d
mov    $0x1,%eax
cmovle %eax,%r14d
add    $0x1,%r14d
cs nopw 0x0(%rax,%rax,1)
mov    $0x2a,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%r14d
cmp    $0x1,%r14d
ja     11e0 <hhist+0xb0>
jmp    1180 <hhist+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%02d-%02d |\00"
define i32 @hhist(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
%15 = load i32*, i32** %6
%16 = load i32, i32* %7
%17 = call i32 @maxelem(i32* %15, i32 %16)
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = sdiv i32 100, %18
store i32 %19, i32* %12
store i32 0, i32* %13
%20 = load i32, i32* %8
store i32 %20, i32* %14
store i32 0, i32* %10
br label %21
21: ; preds = %65, %4
%22 = load i32, i32* %10
%23 = load i32, i32* %7
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %68
25: ; preds = %21
%26 = load i32*, i32** %5
%27 = load i32, i32* %13
%28 = load i32, i32* %14
%29 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %28)
%30 = load i32, i32* %14
store i32 %30, i32* %13
%31 = load i32, i32* %8
%32 = load i32, i32* %14
%33 = add nsw i32 %32, %31
store i32 %33, i32* %14
%34 = load i32*, i32** %6
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %52
40: ; preds = %25
%41 = load i32, i32* %12
%42 = load i32*, i32** %6
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = mul nsw i32 %41, %46
store i32 %47, i32* %11
%48 = load i32, i32* %11
%49 = icmp sle i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %40
store i32 1, i32* %11
br label %51
51: ; preds = %50, %40
br label %53
52: ; preds = %25
store i32 0, i32* %11
br label %53
53: ; preds = %52, %51
br label %54
54: ; preds = %57, %53
%55 = load i32, i32* %11
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = load i32*, i32** %5
%59 = call i32 @fputc(i8 signext 42, i32* %58)
%60 = load i32, i32* %11
%61 = add nsw i32 %60, -1
store i32 %61, i32* %11
br label %54
62: ; preds = %54
%63 = load i32*, i32** %5
%64 = call i32 @fputc(i8 signext 10, i32* %63)
br label %65
65: ; preds = %62
%66 = load i32, i32* %10
%67 = add nsw i32 %66, 1
store i32 %67, i32* %10
br label %21
68: ; preds = %21
ret i32 0
}

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