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


x86 assembly (clang, -O0):
<readConditionBlockAndCount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x1,-0x74(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xead(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1177 <readConditionBlockAndCount+0x47>
jmp    1148 <readConditionBlockAndCount+0x18>
cmpl   $0x0,-0x8(%rbp)
jne    11a0 <readConditionBlockAndCount+0x70>
lea    -0x70(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a0 <readConditionBlockAndCount+0x70>
jmp    11fc <readConditionBlockAndCount+0xcc>
cmpl   $0x1,-0x8(%rbp)
jne    11c9 <readConditionBlockAndCount+0x99>
lea    -0x70(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c9 <readConditionBlockAndCount+0x99>
jmp    11fc <readConditionBlockAndCount+0xcc>
lea    -0x70(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f7 <readConditionBlockAndCount+0xc7>
mov    -0x4(%rbp),%edi
add    $0x1,%edi
xor    %esi,%esi
call   1040 <readConditionBlockAndCount@plt>
imul   -0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
jmp    1148 <readConditionBlockAndCount+0x18>
lea    -0x70(%rbp),%rdi
lea    0xdfe(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    122c <readConditionBlockAndCount+0xfc>
mov    -0x4(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1040 <readConditionBlockAndCount@plt>
add    -0x74(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x74(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readConditionBlockAndCount>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %esi,%r12d
add    $0x1,%edi
mov    %edi,0xc(%rsp)
movl   $0x1,0x8(%rsp)
lea    0xea9(%rip),%r13
lea    0x10(%rsp),%rbp
lea    0xea0(%rip),%rbx
lea    0xea4(%rip),%r15
lea    0xe94(%rip),%r14
jmp    11a0 <readConditionBlockAndCount+0x70>
mov    %rbp,%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e6 <readConditionBlockAndCount+0xb6>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ce <readConditionBlockAndCount+0x9e>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a0 <readConditionBlockAndCount+0x70>
cmp    $0x1,%r12d
je     1173 <readConditionBlockAndCount+0x43>
test   %r12d,%r12d
jne    1187 <readConditionBlockAndCount+0x57>
mov    %rbp,%rdi
mov    %r14,%rsi
jmp    117d <readConditionBlockAndCount+0x4d>
mov    0xc(%rsp),%edi
xor    %esi,%esi
call   1040 <readConditionBlockAndCount@plt>
mov    0x8(%rsp),%ecx
imul   %eax,%ecx
mov    %ecx,0x8(%rsp)
jmp    11a0 <readConditionBlockAndCount+0x70>
lea    0xe18(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1202 <readConditionBlockAndCount+0xd2>
mov    0x8(%rsp),%eax
jmp    1218 <readConditionBlockAndCount+0xe8>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
call   1040 <readConditionBlockAndCount@plt>
mov    0x8(%rsp),%ecx
add    %eax,%ecx
mov    %ecx,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"S\00"
@.str.2 = [5 x i8] c"ELSE\00"
@.str.3 = [7 x i8] c"END_IF\00"
@.str.4 = [3 x i8] c"IF\00"
define i32 @readConditionBlockAndCount(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [101 x i8]
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 1, i32* %6
br label %7
7: ; preds = %2, %13, %40
%8 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %7
br label %7
14: ; preds = %7
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
br label %41
22: ; preds = %17, %14
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
br label %41
30: ; preds = %25, %22
%31 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
%37 = call i32 @readConditionBlockAndCount(i32 %36, i32 0)
%38 = load i32, i32* %6
%39 = mul nsw i32 %38, %37
store i32 %39, i32* %6
br label %40
40: ; preds = %34, %30
br label %7
41: ; preds = %29, %21
%42 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
%48 = call i32 @readConditionBlockAndCount(i32 %47, i32 1)
%49 = load i32, i32* %6
%50 = add nsw i32 %49, %48
store i32 %50, i32* %6
br label %51
51: ; preds = %45, %41
%52 = load i32, i32* %6
ret i32 %52
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"S\00"
@.str.2 = [5 x i8] c"ELSE\00"
@.str.3 = [7 x i8] c"END_IF\00"
@.str.4 = [3 x i8] c"IF\00"
define i32 @readConditionBlockAndCount(i32 %0, i32 %1) {
%3 = alloca [101 x i8]
%4 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%5 = add nsw i32 %0, 1
br label %6
6: ; preds = %23, %2
%7 = phi i32 [ %25, %23 ], [ 1, %2 ]
br label %8
8: ; preds = %6, %20
br label %9
9: ; preds = %8, %9
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%11 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %9, label %13
13: ; preds = %9
switch i32 %1, label %20 [
i32 0, label %14
i32 1, label %17
]
14: ; preds = %13
%15 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %26, label %20
17: ; preds = %13
%18 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %14, %13, %17
%21 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %8
23: ; preds = %20
%24 = call i32 @readConditionBlockAndCount(i32 %5, i32 0)
%25 = mul nsw i32 %24, %7
br label %6
26: ; preds = %17, %14
%27 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 @readConditionBlockAndCount(i32 %5, i32 1)
%31 = add nsw i32 %30, %7
br label %32
32: ; preds = %29, %26
%33 = phi i32 [ %31, %29 ], [ %7, %26 ]
ret i32 %33
}