#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 sc_strlen(char *);
int sc_substr_search(char *A, char *B) {
  int walker_A = 0;
  int walker_B = 0;
  int len_of_A = sc_strlen(A);
  int len_of_B = sc_strlen(B);
  for (walker_A = 0; walker_A < len_of_A && walker_B < len_of_B;) {
    if (A[walker_A] == B[walker_B]) {
      walker_A++;
      walker_B++;
    } else {
      walker_A++;
      walker_B = 0;
    }
  }
  if (walker_B == len_of_B)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<sc_substr_search>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sc_strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <sc_strlen@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x24(%rbp),%ecx
mov    %al,-0x29(%rbp)
jge    116a <sc_substr_search+0x5a>
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
setl   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    117a <sc_substr_search+0x6a>
jmp    11c6 <sc_substr_search+0xb6>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x20(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11b1 <sc_substr_search+0xa1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11c1 <sc_substr_search+0xb1>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
jmp    114d <sc_substr_search+0x3d>
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    11de <sc_substr_search+0xce>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <sc_substr_search+0xd5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sc_substr_search>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbp
call   1030 <sc_strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <sc_strlen@plt>
xor    %edx,%edx
test   %ebx,%ebx
jle    1170 <sc_substr_search+0x60>
test   %eax,%eax
jle    1170 <sc_substr_search+0x60>
mov    %ebx,%ecx
xor    %edx,%edx
mov    $0x1,%esi
nopl   0x0(%rax)
movzbl -0x1(%rbp,%rsi,1),%ebx
movslq %edx,%rdi
cmp    (%r14,%rdi,1),%bl
je     1160 <sc_substr_search+0x50>
xor    %edx,%edx
cmp    %rcx,%rsi
jb     1168 <sc_substr_search+0x58>
jmp    1170 <sc_substr_search+0x60>
nopw   0x0(%rax,%rax,1)
add    $0x1,%edx
cmp    %rcx,%rsi
jae    1170 <sc_substr_search+0x60>
add    $0x1,%rsi
cmp    %eax,%edx
jl     1140 <sc_substr_search+0x30>
xor    %ecx,%ecx
cmp    %eax,%edx
sete   %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @sc_substr_search(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = load i8*, i8** %4
%11 = call i32 @sc_strlen(i8* %10)
store i32 %11, i32* %8
%12 = load i8*, i8** %5
%13 = call i32 @sc_strlen(i8* %12)
store i32 %13, i32* %9
store i32 0, i32* %6
br label %14
14: ; preds = %46, %2
%15 = load i32, i32* %6
%16 = load i32, i32* %8
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %14
%19 = load i32, i32* %7
%20 = load i32, i32* %9
%21 = icmp slt i32 %19, %20
br label %22
22: ; preds = %18, %14
%23 = phi i1 [ false, %14 ], [ %21, %18 ]
br i1 %23, label %24, label %47
24: ; preds = %22
%25 = load i8*, i8** %4
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i8*, i8** %5
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %30, %36
br i1 %37, label %38, label %43
38: ; preds = %24
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %46
43: ; preds = %24
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
store i32 0, i32* %7
br label %46
46: ; preds = %43, %38
br label %14
47: ; preds = %22
%48 = load i32, i32* %7
%49 = load i32, i32* %9
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 1, i32* %3
br label %53
52: ; preds = %47
store i32 0, i32* %3
br label %53
53: ; preds = %52, %51
%54 = load i32, i32* %3
ret i32 %54
}

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