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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x41(%rbp)
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
mov    %rdi,-0x40(%rbp)
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x41(%rbp),%al
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%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,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0xc,-0x24(%rbp)
jge    11df <main+0xbf>
mov    -0x38(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe42(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ac <main+0x8c>
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     12a4 <main+0x184>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0xc,-0x28(%rbp)
jge    1248 <main+0x128>
mov    -0x38(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x24(%rbp),%eax
jne    1235 <main+0x115>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    123a <main+0x11a>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    120e <main+0xee>
mov    -0x24(%rbp),%esi
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1288 <main+0x168>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1260 <main+0x140>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11f4 <main+0xd4>
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
sub    $0x18,%rsp
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea8(%rip),%r14
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x30(%rbp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
mov    %rsp,-0x38(%rbp)
mov    -0x30(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rbx
and    $0xfffffffffffffff0,%rbx
mov    %r12,%r15
sub    %rbx,%r15
mov    %r15,%rsp
lea    0xe6e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
neg    %rbx
lea    (%r12,%rbx,1),%rsi
add    $0x4,%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x8(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0xc(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x10(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x14(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x18(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x1c(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x20(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x24(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x28(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0x2c(%r15),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
lea    0xddd(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,-0x2c(%rbp)
js     1337 <main+0x1f7>
xor    %r14d,%r14d
jmp    128b <main+0x14b>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r14),%eax
cmp    -0x2c(%rbp),%r14d
mov    %eax,%r14d
jge    1337 <main+0x1f7>
movd   %r14d,%xmm0
pshufd $0x0,%xmm0,%xmm0
movdqa 0x10(%r15),%xmm1
pcmpeqd %xmm0,%xmm1
movdqa (%r15),%xmm2
pcmpeqd %xmm0,%xmm2
packssdw %xmm1,%xmm2
packsswb %xmm2,%xmm2
pmovmskb %xmm2,%eax
mov    %eax,%ecx
shr    %cl
and    $0x55,%cl
sub    %cl,%al
mov    %eax,%ecx
and    $0x33,%cl
shr    $0x2,%al
and    $0x33,%al
add    %cl,%al
mov    %eax,%ecx
shr    $0x4,%cl
add    %al,%cl
and    $0xf,%cl
movzbl %cl,%r13d
pcmpeqd 0x20(%r15),%xmm0
movmskps %xmm0,%eax
mov    %eax,%ecx
shr    %cl
and    $0x5,%cl
sub    %cl,%al
mov    %eax,%ecx
and    $0x33,%cl
shr    $0x2,%al
and    $0x33,%al
add    %cl,%al
mov    %eax,%ecx
shr    $0x4,%cl
add    %al,%cl
and    $0xf,%cl
movzbl %cl,%r12d
lea    0xd24(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    %r13d,%r12d
je     1270 <main+0x130>
xor    %ebx,%ebx
nop
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %r12d,%ebx
jb     1320 <main+0x1e0>
jmp    1270 <main+0x130>
mov    -0x38(%rbp),%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
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %4
%16 = alloca i32, i64 %14
store i64 %14, i64* %5
%17 = 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 %18
18: ; preds = %26, %0
%19 = load i32, i32* %6
%20 = icmp slt i32 %19, 12
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %16, i64 %23
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %21
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %18
29: ; preds = %18
%30 = 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 %31
31: ; preds = %67, %29
%32 = load i32, i32* %6
%33 = load i32, i32* %2
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %70
35: ; preds = %31
store i32 0, i32* %8
store i32 0, i32* %7
br label %36
36: ; preds = %50, %35
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 12
br i1 %38, label %39, label %53
39: ; preds = %36
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %16, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %6
%45 = icmp eq i32 %43, %44
br i1 %45, label %46, label %49
46: ; preds = %39
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %49
49: ; preds = %46, %39
br label %50
50: ; preds = %49
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %36
53: ; preds = %36
%54 = load i32, i32* %6
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %54)
store i32 0, i32* %7
br label %56
56: ; preds = %62, %53
%57 = load i32, i32* %7
%58 = load i32, i32* %8
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %65
60: ; preds = %56
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %62
62: ; preds = %60
%63 = load i32, i32* %7
%64 = add nsw i32 %63, 1
store i32 %64, i32* %7
br label %56
65: ; preds = %56
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %67
67: ; preds = %65
%68 = load i32, i32* %6
%69 = add nsw i32 %68, 1
store i32 %69, i32* %6
br label %31
70: ; preds = %31
store i32 0, i32* %1
%71 = load i8*, i8** %4
%72 = load i32, i32* %1
ret i32 %72
}

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 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%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 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%15 = getelementptr inbounds i32, i32* %12, i64 1
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds i32, i32* %12, i64 2
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds i32, i32* %12, i64 3
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds i32, i32* %12, i64 4
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %21)
%23 = getelementptr inbounds i32, i32* %12, i64 5
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = getelementptr inbounds i32, i32* %12, i64 6
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
%27 = getelementptr inbounds i32, i32* %12, i64 7
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %27)
%29 = getelementptr inbounds i32, i32* %12, i64 8
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
%31 = getelementptr inbounds i32, i32* %12, i64 9
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %31)
%33 = getelementptr inbounds i32, i32* %12, i64 10
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %33)
%35 = getelementptr inbounds i32, i32* %12, i64 11
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %35)
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%38 = load i32, i32* %1
%39 = icmp slt i32 %38, 0
br i1 %39, label %72, label %40
40: ; preds = %0
%41 = bitcast i32* %12 to <8 x i32>*
%42 = bitcast i32* %29 to <4 x i32>*
br label %43
43: ; preds = %40, %67
%44 = phi i32 [ %69, %67 ], [ 0, %40 ]
%45 = load <8 x i32>, <8 x i32>* %41
%46 = insertelement <8 x i32> poison, i32 %44, i64 0
%47 = shufflevector <8 x i32> %46, <8 x i32> poison, <8 x i32> zeroinitializer
%48 = icmp eq <8 x i32> %45, %47
%49 = load <4 x i32>, <4 x i32>* %42
%50 = insertelement <4 x i32> poison, i32 %44, i64 0
%51 = shufflevector <4 x i32> %50, <4 x i32> poison, <4 x i32> zeroinitializer
%52 = icmp eq <4 x i32> %49, %51
%53 = bitcast <8 x i1> %48 to i8
%54 = call i8 @llvm.ctpop.i8(i8 %53)
%55 = zext i8 %54 to i32
%56 = bitcast <4 x i1> %52 to i4
%57 = call i4 @llvm.ctpop.i4(i4 %56)
%58 = zext i4 %57 to i32
%59 = add nuw nsw i32 %55, %58
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%61 = icmp eq i32 %59, 0
br i1 %61, label %67, label %62
62: ; preds = %43, %62
%63 = phi i32 [ %65, %62 ], [ 0, %43 ]
%64 = call i32 @putchar(i32 42)
%65 = add nuw nsw i32 %63, 1
%66 = icmp ult i32 %65, %59
br i1 %66, label %62, label %67
67: ; preds = %62, %43
%68 = call i32 @putchar(i32 10)
%69 = add nuw nsw i32 %44, 1
%70 = load i32, i32* %1
%71 = icmp slt i32 %44, %70
br i1 %71, label %43, label %72
72: ; preds = %67, %0
ret i32 0
}