#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() {
  int l, i, j, range, length;
  int origarray[length];
  printf("length:");
  scanf("%d", &length);
  printf("range:");
  scanf("%d", &range);
  printf("array:");
  for (i = 0; i <= length; i++) {
    scanf("%d", &origarray[i]);
  }
  for (i = 0; i <= range; i++) {
    printf("%d:", i);
    for (l = 0; l < length; l++) {
      if (i == origarray[l]) {
        printf("*");
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11dc <main+0xbc>
mov    -0x30(%rbp),%rsi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe3f(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a7 <main+0x87>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1264 <main+0x144>
mov    -0xc(%rbp),%esi
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1248 <main+0x128>
mov    -0x30(%rbp),%rcx
mov    -0xc(%rbp),%eax
movslq -0x8(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    1235 <main+0x115>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <main+0x11a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1207 <main+0xe7>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e3 <main+0xc3>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r15
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb5(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x10(%rsp)
js     11cd <main+0x9d>
mov    %rsp,%r12
mov    $0xffffffffffffffff,%rbx
lea    0xe67(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
movslq 0x10(%rsp),%rax
add    $0x4,%r12
add    $0x1,%rbx
cmp    %rax,%rbx
jl     11b0 <main+0x80>
cmpl   $0x0,0x14(%rsp)
js     1242 <main+0x112>
lea    0xe3e(%rip),%r14
xor    %r12d,%r12d
jmp    11f9 <main+0xc9>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r12),%eax
cmp    0x14(%rsp),%r12d
mov    %eax,%r12d
jge    1242 <main+0x112>
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    11e0 <main+0xb0>
xor    %ebx,%ebx
jmp    122c <main+0xfc>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
movslq %eax,%rcx
cmp    %rcx,%rbx
jge    11e0 <main+0xb0>
cmp    (%rsp),%r12d
jne    1220 <main+0xf0>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    0x10(%rsp),%eax
jmp    1220 <main+0xf0>
mov    %r15,%rsp
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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