#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__ ceq(unsigned char const, char const);
unsigned char substr(const unsigned char *big, const char *small,
                     unsigned char len, unsigned char slen) {
  unsigned char i = 0, i2 = 0;
  if (slen == 0)
    return 1;
redo:
  if (ceq(big[i], small[0]))
    goto more;
  return 0;
more:
  i2 = 1;
  for (i++; i < len; i++, i2++) {
    if (slen == i2)
      return 1;
    else
      goto redo;
  }
  return 0;
}


x86 assembly (clang, -O0):
<substr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %cl,-0x19(%rbp)
mov    %al,-0x1a(%rbp)
movb   $0x0,-0x1b(%rbp)
movb   $0x0,-0x1c(%rbp)
movzbl -0x1a(%rbp),%eax
cmp    $0x0,%eax
jne    1148 <substr+0x38>
movb   $0x1,-0x1(%rbp)
jmp    11bd <substr+0xad>
jmp    114d <substr+0x3d>
mov    -0x10(%rbp),%rax
movzbl -0x1b(%rbp),%ecx
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%rax
movzbl %cl,%edi
movsbl (%rax),%esi
call   1030 <ceq@plt>
cmp    $0x0,%rax
je     1176 <substr+0x66>
jmp    117f <substr+0x6f>
movb   $0x0,-0x1(%rbp)
jmp    11bd <substr+0xad>
movb   $0x1,-0x1c(%rbp)
mov    -0x1b(%rbp),%al
add    $0x1,%al
mov    %al,-0x1b(%rbp)
movzbl -0x1b(%rbp),%eax
movzbl -0x19(%rbp),%ecx
cmp    %ecx,%eax
jge    11b9 <substr+0xa9>
movzbl -0x1a(%rbp),%eax
movzbl -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jne    11b4 <substr+0xa4>
movb   $0x1,-0x1(%rbp)
jmp    11bd <substr+0xad>
jmp    114d <substr+0x3d>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<substr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %ecx,%ecx
je     115e <substr+0x4e>
mov    %ecx,%r15d
mov    %rsi,%r14
mov    %rdi,%r12
movzbl %dl,%ebp
mov    $0x1,%eax
nopl   (%rax)
mov    %rax,%rbx
movzbl -0x1(%r12,%rax,1),%edi
movsbl (%r14),%esi
call   1030 <ceq@plt>
test   %rax,%rax
je     1162 <substr+0x52>
cmp    %rbp,%rbx
jae    1156 <substr+0x46>
lea    0x1(%rbx),%rax
cmp    $0x1,%r15b
jne    1130 <substr+0x20>
cmp    %rbp,%rbx
setb   %al
jmp    1164 <substr+0x54>
mov    $0x1,%al
jmp    1164 <substr+0x54>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define zeroext i8 @substr(i8* nocapture %0, i8* nocapture %1, i8 zeroext %2, i8 zeroext %3) {
%5 = icmp eq i8 %3, 0
br i1 %5, label %23, label %6
6: ; preds = %4
%7 = icmp eq i8 %3, 1
%8 = zext i8 %2 to i64
br label %9
9: ; preds = %16, %6
%10 = phi i64 [ %17, %16 ], [ 0, %6 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
%13 = load i8, i8* %1
%14 = tail call i64 @ceq(i8 zeroext %12, i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %9
%17 = add nuw nsw i64 %10, 1
%18 = icmp uge i64 %17, %8
%19 = or i1 %18, %7
br i1 %19, label %20, label %9
20: ; preds = %16
%21 = xor i1 %18, true
%22 = zext i1 %21 to i8
br label %23
23: ; preds = %9, %20, %4
%24 = phi i8 [ 1, %4 ], [ %22, %20 ], [ 0, %9 ]
ret i8 %24
}