#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*/ printf(char *, ...);
int scanf(char *, int *);
int main() {
  int range;
  printf("Enter range: ");
  scanf("%d", &range);
  int length;
  printf("Enter length: ");
  scanf("%d", &length);
  int masiv[length];
  printf("Enter array: ");
  int i;
  for (i = 0; i < length; i++)
    if (scanf("%d", &masiv[i]) != 1)
      i--;
  printf("Histogram: \n");
  for (i = 0; i <= range; i++) {
    int j;
    printf("%d: ", i);
    for (j = 0; j < length; j++) {
      if (masiv[j] == i)
        printf("*");
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x39(%rbp)
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
mov    %rdi,-0x38(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x39(%rbp),%al
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f8 <main+0xd8>
mov    -0x30(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe40(%rip),%rdi
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     11e5 <main+0xc5>
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11ea <main+0xca>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ac <main+0x8c>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     128e <main+0x16e>
mov    -0x24(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1272 <main+0x152>
mov    -0x30(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x24(%rbp),%eax
jne    125f <main+0x13f>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1264 <main+0x144>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1231 <main+0x111>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120d <main+0xed>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeab(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea9(%rip),%r14
lea    -0x30(%rbp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
mov    %rsp,%r15
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11f3 <main+0xb3>
lea    0xe4d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %ebx,%rbx
lea    (%r12,%rbx,4),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
setne  %cl
neg    %ecx
add    %ecx,%ebx
add    $0x1,%ebx
cmp    -0x2c(%rbp),%ebx
jl     11d0 <main+0x90>
lea    0xe39(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,-0x30(%rbp)
js     1271 <main+0x131>
lea    0xe22(%rip),%r14
xor    %r13d,%r13d
jmp    1237 <main+0xf7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r13),%eax
cmp    -0x30(%rbp),%r13d
mov    %eax,%r13d
jge    1271 <main+0x131>
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
jle    1220 <main+0xe0>
xor    %ebx,%ebx
jmp    125c <main+0x11c>
nop
add    $0x1,%rbx
movslq %eax,%rcx
cmp    %rcx,%rbx
jge    1220 <main+0xe0>
cmp    %r13d,(%r12,%rbx,4)
jne    1250 <main+0x110>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    -0x2c(%rbp),%eax
jmp    1250 <main+0x110>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"Enter range: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [15 x i8] c"Enter length: \00"
@.str.3 = [14 x i8] c"Enter array: \00"
@.str.5 = [5 x i8] c"%d: \00"
@str = [12 x i8] c"Histogram: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = bitcast i32* %2 to i8*
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
%12 = alloca i32, i64 %10
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %0, %16
%17 = phi i32 [ %24, %16 ], [ 0, %0 ]
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %12, i64 %18
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = icmp ne i32 %20, 1
%22 = sext i1 %21 to i32
%23 = add nsw i32 %17, 1
%24 = add nsw i32 %23, %22
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %16, label %27
27: ; preds = %16, %0
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%29 = load i32, i32* %1
%30 = icmp slt i32 %29, 0
br i1 %30, label %55, label %31
31: ; preds = %27, %50
%32 = phi i32 [ %52, %50 ], [ 0, %27 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %2
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %50
36: ; preds = %31, %45
%37 = phi i32 [ %46, %45 ], [ %34, %31 ]
%38 = phi i64 [ %47, %45 ], [ 0, %31 ]
%39 = getelementptr inbounds i32, i32* %12, i64 %38
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, %32
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = call i32 @putchar(i32 42)
%44 = load i32, i32* %2
br label %45
45: ; preds = %36, %42
%46 = phi i32 [ %37, %36 ], [ %44, %42 ]
%47 = add nuw nsw i64 %38, 1
%48 = sext i32 %46 to i64
%49 = icmp slt i64 %47, %48
br i1 %49, label %36, label %50
50: ; preds = %45, %31
%51 = call i32 @putchar(i32 10)
%52 = add nuw nsw i32 %32, 1
%53 = load i32, i32* %1
%54 = icmp slt i32 %32, %53
br i1 %54, label %31, label %55
55: ; preds = %50, %27
ret i32 0
}