#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 scalar_t__ uint8_t;

/* Variables and functions */
scalar_t__ *boyer_moore(char *, int, char *, int);
int /*<<< orphan*/ intervalize(char *, int, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, ...);
int strlen(char *);
int main(int argc, char **argv) {
  int rc, i;
  int N;
  int M;
  if ((rc = scanf("%d %d", &N, &M)) != 2) {
    return (1);
  }
  while ((N != 0) && (M != 0)) {
    char song[N];
    char snippet[M];
    if ((rc = scanf("%s", song)) != 1) {
      printf("rc = %d\n", rc);
      return (1);
    }
    if ((rc = scanf("%s", snippet)) != 1) {
      return (1);
    }
    char text[N - 1];
    char pattern[M - 1];
    int song_len = strlen(song);
    int snippet_len = strlen(snippet);
    intervalize(song, song_len, text, N - 1);
    intervalize(snippet, snippet_len, pattern, M - 1);
    uint8_t *match = boyer_moore(text, N - 1, pattern, M - 1);
    if ((match == NULL) || (*match == 0)) {
      printf("N\n");
    } else {
      printf("S\n");
    }
    if ((rc = scanf("%d %d", &N, &M)) != 2) {
      return (1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x2,%eax
je     1197 <main+0x47>
movl   $0x1,-0x4(%rbp)
jmp    13c5 <main+0x275>
jmp    119c <main+0x4c>
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x61(%rbp)
je     11b5 <main+0x65>
cmpl   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0x61(%rbp)
mov    -0x61(%rbp),%al
test   $0x1,%al
jne    11c5 <main+0x75>
jmp    13be <main+0x26e>
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x78(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x1,%eax
je     1248 <main+0xf8>
mov    -0x14(%rbp),%esi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    139d <main+0x24d>
mov    -0x70(%rbp),%rsi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x1,%eax
je     1279 <main+0x129>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    139d <main+0x24d>
mov    -0x78(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
call   1040 <strlen@plt>
mov    -0x70(%rbp),%rdi
mov    %eax,-0x54(%rbp)
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rdi
mov    -0x88(%rbp),%rdx
mov    %eax,-0x58(%rbp)
mov    -0x54(%rbp),%esi
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
call   1030 <intervalize@plt>
mov    -0x70(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    -0x58(%rbp),%esi
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
call   1030 <intervalize@plt>
mov    -0x88(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    -0x1c(%rbp),%esi
sub    $0x1,%esi
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
call   1070 <boyer_moore@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     1340 <main+0x1f0>
mov    -0x60(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1353 <main+0x203>
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1361 <main+0x211>
lea    0xcbb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc98(%rip),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x2,%eax
je     1396 <main+0x246>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    139d <main+0x24d>
movl   $0x0,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x3c(%rbp),%eax
test   %eax,%eax
je     13b9 <main+0x269>
jmp    13b4 <main+0x264>
jmp    13c5 <main+0x275>
jmp    119c <main+0x4c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe88(%rip),%rdi
xor    %ebx,%ebx
lea    -0x30(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    1303 <main+0x1a3>
mov    -0x30(%rbp),%eax
test   %eax,%eax
je     1308 <main+0x1a8>
cmpl   $0x0,-0x2c(%rbp)
je     1308 <main+0x1a8>
lea    0xe58(%rip),%r15
xchg   %ax,%ax
mov    %rsp,%r12
mov    %eax,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    12f0 <main+0x190>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    1300 <main+0x1a0>
mov    %r12,-0x40(%rbp)
mov    -0x30(%rbp),%eax
add    $0xffffffff,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %rsp,%r12
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r13d
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
call   1030 <intervalize@plt>
mov    -0x2c(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %r14,%rdi
mov    -0x34(%rbp),%esi
mov    %r12,%rdx
call   1030 <intervalize@plt>
mov    -0x30(%rbp),%esi
add    $0xffffffff,%esi
mov    -0x2c(%rbp),%ecx
add    $0xffffffff,%ecx
mov    %r15,%rdi
mov    %r12,%rdx
call   1080 <boyer_moore@plt>
lea    0xd80(%rip),%rdi
test   %rax,%rax
je     12ad <main+0x14d>
cmpq   $0x0,(%rax)
lea    0xd70(%rip),%rdi
je     12ad <main+0x14d>
lea    0xd65(%rip),%rdi
call   1040 <puts@plt>
lea    0xd47(%rip),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
cmp    $0x2,%eax
lea    0xd34(%rip),%r15
mov    -0x40(%rbp),%r12
jne    1300 <main+0x1a0>
mov    %r12,%rsp
mov    -0x30(%rbp),%eax
xor    %ebx,%ebx
test   %eax,%eax
je     1308 <main+0x1a8>
cmpl   $0x0,-0x2c(%rbp)
jne    11b0 <main+0x50>
jmp    1308 <main+0x1a8>
lea    0xd12(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rsp
mov    $0x1,%ebx
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [9 x i8] c"rc = %d\0A\00"
@.str.3 = [3 x i8] c"N\0A\00"
@.str.4 = [3 x i8] c"S\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i64*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %8, i32* %9)
store i32 %19, i32* %6
%20 = icmp ne i32 %19, 2
br i1 %20, label %21, label %22
21: ; preds = %2
store i32 1, i32* %3
br label %92
22: ; preds = %2
br label %23
23: ; preds = %90, %22
%24 = load i32, i32* %8
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %9
%28 = icmp ne i32 %27, 0
br label %29
29: ; preds = %26, %23
%30 = phi i1 [ false, %23 ], [ %28, %26 ]
br i1 %30, label %31, label %91
31: ; preds = %29
%32 = load i32, i32* %8
%33 = zext i32 %32 to i64
%34 = call i8* @llvm.stacksave()
store i8* %34, i8** %10
%35 = alloca i8, i64 %33
store i64 %33, i64* %11
%36 = load i32, i32* %9
%37 = zext i32 %36 to i64
%38 = alloca i8, i64 %37
store i64 %37, i64* %12
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %35)
store i32 %39, i32* %6
%40 = icmp ne i32 %39, 1
br i1 %40, label %41, label %44
41: ; preds = %31
%42 = load i32, i32* %6
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %42)
store i32 1, i32* %3
store i32 1, i32* %13
br label %87
44: ; preds = %31
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %38)
store i32 %45, i32* %6
%46 = icmp ne i32 %45, 1
br i1 %46, label %47, label %48
47: ; preds = %44
store i32 1, i32* %3
store i32 1, i32* %13
br label %87
48: ; preds = %44
%49 = load i32, i32* %8
%50 = sub nsw i32 %49, 1
%51 = zext i32 %50 to i64
%52 = alloca i8, i64 %51
store i64 %51, i64* %14
%53 = load i32, i32* %9
%54 = sub nsw i32 %53, 1
%55 = zext i32 %54 to i64
%56 = alloca i8, i64 %55
store i64 %55, i64* %15
%57 = call i32 @strlen(i8* %35)
store i32 %57, i32* %16
%58 = call i32 @strlen(i8* %38)
store i32 %58, i32* %17
%59 = load i32, i32* %16
%60 = load i32, i32* %8
%61 = sub nsw i32 %60, 1
%62 = call i32 @intervalize(i8* %35, i32 %59, i8* %52, i32 %61)
%63 = load i32, i32* %17
%64 = load i32, i32* %9
%65 = sub nsw i32 %64, 1
%66 = call i32 @intervalize(i8* %38, i32 %63, i8* %56, i32 %65)
%67 = load i32, i32* %8
%68 = sub nsw i32 %67, 1
%69 = load i32, i32* %9
%70 = sub nsw i32 %69, 1
%71 = call i64* @boyer_moore(i8* %52, i32 %68, i8* %56, i32 %70)
store i64* %71, i64** %18
%72 = load i64*, i64** %18
%73 = icmp eq i64* %72, null
br i1 %73, label %78, label %74
74: ; preds = %48
%75 = load i64*, i64** %18
%76 = load i64, i64* %75
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %74, %48
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %82
80: ; preds = %74
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %82
82: ; preds = %80, %78
%83 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %8, i32* %9)
store i32 %83, i32* %6
%84 = icmp ne i32 %83, 2
br i1 %84, label %85, label %86
85: ; preds = %82
store i32 1, i32* %3
store i32 1, i32* %13
br label %87
86: ; preds = %82
store i32 0, i32* %13
br label %87
87: ; preds = %86, %85, %47, %41
%88 = load i8*, i8** %10
%89 = load i32, i32* %13
switch i32 %89, label %94 [
i32 0, label %90
i32 1, label %92
]
90: ; preds = %87
br label %23
91: ; preds = %29
store i32 0, i32* %3
br label %92
92: ; preds = %91, %87, %21
%93 = load i32, i32* %3
ret i32 %93
94: ; preds = %87
unreachable
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [9 x i8] c"rc = %d\0A\00"
@str = [2 x i8] c"S\00"
@str.5 = [2 x i8] c"N\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %69
9: ; preds = %2
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %69
15: ; preds = %9, %63
%16 = phi i32 [ %64, %63 ], [ %10, %9 ]
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
%19 = alloca i8, i64 %17
%20 = load i32, i32* %4
%21 = zext i32 %20 to i64
%22 = alloca i8, i64 %21
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%24 = icmp eq i32 %23, 1
br i1 %24, label %27, label %25
25: ; preds = %15
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %62
27: ; preds = %15
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %62
30: ; preds = %27
%31 = load i32, i32* %3
%32 = add nsw i32 %31, -1
%33 = zext i32 %32 to i64
%34 = alloca i8, i64 %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, -1
%37 = zext i32 %36 to i64
%38 = alloca i8, i64 %37
%39 = call i32 @strlen(i8* %19)
%40 = call i32 @strlen(i8* %22)
%41 = load i32, i32* %3
%42 = add nsw i32 %41, -1
%43 = call i32 @intervalize(i8* %19, i32 %39, i8* %34, i32 %42)
%44 = load i32, i32* %4
%45 = add nsw i32 %44, -1
%46 = call i32 @intervalize(i8* %22, i32 %40, i8* %38, i32 %45)
%47 = load i32, i32* %3
%48 = add nsw i32 %47, -1
%49 = load i32, i32* %4
%50 = add nsw i32 %49, -1
%51 = call i64* @boyer_moore(i8* %34, i32 %48, i8* %38, i32 %50)
%52 = icmp eq i64* %51, null
br i1 %52, label %57, label %53
53: ; preds = %30
%54 = load i64, i64* %51
%55 = icmp eq i64 %54, 0
%56 = select i1 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0)
br label %57
57: ; preds = %53, %30
%58 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0), %30 ], [ %56, %53 ]
%59 = call i32 @puts(i8* dereferenceable(1) %58)
%60 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %4)
%61 = icmp eq i32 %60, 2
br i1 %61, label %63, label %62
62: ; preds = %57, %27, %25
br label %69
63: ; preds = %57
%64 = load i32, i32* %3
%65 = icmp ne i32 %64, 0
%66 = load i32, i32* %4
%67 = icmp ne i32 %66, 0
%68 = select i1 %65, i1 %67, i1 false
br i1 %68, label %15, label %69
69: ; preds = %63, %9, %62, %2
%70 = phi i32 [ 1, %2 ], [ 1, %62 ], [ 0, %9 ], [ 0, %63 ]
ret i32 %70
}