#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, resNumber;
  for (i = 1; i <= 10; ++i)
    ratingCounters[i] = 0;
  printf("Enter your responses\n");
  while (response != 99) {
    scanf("%i", &response);
    if (response == 999) {
      printf("That's all.");
      break;
    } else if (response < 1 || response > 10)
      printf("Bad response: %i\n", response);
    else
      ++ratingCounters[response];
  }
  printf("\n\nRating 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>
cmpl   $0x63,-0x38(%rbp)
je     11e5 <main+0xc5>
lea    0xe9d(%rip),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x3e7,-0x38(%rbp)
jne    11a2 <main+0x82>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e5 <main+0xc5>
cmpl   $0x1,-0x38(%rbp)
jl     11b6 <main+0x96>
cmpl   $0xa,-0x38(%rbp)
jle    11cc <main+0xac>
mov    -0x38(%rbp),%esi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11db <main+0xbb>
movslq -0x38(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x30(%rbp,%rax,4)
jmp    11e0 <main+0xc0>
jmp    1168 <main+0x48>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jg     1239 <main+0x119>
mov    -0x34(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1208 <main+0xe8>
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,0x14(%rsp)
movups %xmm0,0x24(%rsp)
movq   $0x0,0x34(%rsp)
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9e(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0xea1(%rip),%r15
jmp    117a <main+0x4a>
addl   $0x1,0x10(%rsp,%rsi,4)
cmp    $0x63,%esi
je     11bd <main+0x8d>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0x3e7,%rsi
je     11af <main+0x7f>
lea    -0xb(%rsi),%eax
cmp    $0xfffffff5,%eax
ja     1170 <main+0x40>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
cmp    $0x63,%esi
jne    117a <main+0x4a>
jmp    11bd <main+0x8d>
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
mov    0x14(%rsp),%edx
lea    0xe41(%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 = [12 x i8] c"That's all.\00"
@.str.3 = [18 x i8] c"Bad response: %i\0A\00"
@.str.4 = [30 x i8] c"\0A\0ARating Number of Responses\0A\00"
@.str.5 = [28 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
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 10
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 %11
store i32 0, i32* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %6
16: ; preds = %6
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %43, %16
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 99
br i1 %20, label %21, label %44
21: ; preds = %18
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 999
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %44
27: ; preds = %21
%28 = load i32, i32* %4
%29 = icmp slt i32 %28, 1
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load i32, i32* %4
%32 = icmp sgt i32 %31, 10
br i1 %32, label %33, label %36
33: ; preds = %30, %27
%34 = load i32, i32* %4
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %42
36: ; preds = %30
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %39
br label %42
42: ; preds = %36, %33
br label %43
43: ; preds = %42
br label %18
44: ; preds = %25, %18
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %47
47: ; preds = %57, %44
%48 = load i32, i32* %3
%49 = icmp sle i32 %48, 10
br i1 %49, label %50, label %60
50: ; preds = %47
%51 = load i32, i32* %3
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [11 x i32], [11 x i32]* %2, i64 0, i64 %53
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %51, i32 %55)
br label %57
57: ; preds = %50
%58 = load i32, i32* %3
%59 = add nsw i32 %58, 1
store i32 %59, i32* %3
br label %47
60: ; preds = %47
ret i32 0
}

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