#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*/ assert(char *);
unsigned int strings_length(char *);
bool strings_contains_string_imp(char *string, char *substring,
                                 bool (*equals_function)(char *, char *,
                                                         unsigned int)) {
  assert(string);
  assert(substring);
  unsigned int string_length = strings_length(string),
               substring_length = strings_length(substring);
  for (unsigned int k = 0; k < string_length - substring_length + 1; k++) {
    if (equals_function(&string[k], substring, substring_length)) {
      return true;
    }
  }
  return false;
}


x86 assembly (clang, -O0):
<strings_contains_string_imp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strings_length@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strings_length@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    -0x28(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jae    11b8 <strings_contains_string_imp+0x98>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
add    %rcx,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   *%rax
cmp    $0x0,%eax
je     11a5 <strings_contains_string_imp+0x85>
movl   $0x1,-0x4(%rbp)
jmp    11bf <strings_contains_string_imp+0x9f>
jmp    11aa <strings_contains_string_imp+0x8a>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1165 <strings_contains_string_imp+0x45>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strings_contains_string_imp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <assert@plt>
mov    %r15,%rdi
call   1040 <assert@plt>
mov    %r12,%rdi
call   1030 <strings_length@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1030 <strings_length@plt>
sub    %eax,%ebx
inc    %ebx
je     11a6 <strings_contains_string_imp+0x86>
mov    %eax,%ebp
mov    %r12,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   *%r14
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    11a8 <strings_contains_string_imp+0x88>
mov    %ebx,%r13d
mov    $0x1,%ecx
nopl   0x0(%rax)
mov    %rcx,%rbx
cmp    %rcx,%r13
je     119c <strings_contains_string_imp+0x7c>
lea    (%r12,%rbx,1),%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   *%r14
lea    0x1(%rbx),%rcx
test   %eax,%eax
je     1180 <strings_contains_string_imp+0x60>
xor    %eax,%eax
cmp    %r13,%rbx
setb   %al
jmp    11a8 <strings_contains_string_imp+0x88>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strings_contains_string_imp(i8* %0, i8* %1, i32 (i8*, i8*, i32)* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32 (i8*, i8*, i32)*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 (i8*, i8*, i32)* %2, i32 (i8*, i8*, i32)** %7
%11 = load i8*, i8** %5
%12 = call i32 @assert(i8* %11)
%13 = load i8*, i8** %6
%14 = call i32 @assert(i8* %13)
%15 = load i8*, i8** %5
%16 = call i32 @strings_length(i8* %15)
store i32 %16, i32* %8
%17 = load i8*, i8** %6
%18 = call i32 @strings_length(i8* %17)
store i32 %18, i32* %9
store i32 0, i32* %10
br label %19
19: ; preds = %38, %3
%20 = load i32, i32* %10
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = sub i32 %21, %22
%24 = add i32 %23, 1
%25 = icmp ult i32 %20, %24
br i1 %25, label %26, label %41
26: ; preds = %19
%27 = load i32 (i8*, i8*, i32)*, i32 (i8*, i8*, i32)** %7
%28 = load i8*, i8** %5
%29 = load i32, i32* %10
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8*, i8** %6
%33 = load i32, i32* %9
%34 = call i32 %27(i8* %31, i8* %32, i32 %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %26
store i32 1, i32* %4
br label %42
37: ; preds = %26
br label %38
38: ; preds = %37
%39 = load i32, i32* %10
%40 = add i32 %39, 1
store i32 %40, i32* %10
br label %19
41: ; preds = %19
store i32 0, i32* %4
br label %42
42: ; preds = %41, %36
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
define i32 @strings_contains_string_imp(i8* %0, i8* %1, i32 (i8*, i8*, i32)* nocapture %2) {
%4 = tail call i32 @assert(i8* %0)
%5 = tail call i32 @assert(i8* %1)
%6 = tail call i32 @strings_length(i8* %0)
%7 = tail call i32 @strings_length(i8* %1)
%8 = add i32 %6, 1
%9 = sub i32 %8, %7
%10 = icmp eq i32 %9, 0
br i1 %10, label %26, label %11
11: ; preds = %3
%12 = zext i32 %9 to i64
%13 = tail call i32 %2(i8* %0, i8* %1, i32 %7)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %11, %18
%16 = phi i64 [ %22, %18 ], [ 1, %11 ]
%17 = icmp eq i64 %16, %12
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = getelementptr inbounds i8, i8* %0, i64 %16
%20 = tail call i32 %2(i8* %19, i8* %1, i32 %7)
%21 = icmp eq i32 %20, 0
%22 = add nuw nsw i64 %16, 1
br i1 %21, label %15, label %23
23: ; preds = %15, %18
%24 = icmp ult i64 %16, %12
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %23, %11, %3
%27 = phi i32 [ 0, %3 ], [ 1, %11 ], [ %25, %23 ]
ret i32 %27
}