#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 readConditionBlockAndCount(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int readProgramAndCount() {
  char word[100 + 1];
  int count = 1;
  while (1) {
    scanf("%s", word);
    if (strcmp(word, "ENDPROGRAM") == 0)
      break;
    if (strcmp(word, "S") == 0)
      continue;
    count *= readConditionBlockAndCount(0, 0);
  }
  return count;
}


x86 assembly (clang, -O0):
<readProgramAndCount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x1,-0x74(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xeb3(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1171 <readProgramAndCount+0x41>
jmp    11a5 <readProgramAndCount+0x75>
lea    -0x70(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1190 <readProgramAndCount+0x60>
jmp    1142 <readProgramAndCount+0x12>
xor    %esi,%esi
mov    %esi,%edi
call   1040 <readConditionBlockAndCount@plt>
imul   -0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    1142 <readProgramAndCount+0x12>
mov    -0x74(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readProgramAndCount>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    $0x1,%r14d
lea    0xeb7(%rip),%r15
mov    %rsp,%rbp
lea    0xeb0(%rip),%rbx
lea    0xeb4(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     119a <readProgramAndCount+0x6a>
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1160 <readProgramAndCount+0x30>
xor    %edi,%edi
xor    %esi,%esi
call   1040 <readConditionBlockAndCount@plt>
imul   %eax,%r14d
jmp    1160 <readProgramAndCount+0x30>
mov    %r14d,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [11 x i8] c"ENDPROGRAM\00"
@.str.2 = [2 x i8] c"S\00"
define i32 @readProgramAndCount() {
%1 = alloca [101 x i8]
%2 = alloca i32
store i32 1, i32* %2
br label %3
3: ; preds = %0, %14, %15
%4 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %3
br label %19
10: ; preds = %3
%11 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
br label %3
15: ; preds = %10
%16 = call i32 @readConditionBlockAndCount(i32 0, i32 0)
%17 = load i32, i32* %2
%18 = mul nsw i32 %17, %16
store i32 %18, i32* %2
br label %3
19: ; preds = %9
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [11 x i8] c"ENDPROGRAM\00"
@.str.2 = [2 x i8] c"S\00"
define i32 @readProgramAndCount() {
%1 = alloca [101 x i8]
%2 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %12, %0
%4 = phi i32 [ %14, %12 ], [ 1, %0 ]
br label %5
5: ; preds = %3, %9
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%7 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %5
%10 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %5, label %12
12: ; preds = %9
%13 = call i32 @readConditionBlockAndCount(i32 0, i32 0)
%14 = mul nsw i32 %13, %4
br label %3
15: ; preds = %5
ret i32 %4
}