#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 strlen(char *);
scalar_t__ strncasecmp(char *, char *, int);
int String_contains_i(char *s, char *match) {
  int lens = strlen(s);
  int lenmatch = strlen(match);
  for (int i = 0; i < lens - lenmatch; i++) {
    if (strncasecmp(s, match, strlen(match)) == 0)
      return 1;
    s++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<String_contains_i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    11b8 <String_contains_i+0x98>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    119e <String_contains_i+0x7e>
movl   $0x1,-0x4(%rbp)
jmp    11bf <String_contains_i+0x9f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114f <String_contains_i+0x2f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<String_contains_i>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %r13,%rdi
call   1030 <strlen@plt>
sub    %eax,%r15d
test   %r15d,%r15d
jle    11a4 <String_contains_i+0x84>
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     11a8 <String_contains_i+0x88>
mov    %r15d,%r12d
mov    $0x1,%ecx
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rbx
cmp    %ebx,%r12d
je     119a <String_contains_i+0x7a>
lea    (%r14,%rbx,1),%rbp
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <strncasecmp@plt>
lea    0x1(%rbx),%rcx
test   %rax,%rax
jne    1170 <String_contains_i+0x50>
xor    %eax,%eax
cmp    %r15d,%ebx
setl   %al
jmp    11ad <String_contains_i+0x8d>
xor    %eax,%eax
jmp    11ad <String_contains_i+0x8d>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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