#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 */
typedef int /*<<< orphan*/ in;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcmp(char *, char *);
char *strtok(char *, char *);
int main() {
  char in[50];
  fgets(in, sizeof(in), stdin);
  char *tok = " ";
  char tar[10];
  scanf("%s", tar);
  int cnt = 0;
  char *part = strtok(in, tok);
  if (!strcmp(part, tar)) {
    cnt++;
  }
  while (part != NULL) {
    if (!strcmp(part, tar)) {
      cnt++;
    }
    part = strtok(NULL, tok);
  }
  printf("%d %s\n", cnt, tar);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
mov    0x2e7e(%rip),%rax
mov    (%rax),%edx
mov    $0x32,%esi
call   1040 <fgets@plt>
lea    0xe83(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x52(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0x58(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
lea    -0x52(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11c8 <main+0x78>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11cd <main+0x7d>
cmpq   $0x0,-0x60(%rbp)
je     120d <main+0xbd>
mov    -0x60(%rbp),%rdi
lea    -0x52(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11f7 <main+0xa7>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x48(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1070 <strtok@plt>
mov    %rax,-0x60(%rbp)
jmp    11cd <main+0x7d>
mov    -0x58(%rbp),%esi
lea    -0x52(%rbp),%rdx
lea    0xdea(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x32,%esi
call   1040 <fgets@plt>
lea    0xe86(%rip),%rdi
lea    0x6(%rsp),%rbp
mov    %rbp,%rsi
call   1060 <scanf@plt>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strtok@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1050 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
test   %rbx,%rbx
je     11e3 <main+0x93>
lea    0x6(%rsp),%r14
lea    0xe41(%rip),%r15
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
cmp    $0x1,%eax
adc    $0x0,%ebp
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11c0 <main+0x70>
lea    0xe1b(%rip),%rdi
lea    0x6(%rsp),%rdx
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [7 x i8] c"%d %s\0A\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %3, i32 50, i32 %4)
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @strcmp(i8* dereferenceable(1) %8, i8* %6)
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = icmp eq i8* %8, null
br i1 %12, label %22, label %13
13: ; preds = %0, %13
%14 = phi i8* [ %20, %13 ], [ %8, %0 ]
%15 = phi i32 [ %19, %13 ], [ %11, %0 ]
%16 = call i32 @strcmp(i8* %14, i8* %6)
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %15, %18
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %13
22: ; preds = %13, %0
%23 = phi i32 [ %11, %0 ], [ %19, %13 ]
%24 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %23, i8* %6)
ret i32 0
}