#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, ...);
int main(void) {
  char res[80], *ptr;
  int score, total;
  scanf("%*d");
  while (scanf("%s", res) != EOF) {
    total = 0;
    score = 0;
    for (ptr = res; *ptr; ptr++) {
      if (*ptr == 'O')
        total += ++score;
      else
        score = 0;
    }
    printf("%d\n", total);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x60(%rbp),%rsi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%rax
je     11d7 <main+0xb7>
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x6c(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c3 <main+0xa3>
mov    -0x68(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4f,%eax
jne    11a6 <main+0x86>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
add    -0x70(%rbp),%eax
mov    %eax,-0x70(%rbp)
jmp    11ad <main+0x8d>
movl   $0x0,-0x6c(%rbp)
jmp    11b2 <main+0x92>
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1175 <main+0x55>
mov    -0x70(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x50,%rsp
lea    0xecc(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xec0(%rip),%rdi
mov    %rsp,%r13
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x2e90(%rip),%r12
cmp    (%r12),%rax
je     11c5 <main+0xa5>
lea    0xea2(%rip),%r14
lea    0xe98(%rip),%r15
mov    %r13,%rcx
xor    %esi,%esi
jmp    1186 <main+0x66>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rcx
mov    %eax,%ebx
movzbl (%rcx),%edx
test   %dl,%dl
je     11a0 <main+0x80>
xor    %eax,%eax
cmp    $0x4f,%dl
jne    1180 <main+0x60>
mov    %ebx,%eax
add    $0x1,%eax
add    %ebx,%esi
add    $0x1,%esi
jmp    1180 <main+0x60>
mov    %r14,%rdi
call   1030 <printf@plt>
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %r13,%rcx
mov    $0x0,%esi
cmp    (%r12),%rax
jne    1186 <main+0x66>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%*d\00"
@.str.1 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i64, i64* @EOF
%6 = icmp eq i64 %4, %5
br i1 %6, label %28, label %7
7: ; preds = %0, %19
%8 = phi i8* [ %20, %19 ], [ %2, %0 ]
%9 = phi i32 [ %21, %19 ], [ 0, %0 ]
%10 = phi i32 [ %22, %19 ], [ 0, %0 ]
%11 = load i8, i8* %8
switch i8 %11, label %15 [
i8 0, label %23
i8 79, label %12
]
12: ; preds = %7
%13 = add nsw i32 %9, 1
%14 = add nsw i32 %10, %13
br label %15
15: ; preds = %7, %12
%16 = phi i32 [ %13, %12 ], [ 0, %7 ]
%17 = phi i32 [ %14, %12 ], [ %10, %7 ]
%18 = getelementptr inbounds i8, i8* %8, i64 1
br label %19
19: ; preds = %15, %23
%20 = phi i8* [ %18, %15 ], [ %2, %23 ]
%21 = phi i32 [ %16, %15 ], [ 0, %23 ]
%22 = phi i32 [ %17, %15 ], [ 0, %23 ]
br label %7
23: ; preds = %7
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%25 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %19
28: ; preds = %23, %0
ret i32 0
}