#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 kmpHledej(char *, char *, int *);
int /*<<< orphan*/ kmpVektor(char *, int *);
int strlen(char *);
int kmp(char *text, char *vzor) {
  if (strlen(vzor) == 0)
    return 0;
  int dVzoru = strlen(vzor);
  int vektor[dVzoru];
  kmpVektor(vzor, vektor);
  return kmpHledej(text, vzor, vektor);
}


x86 assembly (clang, -O0):
<kmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    115e <kmp+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <kmp+0x85>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x38(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <kmpVektor@plt>
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <kmpHledej@plt>
mov    %eax,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kmp>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     118d <kmp+0x5d>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rsp,%r12
mov    %eax,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <kmpVektor@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <kmpHledej@plt>
mov    %r12,%rsp
jmp    118f <kmp+0x5f>
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @kmp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 0, i32* %3
br label %26
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %7
%19 = alloca i32, i64 %17
store i64 %17, i64* %8
%20 = load i8*, i8** %5
%21 = call i32 @kmpVektor(i8* %20, i32* %19)
%22 = load i8*, i8** %4
%23 = load i8*, i8** %5
%24 = call i32 @kmpHledej(i8* %22, i8* %23, i32* %19)
store i32 %24, i32* %3
%25 = load i8*, i8** %7
br label %26
26: ; preds = %13, %12
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @kmp(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2
%6 = tail call i32 @strlen(i8* %1)
%7 = zext i32 %6 to i64
%8 = tail call i8* @llvm.stacksave()
%9 = alloca i32, i64 %7
%10 = call i32 @kmpVektor(i8* %1, i32* %9)
%11 = call i32 @kmpHledej(i8* %0, i8* %1, i32* %9)
br label %12
12: ; preds = %2, %5
%13 = phi i32 [ %11, %5 ], [ 0, %2 ]
ret i32 %13
}