#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 */
unsigned int strlen(char *);
scalar_t__ strncmp(char *, char *, unsigned int);
int present_string(char *s, char *searchS) {
  unsigned int n, i = 0, j = 0;
  n = strlen(searchS);
  while (s[i] != '\0') {
    if (strncmp(&s[i], searchS, n) == 0) {
      return (1);
    }
    i++;
  }
  return (0);
}


x86 assembly (clang, -O0):
<present_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1198 <present_string+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%eax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    118a <present_string+0x6a>
movl   $0x1,-0x4(%rbp)
jmp    119f <present_string+0x7f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114a <present_string+0x2a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<present_string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %rsi,%rdi
call   1040 <strlen@plt>
xor    %r14d,%r14d
cmpb   $0x0,0x0(%rbp)
je     1178 <present_string+0x58>
mov    %eax,%r12d
mov    $0x1,%ebx
mov    %rbp,%rdi
nopw   0x0(%rax,%rax,1)
mov    %r15,%rsi
mov    %r12d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1172 <present_string+0x52>
mov    %ebx,%eax
lea    (%rax,%rbp,1),%rdi
add    $0x1,%ebx
cmpb   $0x0,0x0(%rbp,%rax,1)
jne    1150 <present_string+0x30>
jmp    1178 <present_string+0x58>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @present_string(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
store i32 0, i32* %7
store i32 0, i32* %8
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %6
br label %11
11: ; preds = %29, %2
%12 = load i8*, i8** %4
%13 = load i32, i32* %7
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %32
19: ; preds = %11
%20 = load i8*, i8** %4
%21 = load i32, i32* %7
%22 = zext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8*, i8** %5
%25 = load i32, i32* %6
%26 = call i64 @strncmp(i8* %23, i8* %24, i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %19
store i32 1, i32* %3
br label %33
29: ; preds = %19
%30 = load i32, i32* %7
%31 = add i32 %30, 1
store i32 %31, i32* %7
br label %11
32: ; preds = %11
store i32 0, i32* %3
br label %33
33: ; preds = %32, %28
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @present_string(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %17, label %11
6: ; preds = %11
%7 = zext i32 %16 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %2, %6
%12 = phi i8* [ %8, %6 ], [ %0, %2 ]
%13 = phi i32 [ %16, %6 ], [ 0, %2 ]
%14 = tail call i64 @strncmp(i8* %12, i8* %1, i32 %3)
%15 = icmp eq i64 %14, 0
%16 = add i32 %13, 1
br i1 %15, label %17, label %6
17: ; preds = %11, %6, %2
%18 = phi i32 [ 0, %2 ], [ 0, %6 ], [ 1, %11 ]
ret i32 %18
}