#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*/ Getnext(char *, int *);
int KMP(char *, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char s[1000];
  char p[1000];
  int next[1000];
  int nRet = 0;
  int i;
  scanf("%s", s);
  scanf("%s", p);
  Getnext(p, next);
  nRet = KMP(s, p, next);
  if (nRet == -1) {
    printf("%s\n", "not found");
  } else {
    for (i = 0; i < strlen(s); i++) {
      if (nRet <= i && i < (nRet + strlen(p))) {
        printf("\033[0;32;31m"
               "%c"
               "\033[m",
               s[i]);
      } else {
        printf("%c", s[i]);
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x17a0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1784(%rbp)
lea    -0x3f0(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x7e0(%rbp),%rsi
lea    0xe73(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x7e0(%rbp),%rdi
lea    -0x1780(%rbp),%rsi
call   1050 <Getnext@plt>
lea    -0x3f0(%rbp),%rdi
lea    -0x7e0(%rbp),%rsi
lea    -0x1780(%rbp),%rdx
call   1060 <KMP@plt>
mov    %eax,-0x1784(%rbp)
cmpl   $0xffffffff,-0x1784(%rbp)
jne    11ec <main+0x9c>
lea    0xe2a(%rip),%rdi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d2 <main+0x182>
movl   $0x0,-0x1788(%rbp)
mov    -0x1788(%rbp),%eax
mov    %eax,-0x178c(%rbp)
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x178c(%rbp),%eax
cmp    %ecx,%eax
jge    12c4 <main+0x174>
mov    -0x1784(%rbp),%eax
cmp    -0x1788(%rbp),%eax
jg     128e <main+0x13e>
mov    -0x1788(%rbp),%eax
mov    %eax,-0x1790(%rbp)
mov    -0x1784(%rbp),%eax
mov    %eax,-0x1794(%rbp)
lea    -0x7e0(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x1794(%rbp),%ecx
mov    %eax,%edx
mov    -0x1790(%rbp),%eax
add    %edx,%ecx
cmp    %ecx,%eax
jge    128e <main+0x13e>
movslq -0x1788(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%esi
ff
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ab <main+0x15b>
movslq -0x1788(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%esi
ff
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b0 <main+0x160>
mov    -0x1788(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1788(%rbp)
jmp    11f6 <main+0xa6>
lea    0xd3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x17a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1788,%rsp
lea    0xe78(%rip),%r15
mov    %rsp,%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
lea    0x3f0(%rsp),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1090 <scanf@plt>
lea    0x7e0(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <Getnext@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1080 <KMP@plt>
cmp    $0xffffffff,%eax
je     124f <main+0xdf>
mov    %eax,%r13d
mov    %rsp,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1243 <main+0xd3>
movslq %r13d,%rbx
mov    %rsp,%r14
lea    0x3f0(%rsp),%r15
lea    0xe16(%rip),%r12
xor    %ebp,%ebp
jmp    121c <main+0xac>
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1243 <main+0xd3>
cmp    %rbx,%rbp
jl     1200 <main+0x90>
mov    %r15,%rdi
call   1050 <strlen@plt>
add    %r13d,%eax
cltq
cmp    %rax,%rbp
jge    1200 <main+0x90>
movsbl (%rsp,%rbp,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1209 <main+0x99>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    125b <main+0xeb>
lea    0xdad(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x1788,%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 = [4 x i8] c"%s\0A\00"
@.str.2 = [10 x i8] c"not found\00"
@.str.3 = [16 x i8] c"\1B[0;32;31m%c\1B[m\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 0
%13 = call i32 @Getnext(i8* %11, i32* %12)
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%16 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 0
%17 = call i32 @KMP(i8* %14, i8* %15, i32* %16)
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %59
22: ; preds = %0
store i32 0, i32* %6
br label %23
23: ; preds = %54, %22
%24 = load i32, i32* %6
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = icmp slt i32 %24, %26
br i1 %27, label %28, label %57
28: ; preds = %23
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %46
32: ; preds = %28
%33 = load i32, i32* %6
%34 = load i32, i32* %5
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
%37 = add nsw i32 %34, %36
%38 = icmp slt i32 %33, %37
br i1 %38, label %39, label %46
39: ; preds = %32
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %44)
br label %53
46: ; preds = %32, %28
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %46, %39
br label %54
54: ; preds = %53
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %23
57: ; preds = %23
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %59
59: ; preds = %57, %20
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.2 = [10 x i8] c"not found\00"
@.str.3 = [16 x i8] c"\1B[0;32;31m%c\1B[m\00"
define i32 @main() {
%1 = alloca [1000 x i8]
%2 = alloca [1000 x i8]
%3 = alloca [1000 x i32]
%4 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %2, i64 0, i64 0
%6 = bitcast [1000 x i32]* %3 to i8*
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%9 = getelementptr inbounds [1000 x i32], [1000 x i32]* %3, i64 0, i64 0
%10 = call i32 @Getnext(i8* %5, i32* %9)
%11 = call i32 @KMP(i8* %4, i8* %5, i32* %9)
%12 = icmp eq i32 %11, -1
br i1 %12, label %18, label %13
13: ; preds = %0
%14 = call i32 @strlen(i8* %4)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %43
16: ; preds = %13
%17 = sext i32 %11 to i64
br label %20
18: ; preds = %0
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %45
20: ; preds = %16, %38
%21 = phi i64 [ 0, %16 ], [ %39, %38 ]
%22 = icmp slt i64 %21, %17
br i1 %22, label %33, label %23
23: ; preds = %20
%24 = call i32 @strlen(i8* %5)
%25 = add nsw i32 %24, %11
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %21, %26
br i1 %27, label %28, label %33
28: ; preds = %23
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %21
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %38
33: ; preds = %23, %20
%34 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %21
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = call i32 @putchar(i32 %36)
br label %38
38: ; preds = %28, %33
%39 = add nuw nsw i64 %21, 1
%40 = call i32 @strlen(i8* %4)
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
br i1 %42, label %20, label %43
43: ; preds = %38, %13
%44 = call i32 @putchar(i32 10)
br label %45
45: ; preds = %43, %18
ret i32 0
}