#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 */
size_t strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, size_t);
int strutil_contains(char *string, char *sequence) {
  char *s = string;
  if (strlen(sequence) > strlen(string)) {
    return 0;
  }
  for (size_t i = 0; i < strlen(string); i++) {
    if (!strncmp(s, sequence, strlen(sequence))) {
      return 1;
    } else {
      s++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<strutil_contains>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jbe    116a <strutil_contains+0x4a>
movl   $0x0,-0x4(%rbp)
jmp    11fa <strutil_contains+0xda>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jae    11f3 <strutil_contains+0xd3>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11d1 <strutil_contains+0xb1>
movl   $0x1,-0x4(%rbp)
jmp    11fa <strutil_contains+0xda>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11e2 <strutil_contains+0xc2>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1172 <strutil_contains+0x52>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strutil_contains>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %rax,%r12
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,%r13
xor    %eax,%eax
cmp    %r13,%r12
ja     119e <strutil_contains+0x7e>
test   %r13,%r13
je     119e <strutil_contains+0x7e>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1199 <strutil_contains+0x79>
mov    $0x1,%ecx
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rbx
cmp    %rcx,%r13
je     118f <strutil_contains+0x6f>
lea    (%r15,%rbx,1),%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <strncmp@plt>
lea    0x1(%rbx),%rcx
test   %eax,%eax
jne    1170 <strutil_contains+0x50>
xor    %eax,%eax
cmp    %r13,%rbx
setb   %al
jmp    119e <strutil_contains+0x7e>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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