#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 strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
scalar_t__ white_space(char);
int matches(char *str1, char *comm, int min_len_for_match) {
  int length;
  for (length = 0; !white_space(*(str1 + length)) && *(str1 + length) != '\0';
       length++)
    ;
  if (length < min_len_for_match)
    return 0;
  else if (length > strlen(comm))
    return (!strncmp(str1, comm, strlen(comm))) &&
           white_space(*(str1 + strlen(comm)));
  else
    return (!strncmp(str1, comm, length));
}


x86 assembly (clang, -O0):
<matches>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <white_space@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    1182 <matches+0x52>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1192 <matches+0x62>
jmp    11a5 <matches+0x75>
jmp    1197 <matches+0x67>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114a <matches+0x1a>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11bd <matches+0x8d>
movl   $0x0,-0x4(%rbp)
jmp    126e <matches+0x13e>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jle    124e <matches+0x11e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x29(%rbp)
jne    123e <matches+0x10e>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <white_space@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    126e <matches+0x13e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matches>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%r15
movsbl (%rdi),%edi
call   1040 <white_space@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    116b <matches+0x3b>
xor    %ebx,%ebx
cmpb   $0x0,(%r15,%rbx,1)
je     116b <matches+0x3b>
movsbl 0x1(%r15,%rbx,1),%edi
add    $0x1,%rbx
call   1040 <white_space@plt>
test   %rax,%rax
je     1150 <matches+0x20>
cmp    %ebp,%ebx
jl     1194 <matches+0x64>
mov    %r14,%rdi
call   1050 <strlen@plt>
cmp    %eax,%ebx
jle    1198 <matches+0x68>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11ac <matches+0x7c>
xor    %eax,%eax
jmp    11c6 <matches+0x96>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
sete   %al
jmp    11c6 <matches+0x96>
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movsbl (%r15,%rax,1),%edi
call   1040 <white_space@plt>
test   %rax,%rax
setne  %al
movzbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @matches(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %28, %3
%10 = load i8*, i8** %5
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = call i64 @white_space(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %9
%18 = load i8*, i8** %5
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br label %25
25: ; preds = %17, %9
%26 = phi i1 [ false, %9 ], [ %24, %17 ]
br i1 %26, label %27, label %31
27: ; preds = %25
br label %28
28: ; preds = %27
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %9
31: ; preds = %25
%32 = load i32, i32* %8
%33 = load i32, i32* %7
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %31
store i32 0, i32* %4
br label %68
36: ; preds = %31
%37 = load i32, i32* %8
%38 = load i8*, i8** %6
%39 = call i32 @strlen(i8* %38)
%40 = icmp sgt i32 %37, %39
br i1 %40, label %41, label %60
41: ; preds = %36
%42 = load i8*, i8** %5
%43 = load i8*, i8** %6
%44 = load i8*, i8** %6
%45 = call i32 @strlen(i8* %44)
%46 = call i32 @strncmp(i8* %42, i8* %43, i32 %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %57, label %48
48: ; preds = %41
%49 = load i8*, i8** %5
%50 = load i8*, i8** %6
%51 = call i32 @strlen(i8* %50)
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %49, i64 %52
%54 = load i8, i8* %53
%55 = call i64 @white_space(i8 signext %54)
%56 = icmp ne i64 %55, 0
br label %57
57: ; preds = %48, %41
%58 = phi i1 [ false, %41 ], [ %56, %48 ]
%59 = zext i1 %58 to i32
store i32 %59, i32* %4
br label %68
60: ; preds = %36
%61 = load i8*, i8** %5
%62 = load i8*, i8** %6
%63 = load i32, i32* %8
%64 = call i32 @strncmp(i8* %61, i8* %62, i32 %63)
%65 = icmp ne i32 %64, 0
%66 = xor i1 %65, true
%67 = zext i1 %66 to i32
store i32 %67, i32* %4
br label %68
68: ; preds = %60, %57, %35
%69 = load i32, i32* %4
ret i32 %69
}

LLVM IR (-O2):
define i32 @matches(i8* %0, i8* %1, i32 %2) {
%4 = load i8, i8* %0
%5 = tail call i64 @white_space(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %3, %12
%8 = phi i64 [ %13, %12 ], [ 0, %3 ]
%9 = phi i8* [ %14, %12 ], [ %0, %3 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %7
%13 = add nuw i64 %8, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = tail call i64 @white_space(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %7, label %18
18: ; preds = %12, %7
%19 = phi i64 [ %8, %7 ], [ %13, %12 ]
%20 = trunc i64 %19 to i32
br label %21
21: ; preds = %18, %3
%22 = phi i32 [ 0, %3 ], [ %20, %18 ]
%23 = icmp slt i32 %22, %2
br i1 %23, label %41, label %24
24: ; preds = %21
%25 = tail call i32 @strlen(i8* %1)
%26 = icmp sgt i32 %22, %25
br i1 %26, label %27, label %38
27: ; preds = %24
%28 = tail call i32 @strlen(i8* %1)
%29 = tail call i32 @strncmp(i8* %0, i8* %1, i32 %28)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %41
31: ; preds = %27
%32 = tail call i32 @strlen(i8* %1)
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %0, i64 %33
%35 = load i8, i8* %34
%36 = tail call i64 @white_space(i8 signext %35)
%37 = icmp ne i64 %36, 0
br label %41
38: ; preds = %24
%39 = tail call i32 @strncmp(i8* %0, i8* %1, i32 %22)
%40 = icmp eq i32 %39, 0
br label %41
41: ; preds = %27, %31, %21, %38
%42 = phi i1 [ %40, %38 ], [ false, %21 ], [ false, %27 ], [ %37, %31 ]
%43 = zext i1 %42 to i32
ret i32 %43
}