#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*/ KMP(char *, char *);
int /*<<< orphan*/ naive_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ naive_scanf(char *, ...);
int program_main() {
  static char s1[10000 + 1], s2[1000000 + 1];
  int T;
  naive_scanf("%d", &T);
  while (T--) {
    naive_scanf("%s%s", s1, s2);
    naive_printf("%d\n", KMP(s1, s2));
  }
  return 0;
}


x86 assembly (clang, -O0):
<program_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1030 <naive_scanf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
je     11a0 <program_main+0x70>
lea    0xe9e(%rip),%rdi
lea    0x2ee4(%rip),%rsi
lea    0x55fd(%rip),%rdx
mov    $0x0,%al
call   1030 <naive_scanf@plt>
lea    0x2ecf(%rip),%rdi
lea    0x55e8(%rip),%rsi
call   1050 <KMP@plt>
mov    %eax,%esi
lea    0xe72(%rip),%rdi
call   1040 <naive_printf@plt>
jmp    114a <program_main+0x1a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<program_main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1030 <naive_scanf@plt>
subl   $0x1,0x4(%rsp)
jb     119c <program_main+0x6c>
lea    0xeaa(%rip),%r14
lea    0x2ef0(%rip),%r15
lea    0x5609(%rip),%rbx
lea    0xe9a(%rip),%r12
xchg   %ax,%ax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <naive_scanf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <KMP@plt>
mov    %r12,%rdi
mov    %eax,%esi
call   1040 <naive_printf@plt>
subl   $0x1,0x4(%rsp)
jae    1170 <program_main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@program_main.s1 = internal global [10001 x i8] zeroinitializer
@program_main.s2 = internal global [1000001 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @program_main() {
%1 = alloca i32
%2 = call i32 (i8*, ...) @naive_scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
br label %3
3: ; preds = %7, %0
%4 = load i32, i32* %1
%5 = add nsw i32 %4, -1
store i32 %5, i32* %1
%6 = icmp ne i32 %4, 0
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = call i32 (i8*, ...) @naive_scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10001 x i8], [10001 x i8]* @program_main.s1, i64 0, i64 0), i8* getelementptr inbounds ([1000001 x i8], [1000001 x i8]* @program_main.s2, i64 0, i64 0))
%9 = call i32 @KMP(i8* getelementptr inbounds ([10001 x i8], [10001 x i8]* @program_main.s1, i64 0, i64 0), i8* getelementptr inbounds ([1000001 x i8], [1000001 x i8]* @program_main.s2, i64 0, i64 0))
%10 = call i32 @naive_printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %3
11: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@program_main.s1 = internal global [10001 x i8] zeroinitializer
@program_main.s2 = internal global [1000001 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @program_main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i8*, ...) @naive_scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = add nsw i32 %4, -1
store i32 %5, i32* %1
%6 = icmp eq i32 %4, 0
br i1 %6, label %14, label %7
7: ; preds = %0, %7
%8 = call i32 (i8*, ...) @naive_scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10001 x i8], [10001 x i8]* @program_main.s1, i64 0, i64 0), i8* getelementptr inbounds ([1000001 x i8], [1000001 x i8]* @program_main.s2, i64 0, i64 0))
%9 = call i32 @KMP(i8* getelementptr inbounds ([10001 x i8], [10001 x i8]* @program_main.s1, i64 0, i64 0), i8* getelementptr inbounds ([1000001 x i8], [1000001 x i8]* @program_main.s2, i64 0, i64 0))
%10 = call i32 @naive_printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %1
%12 = add nsw i32 %11, -1
store i32 %12, i32* %1
%13 = icmp eq i32 %11, 0
br i1 %13, label %14, label %7
14: ; preds = %7, %0
ret i32 0
}