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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jg     115a <main+0x3a>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x40(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jl     118c <main+0x6c>
cmpl   $0xa,-0xc(%rbp)
jle    11b4 <main+0x94>
cmpl   $0x3e7,-0xc(%rbp)
jne    119e <main+0x7e>
jmp    11c8 <main+0xa8>
mov    -0xc(%rbp),%esi
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <main+0xa3>
movslq -0xc(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x40(%rbp,%rax,4)
jmp    1168 <main+0x48>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jg     121c <main+0xfc>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11eb <main+0xcb>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x24(%rsp)
movups %xmm0,0x14(%rsp)
movq   $0x0,0x34(%rsp)
lea    0xec7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9e(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0xe95(%rip),%r15
jmp    1175 <main+0x45>
addl   $0x1,0x10(%rsp,%rsi,4)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    -0xb(%rsi),%eax
cmp    $0xfffffff5,%eax
ja     1170 <main+0x40>
cmp    $0x3e7,%esi
je     11a0 <main+0x70>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1175 <main+0x45>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
mov    0x14(%rsp),%edx
lea    0xe51(%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    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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