#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 *, char *);
void main() {
  char a;
  int i, as = 0, bs = 0, cs = 0;
  for (i = 0; i < 20; i += 1) {
    printf("Please enter a character: ");
    scanf(" %c", &a);
    switch (a) {
    case 'A':
    case 'a':
      as += 1;
      break;
    case 'B':
    case 'b':
      bs += 1;
      break;
    case 'C':
    case 'c':
      cs += 1;
      break;
    }
  }
  printf("A: %d\n", as);
  printf("B: %d\n", bs);
  printf("C: %d\n", cs);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    120e <main+0xee>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x1(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x41,%eax
je     11d6 <main+0xb6>
jmp    1181 <main+0x61>
mov    -0x18(%rbp),%eax
sub    $0x42,%eax
je     11e4 <main+0xc4>
jmp    1192 <main+0x72>
mov    -0x18(%rbp),%eax
sub    $0x43,%eax
je     11f2 <main+0xd2>
jmp    11a3 <main+0x83>
mov    -0x18(%rbp),%eax
sub    $0x61,%eax
je     11d6 <main+0xb6>
jmp    11b4 <main+0x94>
mov    -0x18(%rbp),%eax
sub    $0x62,%eax
je     11e4 <main+0xc4>
jmp    11c5 <main+0xa5>
mov    -0x18(%rbp),%eax
sub    $0x63,%eax
je     11f2 <main+0xd2>
jmp    11fb <main+0xdb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11fb <main+0xdb>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11fb <main+0xdb>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1200 <main+0xe0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <main+0x24>
mov    -0xc(%rbp),%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x14,%r14d
lea    0xee3(%rip),%r15
lea    0x7(%rsp),%r12
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1159 <main+0x39>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0xffffffff,%r14d
je     11c5 <main+0xa5>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
movsbl 0x7(%rsp),%eax
add    $0xffffffbf,%eax
cmp    $0x22,%eax
ja     1153 <main+0x33>
movabs $0x100000001,%rcx
bt     %rax,%rcx
jb     11c0 <main+0xa0>
movabs $0x200000002,%rcx
bt     %rax,%rcx
jb     1150 <main+0x30>
movabs $0x400000004,%rcx
bt     %rax,%rcx
jae    1153 <main+0x33>
add    $0x1,%r13d
jmp    1153 <main+0x33>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebx
jmp    1153 <main+0x33>
lea    0xe53(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4a(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe41(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Please enter a character: \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [7 x i8] c"A: %d\0A\00"
@.str.3 = [7 x i8] c"B: %d\0A\00"
@.str.4 = [7 x i8] c"C: %d\0A\00"
define void @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %2
br label %6
6: ; preds = %24, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 20
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%12 = load i8, i8* %1
%13 = sext i8 %12 to i32
switch i32 %13, label %23 [
i32 65, label %14
i32 97, label %14
i32 66, label %17
i32 98, label %17
i32 67, label %20
i32 99, label %20
]
14: ; preds = %9, %9
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %23
17: ; preds = %9, %9
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %23
20: ; preds = %9, %9
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %23
23: ; preds = %9, %20, %17, %14
br label %24
24: ; preds = %23
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %6
27: ; preds = %6
%28 = load i32, i32* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %32)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"Please enter a character: \00"
@.str.1 = [4 x i8] c" %c\00"
@.str.2 = [7 x i8] c"A: %d\0A\00"
@.str.3 = [7 x i8] c"B: %d\0A\00"
@.str.4 = [7 x i8] c"C: %d\0A\00"
define void @main() {
%1 = alloca i8
br label %2
2: ; preds = %0, %17
%3 = phi i32 [ 0, %0 ], [ %20, %17 ]
%4 = phi i32 [ 0, %0 ], [ %19, %17 ]
%5 = phi i32 [ 0, %0 ], [ %18, %17 ]
%6 = phi i32 [ 0, %0 ], [ %21, %17 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%9 = load i8, i8* %1
%10 = sext i8 %9 to i32
switch i32 %10, label %17 [
i32 65, label %11
i32 97, label %11
i32 66, label %13
i32 98, label %13
i32 67, label %15
i32 99, label %15
]
11: ; preds = %2, %2
%12 = add nsw i32 %5, 1
br label %17
13: ; preds = %2, %2
%14 = add nsw i32 %4, 1
br label %17
15: ; preds = %2, %2
%16 = add nsw i32 %3, 1
br label %17
17: ; preds = %11, %13, %15, %2
%18 = phi i32 [ %5, %2 ], [ %5, %15 ], [ %5, %13 ], [ %12, %11 ]
%19 = phi i32 [ %4, %2 ], [ %4, %15 ], [ %14, %13 ], [ %4, %11 ]
%20 = phi i32 [ %3, %2 ], [ %16, %15 ], [ %3, %13 ], [ %3, %11 ]
%21 = add nuw nsw i32 %6, 1
%22 = icmp eq i32 %21, 20
br i1 %22, label %23, label %2
23: ; preds = %17
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 %20)
ret void
}