#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 */
char *rindex(char *, char);
size_t strcspn(char *, char *);
size_t strlen(char *);
scalar_t__ strncmp(char *, char *, size_t);
int comp_alias(char *alias, char *name) {
  size_t compare_length = 0;
  char *alias_pointer = NULL;
  char *name_pointer = NULL;
  compare_length = strcspn(alias, "*");
  if (strncmp(name, alias, compare_length) == 0) {
    if (compare_length == strlen(alias)) {
      if (strlen(alias) == strlen(name)) {
        return 0;
      }
    } else {
      alias_pointer = alias + strlen(alias) - 1;
      if (rindex(alias, '*') == alias_pointer) {
        return 0;
      } else {
        name_pointer = name + strlen(name) - 1;
        while (*alias_pointer != '*') {
          if (*alias_pointer == *name_pointer) {
            alias_pointer--;
            name_pointer--;
          } else {
            return 1;
          }
        }
        return 0;
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<comp_alias>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1050 <strcspn@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12be <comp_alias+0x17e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jne    11ef <comp_alias+0xaf>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
jne    11ea <comp_alias+0xaa>
movl   $0x0,-0x4(%rbp)
jmp    12c5 <comp_alias+0x185>
jmp    12b9 <comp_alias+0x179>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2a,%esi
call   1060 <rindex@plt>
cmp    -0x28(%rbp),%rax
jne    1236 <comp_alias+0xf6>
movl   $0x0,-0x4(%rbp)
jmp    12c5 <comp_alias+0x185>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
je     12ad <comp_alias+0x16d>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    -0x30(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    129c <comp_alias+0x15c>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
jmp    12a8 <comp_alias+0x168>
movl   $0x1,-0x4(%rbp)
jmp    12c5 <comp_alias+0x185>
jmp    1259 <comp_alias+0x119>
movl   $0x0,-0x4(%rbp)
jmp    12c5 <comp_alias+0x185>
jmp    12be <comp_alias+0x17e>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comp_alias>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r13
lea    0xeaa(%rip),%rsi
call   1050 <strcspn@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1180 <comp_alias+0x40>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %r13,%rdi
call   1040 <strlen@plt>
cmp    %rax,%r12
jne    11a1 <comp_alias+0x61>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%r12
jne    1171 <comp_alias+0x31>
jmp    1176 <comp_alias+0x36>
mov    %rax,%r15
lea    (%rax,%r13,1),%rbx
add    $0xffffffffffffffff,%rbx
mov    %r13,%rdi
mov    $0x2a,%esi
call   1060 <rindex@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rbx,%rcx
je     1176 <comp_alias+0x36>
mov    (%rbx),%bl
cmp    $0x2a,%bl
je     1176 <comp_alias+0x36>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    (%rax,%r14,1),%rcx
add    $0xffffffffffffffff,%rcx
lea    (%r15,%r13,1),%rdx
add    $0xfffffffffffffffe,%rdx
xor    %esi,%esi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
cmp    (%rcx,%rsi,1),%bl
jne    1171 <comp_alias+0x31>
movzbl (%rdx,%rsi,1),%ebx
add    $0xffffffffffffffff,%rsi
cmp    $0x2a,%bl
jne    11f0 <comp_alias+0xb0>
jmp    1176 <comp_alias+0x36>

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

LLVM IR (-O2):
@.str = [2 x i8] c"*\00"
define i32 @comp_alias(i8* %0, i8* %1) {
%3 = tail call i64 @strcspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @strncmp(i8* %1, i8* %0, i64 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %34
6: ; preds = %2
%7 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%8 = icmp eq i64 %3, %7
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%11 = icmp eq i64 %3, %10
br i1 %11, label %35, label %34
12: ; preds = %6
%13 = getelementptr inbounds i8, i8* %0, i64 %7
%14 = getelementptr inbounds i8, i8* %13, i64 -1
%15 = tail call i8* @rindex(i8* %0, i8 signext 42)
%16 = icmp eq i8* %15, %14
br i1 %16, label %35, label %17
17: ; preds = %12
%18 = load i8, i8* %14
%19 = icmp eq i8 %18, 42
br i1 %19, label %35, label %20
20: ; preds = %17
%21 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%22 = getelementptr inbounds i8, i8* %1, i64 %21
br label %26
23: ; preds = %26
%24 = load i8, i8* %33
%25 = icmp eq i8 %24, 42
br i1 %25, label %35, label %26
26: ; preds = %20, %23
%27 = phi i8 [ %24, %23 ], [ %18, %20 ]
%28 = phi i8* [ %30, %23 ], [ %22, %20 ]
%29 = phi i8* [ %33, %23 ], [ %14, %20 ]
%30 = getelementptr inbounds i8, i8* %28, i64 -1
%31 = load i8, i8* %30
%32 = icmp eq i8 %27, %31
%33 = getelementptr inbounds i8, i8* %29, i64 -1
br i1 %32, label %23, label %35
34: ; preds = %9, %2
br label %35
35: ; preds = %26, %23, %17, %12, %9, %34
%36 = phi i32 [ 1, %34 ], [ 0, %9 ], [ 0, %12 ], [ 0, %17 ], [ 1, %26 ], [ 0, %23 ]
ret i32 %36
}