#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);
int /*<<< orphan*/ scanf(char *, ...);
int strlen(char *);
int main(int argc, char const *argv[]) {
  int iterations = 0;
  int holes = 0;
  scanf("%d", &iterations);
  char text[100] = "";
  while (iterations--) {
    holes = 0;
    scanf("%s", text);
    for (int i = 0; i < strlen(text); ++i) {
      switch (text[i]) {
      case 65:
      case 68:
      case 79:
      case 80:
      case 81:
      case 82:
        holes++;
        break;
      case 66:
        holes += 2;
      }
    }
    printf("%d\n", holes);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe92(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1288 <main+0x148>
movl   $0x0,-0x18(%rbp)
lea    -0x80(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%eax
cmp    %ecx,%eax
jge    1274 <main+0x134>
movslq -0x84(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
mov    %eax,-0x8c(%rbp)
sub    $0x41,%eax
je     1244 <main+0x104>
jmp    1205 <main+0xc5>
mov    -0x8c(%rbp),%eax
sub    $0x42,%eax
je     1252 <main+0x112>
jmp    1219 <main+0xd9>
mov    -0x8c(%rbp),%eax
sub    $0x44,%eax
je     1244 <main+0x104>
jmp    122d <main+0xed>
mov    -0x8c(%rbp),%eax
add    $0xffffffb1,%eax
sub    $0x3,%eax
ja     125b <main+0x11b>
jmp    1244 <main+0x104>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    125b <main+0x11b>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    1260 <main+0x120>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11c0 <main+0x80>
mov    -0x18(%rbp),%esi
lea    0xd88(%rip),%rdi
call   1040 <printf@plt>
jmp    1189 <main+0x49>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb3(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
subl   $0x1,0xc(%rsp)
jae    119a <main+0x6a>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe62(%rip),%r14
lea    0x10(%rsp),%r13
mov    $0x3c009,%r12d
lea    0xe53(%rip),%r15
jmp    11d1 <main+0xa1>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1189 <main+0x59>
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11c0 <main+0x90>
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1216 <main+0xe6>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
add    $0x1,%rbx
mov    %r13,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11c0 <main+0x90>
movsbl 0x10(%rsp,%rbx,1),%eax
add    $0xffffffbf,%eax
cmp    $0x11,%eax
ja     1203 <main+0xd3>
bt     %eax,%r12d
jb     1200 <main+0xd0>
cmp    $0x1,%eax
jne    1203 <main+0xd3>
add    $0x2,%ebp
jmp    1203 <main+0xd3>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [100 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%11 = bitcast [100 x i8]* %8 to i8*
br label %12
12: ; preds = %40, %2
%13 = load i32, i32* %6
%14 = add nsw i32 %13, -1
store i32 %14, i32* %6
%15 = icmp ne i32 %13, 0
br i1 %15, label %16, label %43
16: ; preds = %12
store i32 0, i32* %7
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 0, i32* %9
br label %19
19: ; preds = %37, %16
%20 = load i32, i32* %9
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %40
24: ; preds = %19
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
switch i32 %29, label %36 [
i32 65, label %30
i32 68, label %30
i32 79, label %30
i32 80, label %30
i32 81, label %30
i32 82, label %30
i32 66, label %33
]
30: ; preds = %24, %24, %24, %24, %24, %24
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %36
33: ; preds = %24
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 2
store i32 %35, i32* %7
br label %36
36: ; preds = %33, %24, %30
br label %37
37: ; preds = %36
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %19
40: ; preds = %19
%41 = load i32, i32* %7
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %12
43: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [100 x i8]
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = load i32, i32* %3
%9 = add nsw i32 %8, -1
store i32 %9, i32* %3
%10 = icmp eq i32 %8, 0
br i1 %10, label %37, label %11
11: ; preds = %2, %15
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%13 = call i32 @strlen(i8* %7)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %31, %11
%16 = phi i32 [ 0, %11 ], [ %32, %31 ]
%17 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %3
%19 = add nsw i32 %18, -1
store i32 %19, i32* %3
%20 = icmp eq i32 %18, 0
br i1 %20, label %37, label %11
21: ; preds = %11, %31
%22 = phi i64 [ %33, %31 ], [ 0, %11 ]
%23 = phi i32 [ %32, %31 ], [ 0, %11 ]
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %22
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
switch i32 %26, label %31 [
i32 65, label %27
i32 68, label %27
i32 79, label %27
i32 80, label %27
i32 81, label %27
i32 82, label %27
i32 66, label %29
]
27: ; preds = %21, %21, %21, %21, %21, %21
%28 = add nsw i32 %23, 1
br label %31
29: ; preds = %21
%30 = add nsw i32 %23, 2
br label %31
31: ; preds = %27, %21, %29
%32 = phi i32 [ %23, %21 ], [ %30, %29 ], [ %28, %27 ]
%33 = add nuw nsw i64 %22, 1
%34 = call i32 @strlen(i8* %7)
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %21, label %15
37: ; preds = %15, %2
ret i32 0
}