#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__ isspace(char const);
int strlen(char const *);
int strncmp(char const *, char const *, int);
int strmatches(const char *s, const char *m) {
  int i, l;
  l = strlen(m);
  i = strncmp(s, m, l);
  if (i)
    return i;
  return !(isspace(s[l]) || s[l] == ')') ? 1 : 0;
}


x86 assembly (clang, -O0):
<strmatches>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncmp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1174 <strmatches+0x44>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <strmatches+0x92>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isspace@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    11ac <strmatches+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x29,%eax
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%dl
xor    $0xff,%dl
xor    %eax,%eax
mov    $0x1,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strmatches>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1176 <strmatches+0x46>
movslq %ebp,%rbx
movsbl (%r14,%rbx,1),%edi
call   1050 <isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1176 <strmatches+0x46>
xor    %eax,%eax
cmpb   $0x29,(%r14,%rbx,1)
setne  %al
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @strmatches(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i32 @strncmp(i8* %0, i8* %1, i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = sext i32 %3 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = tail call i64 @isspace(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %6
%13 = load i8, i8* %8
%14 = icmp ne i8 %13, 41
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %6, %12, %2
%17 = phi i32 [ %4, %2 ], [ 0, %6 ], [ %15, %12 ]
ret i32 %17
}