#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 */
typedef int uint8_t;

/* Variables and functions */
size_t strlen(char const *);
uint8_t hasSubstr(const char *inputStr, const char *substr) {
  size_t i, occurenceCounter = 0;
  char *currPos;
  for (i = 0; i < strlen(inputStr); ++i) {
    currPos = substr + i;
    if (*currPos == *(inputStr + i)) {
      occurenceCounter++;
      if (occurenceCounter == strlen(substr)) {
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<hasSubstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jae    11cc <hasSubstr+0xbc>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11b6 <hasSubstr+0xa6>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jne    11b1 <hasSubstr+0xa1>
movl   $0x1,-0x4(%rbp)
jmp    11d3 <hasSubstr+0xc3>
jmp    11b6 <hasSubstr+0xa6>
jmp    11bb <hasSubstr+0xab>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1130 <hasSubstr+0x20>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hasSubstr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %rax,%rax
je     116c <hasSubstr+0x5c>
mov    %rax,%r15
xor    %r13d,%r13d
xor    %ebx,%ebx
jmp    1149 <hasSubstr+0x39>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r15
je     116c <hasSubstr+0x5c>
movzbl (%r12,%rbx,1),%eax
cmp    (%r14,%rbx,1),%al
jne    1140 <hasSubstr+0x30>
add    $0x1,%r13
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    %rax,%r13
jne    1140 <hasSubstr+0x30>
mov    $0x1,%eax
jmp    116e <hasSubstr+0x5e>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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