#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
char *strstr(char *, char *);
int main() {
  int n, start, len;
  char s[5001], search[5001];
  scanf("%d", &n);
  scanf("%s", s);
  printf("%d, %s\n", n, s);
  for (start = 0; start < n; start++) {
    for (len = 0; start + len < n; len++)
      printf("%s\n", strstr(&s[start + len], &s[start]));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2730,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    -0x13a0(%rbp),%rsi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%esi
lea    -0x13a0(%rbp),%rdx
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1201 <main+0xd1>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ee <main+0xbe>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
cltq
lea    -0x13a0(%rbp),%rdi
add    %rax,%rdi
movslq -0xc(%rbp),%rax
lea    -0x13a0(%rbp),%rsi
add    %rax,%rsi
call   1050 <strstr@plt>
mov    %rax,%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119b <main+0x6b>
jmp    11f3 <main+0xc3>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1188 <main+0x58>
mov    -0x4(%rbp),%eax
add    $0x2730,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x13a0,%rsp
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xe9d(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0xe86(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11e9 <main+0xa9>
xor    %r14d,%r14d
jmp    11a9 <main+0x69>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %rcx,%r14
jge    11e9 <main+0xa9>
movslq %eax,%rcx
cmp    %rcx,%r14
jge    11a0 <main+0x60>
lea    (%rsp,%r14,1),%r15
add    $0x10,%r15
mov    %r14,%rbx
nopl   0x0(%rax)
lea    (%rsp,%rbx,1),%rdi
add    $0x10,%rdi
mov    %r15,%rsi
call   1060 <strstr@plt>
mov    %rax,%rdi
call   1030 <puts@plt>
add    $0x1,%rbx
mov    0xc(%rsp),%eax
cmp    %ebx,%eax
jg     11c0 <main+0x80>
movslq %eax,%rcx
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x13a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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