#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 */
struct trienode {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ addString(struct trienode *, char *);
struct trienode *getNode();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, ...);
int searchString(struct trienode *, char *);
scalar_t__ strcmp(char *, char *);
int main() {
  struct trienode *root = getNode();
  int n;
  scanf("%d", &n);
  while (n--) {
    char type[22];
    char str[22];
    scanf("%s", type);
    scanf("%s", str);
    if (strcmp("add", type) == 0) {
      addString(root, str);
    } else {
      int count = searchString(root, str);
      printf("%d\n", count);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <getNode@plt>
mov    %rax,-0x10(%rbp)
lea    0xe7f(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1214 <main+0xb4>
lea    -0x30(%rbp),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x50(%rbp),%rsi
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    -0x30(%rbp),%rsi
lea    0xe37(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f0 <main+0x90>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1030 <addString@plt>
jmp    120f <main+0xaf>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1060 <searchString@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%esi
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
jmp    118c <main+0x2c>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
xor    %eax,%eax
call   1080 <getNode@plt>
mov    %rax,%r14
lea    0xe81(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
subl   $0x1,0xc(%rsp)
jb     1212 <main+0xb2>
lea    0xe66(%rip),%r15
lea    0x30(%rsp),%r12
lea    0x10(%rsp),%rbx
lea    0xe58(%rip),%r13
lea    0xe55(%rip),%rbp
jmp    11d6 <main+0x76>
nopw   0x0(%rax,%rax,1)
call   1060 <searchString@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1212 <main+0xb2>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <strcmp@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
test   %rax,%rax
jne    11c0 <main+0x60>
call   1030 <addString@plt>
subl   $0x1,0xc(%rsp)
jae    11d6 <main+0x76>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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