#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 */
scalar_t__ strlen(char *);
scalar_t__ strncasecmp(char *, char *, scalar_t__);
int search_in_string(char *search_here, char *search_this) {
  int i = 0;
  for (i = 0; strlen(search_here) - strlen(search_this); i++) {
    if (strncasecmp(search_here, search_this, strlen(search_this)) == 0)
      return 1;
    search_here++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<search_in_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
cmp    $0x0,%rax
je     11c1 <search_in_string+0xa1>
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    %rax,%rdx
call   1040 <strncasecmp@plt>
cmp    $0x0,%rax
jne    11a7 <search_in_string+0x87>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <search_in_string+0xa8>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <search_in_string+0x1e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_in_string>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %r15d,%r15d
cmp    %rbp,%rax
je     117c <search_in_string+0x5c>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1040 <strncasecmp@plt>
test   %rax,%rax
je     1176 <search_in_string+0x56>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %rbp,%rax
jne    1150 <search_in_string+0x30>
jmp    117c <search_in_string+0x5c>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @search_in_string(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 eq i64 %4, %3
br i1 %5, label %14, label %9
6: ; preds = %9
%7 = tail call i64 @strlen(i8* dereferenceable(1) %13)
%8 = icmp eq i64 %7, %3
br i1 %8, label %14, label %9
9: ; preds = %2, %6
%10 = phi i8* [ %13, %6 ], [ %0, %2 ]
%11 = tail call i64 @strncasecmp(i8* %10, i8* %1, i64 %3)
%12 = icmp eq i64 %11, 0
%13 = getelementptr inbounds i8, i8* %10, i64 1
br i1 %12, label %14, label %6
14: ; preds = %9, %6, %2
%15 = phi i32 [ 0, %2 ], [ 0, %6 ], [ 1, %9 ]
ret i32 %15
}