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


x86 assembly (clang, -O0):
<vhist>:
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   $0x64,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1212 <vhist+0xe2>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f6 <vhist+0xc6>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
imul   -0x28(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     11c8 <vhist+0x98>
mov    -0x8(%rbp),%rdi
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11da <vhist+0xaa>
mov    -0x8(%rbp),%rdi
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <fputc@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118d <vhist+0x5d>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    117c <vhist+0x4c>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1245 <vhist+0x115>
mov    -0x8(%rbp),%rdi
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1219 <vhist+0xe9>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    129a <vhist+0x16a>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
lea    0xd9c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <fputc@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    125a <vhist+0x12a>
mov    -0x8(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vhist>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,(%rsp)
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %edx,%esi
call   1050 <maxelem@plt>
mov    %eax,%ecx
mov    $0x64,%ebp
mov    $0x64,%eax
xor    %edx,%edx
idiv   %ecx
mov    %eax,%r13d
mov    %r15d,%r14d
mov    %r15d,0x4(%rsp)
jmp    119e <vhist+0x5e>
xchg   %ax,%ax
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
cmp    $0x2,%ebp
mov    0x4(%rsp),%r15d
jb     1217 <vhist+0xd7>
add    $0xffffffff,%ebp
test   %r15d,%r15d
jle    1200 <vhist+0xc0>
xor    %r15d,%r15d
jmp    11d8 <vhist+0x98>
nopl   0x0(%rax,%rax,1)
mov    $0x5,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     1180 <vhist+0x40>
mov    (%r12,%r15,4),%eax
imul   %r13d,%eax
lea    0xe1f(%rip),%rdi
cmp    %ebp,%eax
jl     11b0 <vhist+0x70>
lea    0xe0e(%rip),%rdi
jmp    11b0 <vhist+0x70>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
cmp    $0x1,%ebp
ja     119b <vhist+0x5b>
jmp    1296 <vhist+0x156>
test   %r15d,%r15d
jle    1296 <vhist+0x156>
lea    0xde9(%rip),%r14
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    $0x6,%esi
mov    $0x1,%edx
mov    %r14,%rdi
mov    %rbx,%rcx
call   1060 <fwrite@plt>
add    $0xffffffff,%ebp
jne    1230 <vhist+0xf0>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
test   %r15d,%r15d
mov    (%rsp),%ebp
jle    12a3 <vhist+0x163>
lea    0xdad(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x20,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0xffffffff,%r15d
jne    1270 <vhist+0x130>
jmp    12a3 <vhist+0x163>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c" * \00"
@.str.1 = [6 x i8] c" \00"
@.str.2 = [7 x i8] c"======\00"
@.str.3 = [10 x i8] c"%02d-%02d\00"
define i32 @vhist(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 100, i32* %10
br label %21
21: ; preds = %54, %4
%22 = load i32, i32* %10
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %57
24: ; preds = %21
store i32 0, i32* %11
br label %25
25: ; preds = %48, %24
%26 = load i32, i32* %11
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %51
29: ; preds = %25
%30 = load i32*, i32** %6
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = load i32, i32* %12
%36 = mul nsw i32 %34, %35
%37 = load i32, i32* %10
%38 = icmp sge i32 %36, %37
br i1 %38, label %39, label %42
39: ; preds = %29
%40 = load i32*, i32** %5
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %40, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %45
42: ; preds = %29
%43 = load i32*, i32** %5
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %45
45: ; preds = %42, %39
%46 = load i32*, i32** %5
%47 = call i32 @fputc(i8 signext 32, i32* %46)
br label %48
48: ; preds = %45
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
br label %25
51: ; preds = %25
%52 = load i32*, i32** %5
%53 = call i32 @fputc(i8 signext 10, i32* %52)
br label %54
54: ; preds = %51
%55 = load i32, i32* %10
%56 = add nsw i32 %55, -1
store i32 %56, i32* %10
br label %21
57: ; preds = %21
store i32 0, i32* %10
br label %58
58: ; preds = %65, %57
%59 = load i32, i32* %10
%60 = load i32, i32* %7
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %68
62: ; preds = %58
%63 = load i32*, i32** %5
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %65
65: ; preds = %62
%66 = load i32, i32* %10
%67 = add nsw i32 %66, 1
store i32 %67, i32* %10
br label %58
68: ; preds = %58
%69 = load i32*, i32** %5
%70 = call i32 @fputc(i8 signext 10, i32* %69)
store i32 0, i32* %10
br label %71
71: ; preds = %82, %68
%72 = load i32, i32* %10
%73 = load i32, i32* %7
%74 = icmp slt i32 %72, %73
br i1 %74, label %75, label %85
75: ; preds = %71
%76 = load i32*, i32** %5
%77 = load i32, i32* %13
%78 = load i32, i32* %14
%79 = call i32 (i32*, i8*, ...) @fprintf(i32* %76, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %77, i32 %78)
%80 = load i32*, i32** %5
%81 = call i32 @fputc(i8 signext 32, i32* %80)
br label %82
82: ; preds = %75
%83 = load i32, i32* %10
%84 = add nsw i32 %83, 1
store i32 %84, i32* %10
br label %71
85: ; preds = %71
%86 = load i32*, i32** %5
%87 = call i32 @fputc(i8 signext 10, i32* %86)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c" * \00"
@.str.1 = [6 x i8] c" \00"
@.str.2 = [7 x i8] c"======\00"
@.str.3 = [10 x i8] c"%02d-%02d\00"
define i32 @vhist(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
%8 = zext i32 %2 to i64
br label %9
9: ; preds = %26, %4
%10 = phi i32 [ 100, %4 ], [ %27, %26 ]
br i1 %7, label %12, label %28
11: ; preds = %23
br i1 %7, label %31, label %36
12: ; preds = %9, %12
%13 = phi i64 [ %21, %12 ], [ 0, %9 ]
%14 = getelementptr inbounds i32, i32* %1, i64 %13
%15 = load i32, i32* %14
%16 = mul nsw i32 %15, %6
%17 = icmp slt i32 %16, %10
%18 = select i1 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)
%19 = tail call i64 @fwrite(i8* %18, i64 5, i64 1, i32* %0)
%20 = tail call i32 @fputc(i8 signext 32, i32* %0)
%21 = add nuw nsw i64 %13, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %12
23: ; preds = %12
%24 = tail call i32 @fputc(i8 signext 10, i32* %0)
%25 = icmp ugt i32 %10, 1
br i1 %25, label %26, label %11
26: ; preds = %23, %28
%27 = add nsw i32 %10, -1
br label %9
28: ; preds = %9
%29 = tail call i32 @fputc(i8 signext 10, i32* %0)
%30 = icmp ugt i32 %10, 1
br i1 %30, label %26, label %36
31: ; preds = %11, %31
%32 = phi i32 [ %34, %31 ], [ 0, %11 ]
%33 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 6, i64 1, i32* %0)
%34 = add nuw nsw i32 %32, 1
%35 = icmp eq i32 %34, %2
br i1 %35, label %38, label %31
36: ; preds = %28, %11
%37 = tail call i32 @fputc(i8 signext 10, i32* %0)
br label %46
38: ; preds = %31
%39 = tail call i32 @fputc(i8 signext 10, i32* %0)
br i1 %7, label %40, label %46
40: ; preds = %38, %40
%41 = phi i32 [ %44, %40 ], [ 0, %38 ]
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %3)
%43 = tail call i32 @fputc(i8 signext 32, i32* %0)
%44 = add nuw nsw i32 %41, 1
%45 = icmp eq i32 %44, %2
br i1 %45, label %46, label %40
46: ; preds = %40, %36, %38
%47 = tail call i32 @fputc(i8 signext 10, i32* %0)
ret i32 0
}