#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 int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ KMP(char *, size_t, char *, size_t);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int main(void) {
  size_t a = 0, b = 0;
  char *pattern = NULL, *text = NULL;
  ssize_t p_len = 0, t_len = 0;
  while ((p_len = getline(&pattern, &a, stdin)) >= 0 &&
         (t_len = getline(&text, &b, stdin)) >= 0) {
    KMP(pattern, (size_t)(p_len - 1), text, (size_t)(t_len - 1));
    free(pattern);
    free(text);
    a = 0;
    b = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    0x2e74(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,%ecx
mov    %ecx,-0x2c(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x31(%rbp)
jl     11b8 <main+0x88>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
lea    -0x28(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
setge  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11c8 <main+0x98>
jmp    120e <main+0xde>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
call   1040 <KMP@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
jmp    116d <main+0x3d>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x18(%rsp)
movq   $0x0,0x20(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e7f(%rip),%rbx
mov    (%rbx),%edx
lea    0x8(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1050 <getline@plt>
test   %eax,%eax
js     1205 <main+0xd5>
mov    %eax,%ebp
lea    0x10(%rsp),%r14
lea    0x20(%rsp),%r13
lea    0x8(%rsp),%r15
lea    0x18(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%edx
mov    %r14,%rdi
mov    %r13,%rsi
call   1050 <getline@plt>
test   %eax,%eax
js     1205 <main+0xd5>
mov    0x8(%rsp),%rdi
add    $0xffffffff,%ebp
movslq %ebp,%rsi
mov    0x10(%rsp),%rdx
add    $0xffffffff,%eax
movslq %eax,%rcx
call   1040 <KMP@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
movq   $0x0,0x18(%rsp)
movq   $0x0,0x20(%rsp)
mov    (%rbx),%edx
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <getline@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    11a0 <main+0x70>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
store i8* null, i8** %4
store i8* null, i8** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %4, i64* %2, i32 %9)
store i32 %10, i32* %6
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* @stdin
%14 = call i32 @getline(i8** %5, i64* %3, i32 %13)
store i32 %14, i32* %7
%15 = icmp sge i32 %14, 0
br label %16
16: ; preds = %12, %8
%17 = phi i1 [ false, %8 ], [ %15, %12 ]
br i1 %17, label %18, label %32
18: ; preds = %16
%19 = load i8*, i8** %4
%20 = load i32, i32* %6
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = load i8*, i8** %5
%24 = load i32, i32* %7
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = call i32 @KMP(i8* %19, i64 %22, i8* %23, i64 %26)
%28 = load i8*, i8** %4
%29 = call i32 @free(i8* %28)
%30 = load i8*, i8** %5
%31 = call i32 @free(i8* %30)
store i64 0, i64* %2
store i64 0, i64* %3
br label %8
32: ; preds = %16
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%6 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%7 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%8 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %3, i64* %1, i32 %9)
%11 = icmp sgt i32 %10, -1
br i1 %11, label %12, label %32
12: ; preds = %0, %17
%13 = phi i32 [ %30, %17 ], [ %10, %0 ]
%14 = load i32, i32* @stdin
%15 = call i32 @getline(i8** %4, i64* %2, i32 %14)
%16 = icmp sgt i32 %15, -1
br i1 %16, label %17, label %32
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = add nsw i32 %13, -1
%20 = sext i32 %19 to i64
%21 = load i8*, i8** %4
%22 = add nsw i32 %15, -1
%23 = sext i32 %22 to i64
%24 = call i32 @KMP(i8* %18, i64 %20, i8* %21, i64 %23)
%25 = load i8*, i8** %3
%26 = call i32 @free(i8* %25)
%27 = load i8*, i8** %4
%28 = call i32 @free(i8* %27)
store i64 0, i64* %1
store i64 0, i64* %2
%29 = load i32, i32* @stdin
%30 = call i32 @getline(i8** %3, i64* %1, i32 %29)
%31 = icmp sgt i32 %30, -1
br i1 %31, label %12, label %32
32: ; preds = %12, %17, %0
ret i32 0
}