#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 */
struct stree {
  int dummy;
};
struct node {
  int dummy;
};

/* Variables and functions */
int kTstree_match(struct stree *, char *, int, struct node **, int *);
struct node *stree_get_root(struct stree *);
int gsuffix_lookup_exists(struct stree *tree, const char *pattern,
                          int pattern_length) {
  int pos, matchlen;
  struct node *node;
  char *mapped_pattern;
  mapped_pattern = (char *)pattern;
  node = stree_get_root(tree);
  matchlen = kTstree_match(tree, mapped_pattern, pattern_length, &node, &pos);
  if (matchlen == pattern_length)
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<gsuffix_lookup_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <stree_get_root@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x30(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1030 <kTstree_match@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    117b <gsuffix_lookup_exists+0x5b>
movl   $0x1,-0x4(%rbp)
jmp    1182 <gsuffix_lookup_exists+0x62>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gsuffix_lookup_exists>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
call   1040 <stree_get_root@plt>
mov    %rax,(%rsp)
mov    %rsp,%rcx
lea    0xc(%rsp),%r8
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <kTstree_match@plt>
xor    %ecx,%ecx
cmp    %ebp,%eax
sete   %cl
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stree = type { i32 }
%struct.node = type { i32 }
define i32 @gsuffix_lookup_exists(%struct.stree* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.stree*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.node*
%11 = alloca i8*
store %struct.stree* %0, %struct.stree** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%12 = load i8*, i8** %6
store i8* %12, i8** %11
%13 = load %struct.stree*, %struct.stree** %5
%14 = call %struct.node* @stree_get_root(%struct.stree* %13)
store %struct.node* %14, %struct.node** %10
%15 = load %struct.stree*, %struct.stree** %5
%16 = load i8*, i8** %11
%17 = load i32, i32* %7
%18 = call i32 @kTstree_match(%struct.stree* %15, i8* %16, i32 %17, %struct.node** %10, i32* %8)
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = load i32, i32* %7
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %3
store i32 1, i32* %4
br label %24
23: ; preds = %3
store i32 0, i32* %4
br label %24
24: ; preds = %23, %22
%25 = load i32, i32* %4
ret i32 %25
}

LLVM IR (-O2):
%struct.stree = type { i32 }
%struct.node = type { i32 }
define i32 @gsuffix_lookup_exists(%struct.stree* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.node*
%6 = bitcast i32* %4 to i8*
%7 = bitcast %struct.node** %5 to i8*
%8 = tail call %struct.node* @stree_get_root(%struct.stree* %0)
store %struct.node* %8, %struct.node** %5
%9 = call i32 @kTstree_match(%struct.stree* %0, i8* %1, i32 %2, %struct.node** %5, i32* %4)
%10 = icmp eq i32 %9, %2
%11 = zext i1 %10 to i32
ret i32 %11
}