#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(void) {
  int ratingCounters[11], i, response;
  for (i = 1; i <= 10; ++i)
    ratingCounters[i] = 0;
  printf("Enter your responses, enter 999 when done.\n");
  for (i = 1; i <= 20; ++i) {
    scanf("%i", &response);
    if (response == 999)
      break;
    else if (response < 1 || response > 10)
      printf("Bad response: %i\n", response);
    else
      ++ratingCounters[response];
  }
  printf("\n\n");
  printf("Rating   Number of Responses\n");
  printf("------   -------------------\n");
  for (i = 1; i <= 10; ++i)
    printf("%4i%14i\n", i, ratingCounters[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jg     115a <main+0x3a>
movslq -0x34(%rbp),%rax
movl   $0x0,-0x30(%rbp,%rax,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1136 <main+0x16>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
cmpl   $0x14,-0x34(%rbp)
jg     11ec <main+0xcc>
lea    0xeac(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3e7,-0x38(%rbp)
jne    119b <main+0x7b>
jmp    11ec <main+0xcc>
cmpl   $0x1,-0x38(%rbp)
jl     11af <main+0x8f>
cmpl   $0xa,-0x38(%rbp)
jle    11c5 <main+0xa5>
mov    -0x38(%rbp),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d4 <main+0xb4>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11d9 <main+0xb9>
jmp    11de <main+0xbe>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116f <main+0x4f>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jg     124e <main+0x12e>
mov    -0x34(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    121d <main+0xfd>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x14(%rsp)
movups %xmm0,0x24(%rsp)
movq   $0x0,0x34(%rsp)
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
mov    $0x14,%ebp
lea    0xe98(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0xe8f(%rip),%r15
jmp    118a <main+0x5a>
cs nopw 0x0(%rax,%rax,1)
addl   $0x1,0x10(%rsp,%rsi,4)
add    $0xffffffff,%ebp
je     11b9 <main+0x89>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0x3e7,%rsi
je     11b9 <main+0x89>
lea    -0xb(%rsi),%eax
cmp    $0xfffffff5,%eax
ja     1180 <main+0x50>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    118a <main+0x5a>
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    0x14(%rsp),%edx
lea    0xe2d(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%edx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x24(%rsp),%edx
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x28(%rsp),%edx
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2c(%rsp),%edx
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x30(%rsp),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x34(%rsp),%edx
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x38(%rsp),%edx
mov    %rbx,%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [18 x i8] c"Bad response: %i\0A\00"
@.str.6 = [9 x i8] c"%4i%14i\0A\00"
@str = [43 x i8] c"Enter your responses, enter 999 when done.\00"
@str.7 = [2 x i8] c"\0A\00"
@str.8 = [29 x i8] c"Rating Number of Responses\00"
@str.9 = [29 x i8] c"------ -------------------\00"
define i32 @main() {
%1 = alloca [11 x i32]
%2 = alloca i32
%3 = bitcast [11 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 1
%6 = bitcast i32* %5 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %0, %23
%9 = phi i32 [ 1, %0 ], [ %24, %23 ]
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 999
br i1 %12, label %26, label %13
13: ; preds = %8
%14 = add i32 %11, -11
%15 = icmp ult i32 %14, -10
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %23
18: ; preds = %13
%19 = zext i32 %11 to i64
%20 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %20
br label %23
23: ; preds = %18, %16
%24 = add nuw nsw i32 %9, 1
%25 = icmp eq i32 %24, 21
br i1 %25, label %26, label %8
26: ; preds = %8, %23
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.8, i64 0, i64 0))
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.9, i64 0, i64 0))
%30 = load i32, i32* %5
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 1, i32 %30)
%32 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 2
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 2, i32 %33)
%35 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 3
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 3, i32 %36)
%38 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 4
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 4, i32 %39)
%41 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 5
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 5, i32 %42)
%44 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 6
%45 = load i32, i32* %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 6, i32 %45)
%47 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 7
%48 = load i32, i32* %47
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 7, i32 %48)
%50 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 8
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 8, i32 %51)
%53 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 9
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 9, i32 %54)
%56 = getelementptr inbounds [11 x i32], [11 x i32]* %1, i64 0, i64 10
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 10, i32 %57)
ret i32 0
}