#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__ memcmp(unsigned char const *, char const *, int);
int strlen(char const *);
int user_class_match(const unsigned char *uc, int uclen, const char *s) {
  int slen = strlen(s);
  int i;
  i = 0;
  while (i + slen + 1 < uclen) {
    int clen = uc[i];
    if (clen == slen && memcmp(uc + i + 1, s, slen) == 0)
      return 1;
    i += clen + 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<user_class_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jge    11b5 <user_class_match+0x95>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    11a4 <user_class_match+0x84>
mov    -0x10(%rbp),%rdi
movslq -0x28(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
jne    11a4 <user_class_match+0x84>
movl   $0x1,-0x4(%rbp)
jmp    11bc <user_class_match+0x9c>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1146 <user_class_match+0x26>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<user_class_match>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%r12
mov    %rdx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r13d
lea    0x1(%r13),%ecx
xor    %eax,%eax
cmp    %r15d,%ecx
jge    118f <user_class_match+0x6f>
xor    %ebx,%ebx
jmp    1163 <user_class_match+0x43>
xchg   %ax,%ax
lea    (%rbx,%rbp,1),%eax
add    %ebp,%ebx
add    $0x1,%ebx
add    %r13d,%eax
add    $0x2,%eax
cmp    %r15d,%eax
jge    118d <user_class_match+0x6d>
mov    %ebx,%edi
movzbl (%r12,%rdi,1),%ebp
cmp    %ebp,%r13d
jne    1150 <user_class_match+0x30>
add    %r12,%rdi
add    $0x1,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
jne    1150 <user_class_match+0x30>
mov    $0x1,%eax
jmp    118f <user_class_match+0x6f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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