#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__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
int match_stab_symbol(char *symbol, char *stabtext, int slen) {
  if (strcmp(symbol, stabtext) == 0) {
    return 1;
  }
  if ((strncmp(symbol, stabtext, slen) == 0) && (*(stabtext + slen) == ':'))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<match_stab_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1156 <match_stab_symbol+0x36>
movl   $0x1,-0x4(%rbp)
jmp    1198 <match_stab_symbol+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1191 <match_stab_symbol+0x71>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    1191 <match_stab_symbol+0x71>
movl   $0x1,-0x4(%rbp)
jmp    1198 <match_stab_symbol+0x78>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_stab_symbol>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1040 <strcmp@plt>
mov    $0x1,%r15d
test   %rax,%rax
je     115f <match_stab_symbol+0x3f>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    115c <match_stab_symbol+0x3c>
movslq %r14d,%rax
cmpb   $0x3a,(%rbx,%rax,1)
je     115f <match_stab_symbol+0x3f>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @match_stab_symbol(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = load i8*, i8** %6
%10 = call i64 @strcmp(i8* %8, i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %3
store i32 1, i32* %4
br label %29
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i8*, i8** %6
%16 = load i32, i32* %7
%17 = call i64 @strncmp(i8* %14, i8* %15, i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %13
%20 = load i8*, i8** %6
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 58
br i1 %26, label %27, label %28
27: ; preds = %19
store i32 1, i32* %4
br label %29
28: ; preds = %19, %13
store i32 0, i32* %4
br label %29
29: ; preds = %28, %27, %12
%30 = load i32, i32* %4
ret i32 %30
}

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