#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*/ freopen(char *, char *, int /*<<< orphan*/);
scalar_t__ mystrcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(int argc, char *argv[]) {
  char T[1000000], P[1000000];
  int total, i, tlen, plen;
  freopen("input.txt", "r", stdin);
  while (scanf("%s %s", T, P) != EOF) {
    printf("%s %s\n", T, P);
    tlen = strlen(T);
    plen = strlen(P);
    total = 0;
    for (i = 0; i <= (tlen - plen); i++) {
      if (mystrcmp(T + i, P, plen) == 0) {
        total++;
      }
    }
    printf("%d\n", total);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e84a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%edx
lea    0xe87(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1060 <freopen@plt>
lea    -0xf4250(%rbp),%rsi
lea    -0x1e8490(%rbp),%rdx
lea    0xe72(%rip),%rdi
call   1070 <scanf@plt>
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%rax
je     128b <main+0x13b>
lea    -0xf4250(%rbp),%rsi
lea    -0x1e8490(%rbp),%rdx
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0xf4250(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1e849c(%rbp)
lea    -0x1e8490(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1e84a0(%rbp)
movl   $0x0,-0x1e8494(%rbp)
movl   $0x0,-0x1e8498(%rbp)
mov    -0x1e8498(%rbp),%eax
mov    -0x1e849c(%rbp),%ecx
sub    -0x1e84a0(%rbp),%ecx
cmp    %ecx,%eax
jg     1272 <main+0x122>
lea    -0xf4250(%rbp),%rdi
movslq -0x1e8498(%rbp),%rax
add    %rax,%rdi
lea    -0x1e8490(%rbp),%rsi
mov    -0x1e84a0(%rbp),%edx
call   1030 <mystrcmp@plt>
cmp    $0x0,%rax
jne    1259 <main+0x109>
mov    -0x1e8494(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1e8494(%rbp)
jmp    125e <main+0x10e>
mov    -0x1e8498(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1e8498(%rbp)
jmp    1203 <main+0xb3>
mov    -0x1e8494(%rbp),%esi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1185 <main+0x35>
xor    %eax,%eax
add    $0x1e84a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1e8488,%rsp
mov    0x2e80(%rip),%rax
mov    (%rax),%edx
lea    0xe8f(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1060 <freopen@plt>
lea    0xe88(%rip),%rdi
lea    0xf4240(%rsp),%r13
mov    %rsp,%rdx
mov    %r13,%rsi
call   1070 <scanf@plt>
mov    0x2e42(%rip),%rcx
cmp    (%rcx),%rax
jne    11b7 <main+0x67>
xor    %eax,%eax
add    $0x1e8488,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rbx
jmp    11ef <main+0x9f>
nopl   0x0(%rax)
lea    0xe52(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe34(%rip),%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1070 <scanf@plt>
mov    0x2df6(%rip),%rcx
cmp    (%rcx),%rax
je     11a3 <main+0x53>
lea    0xe1c(%rip),%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x0,%r12d
sub    %eax,%ebp
jl     11c0 <main+0x70>
mov    %eax,%r14d
add    $0x1,%ebp
xor    %r12d,%r12d
mov    %r13,%r15
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <mystrcmp@plt>
cmp    $0x1,%rax
adc    $0x0,%r12d
add    $0x1,%r15
add    $0xffffffffffffffff,%rbp
jne    1230 <main+0xe0>
jmp    11c0 <main+0x70>

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [6 x i8] c"%s %s\00"
@EOF = global i64 0
@.str.3 = [7 x i8] c"%s %s\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000000 x i8]
%7 = alloca [1000000 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @stdin
%13 = call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %50, %2
%15 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %7, i64 0, i64 0
%17 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* %16)
%18 = load i64, i64* @EOF
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %53
20: ; preds = %14
%21 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %6, i64 0, i64 0
%22 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %7, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %21, i8* %22)
%24 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %6, i64 0, i64 0
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %10
%26 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %7, i64 0, i64 0
%27 = call i32 @strlen(i8* %26)
store i32 %27, i32* %11
store i32 0, i32* %8
store i32 0, i32* %9
br label %28
28: ; preds = %47, %20
%29 = load i32, i32* %9
%30 = load i32, i32* %10
%31 = load i32, i32* %11
%32 = sub nsw i32 %30, %31
%33 = icmp sle i32 %29, %32
br i1 %33, label %34, label %50
34: ; preds = %28
%35 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %6, i64 0, i64 0
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %7, i64 0, i64 0
%40 = load i32, i32* %11
%41 = call i64 @mystrcmp(i8* %38, i8* %39, i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %34
%44 = load i32, i32* %8
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
br label %46
46: ; preds = %43, %34
br label %47
47: ; preds = %46
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %28
50: ; preds = %28
%51 = load i32, i32* %8
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %51)
br label %14
53: ; preds = %14
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [6 x i8] c"%s %s\00"
@EOF = global i64 0
@.str.3 = [7 x i8] c"%s %s\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000000 x i8]
%4 = alloca [1000000 x i8]
%5 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = tail call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %6)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %37, label %12
12: ; preds = %2, %31
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %5, i8* %6)
%14 = call i32 @strlen(i8* %5)
%15 = call i32 @strlen(i8* %6)
%16 = icmp slt i32 %14, %15
br i1 %16, label %31, label %17
17: ; preds = %12
%18 = add i32 %14, 1
%19 = sub i32 %18, %15
%20 = zext i32 %19 to i64
br label %21
21: ; preds = %17, %21
%22 = phi i64 [ 0, %17 ], [ %29, %21 ]
%23 = phi i32 [ 0, %17 ], [ %28, %21 ]
%24 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %3, i64 0, i64 %22
%25 = call i64 @mystrcmp(i8* %24, i8* %6, i32 %15)
%26 = icmp eq i64 %25, 0
%27 = zext i1 %26 to i32
%28 = add nuw nsw i32 %23, %27
%29 = add nuw nsw i64 %22, 1
%30 = icmp eq i64 %29, %20
br i1 %30, label %31, label %21
31: ; preds = %21, %12
%32 = phi i32 [ 0, %12 ], [ %28, %21 ]
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %32)
%34 = call i64 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %6)
%35 = load i64, i64* @EOF
%36 = icmp eq i64 %34, %35
br i1 %36, label %37, label %12
37: ; preds = %31, %2
ret i32 0
}