#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 /*<<< orphan*/ free(char *);
char *normalize(char *);
int strcmp(char *, char *);
int strlen(char *);
int strncmp(char *, char *, int);
int evaluate_match_signing(char *pattern, char *subject, int type) {
  int success = 2;
  int len = 0;
  int compare;
  char *patterntmp = normalize(pattern);
  char *subjecttmp = normalize(subject);
  if (!pattern || !subject)
    return success;
  len = strlen(pattern);
  if (pattern[len - 1] == '*')
    compare = strncmp(patterntmp, subjecttmp, len - 1);
  else
    compare = strcmp(patterntmp, subjecttmp);
  free(patterntmp);
  free(subjecttmp);
  if (!compare) {
    if (type)
      return 0;
    else
      return 1;
  }
  return success;
}


x86 assembly (clang, -O0):
<evaluate_match_signing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <normalize@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <normalize@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a1 <evaluate_match_signing+0x51>
cmpq   $0x0,-0x18(%rbp)
jne    11ac <evaluate_match_signing+0x5c>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1241 <evaluate_match_signing+0xf1>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2a,%eax
jne    11ed <evaluate_match_signing+0x9d>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
call   1040 <strncmp@plt>
mov    %eax,-0x28(%rbp)
jmp    11fd <evaluate_match_signing+0xad>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strcmp@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x28(%rbp)
jne    123b <evaluate_match_signing+0xeb>
cmpl   $0x0,-0x1c(%rbp)
je     122f <evaluate_match_signing+0xdf>
movl   $0x0,-0x4(%rbp)
jmp    1241 <evaluate_match_signing+0xf1>
movl   $0x1,-0x4(%rbp)
jmp    1241 <evaluate_match_signing+0xf1>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evaluate_match_signing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1060 <normalize@plt>
mov    %rax,%r15
mov    %rbp,%rdi
call   1060 <normalize@plt>
mov    $0x2,%r13d
test   %rbx,%rbx
je     11d5 <evaluate_match_signing+0x85>
test   %rbp,%rbp
je     11d5 <evaluate_match_signing+0x85>
mov    %rax,%r12
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq %eax,%rdx
cmpb   $0x2a,-0x1(%rbx,%rdx,1)
jne    11aa <evaluate_match_signing+0x5a>
add    $0xffffffffffffffff,%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <strncmp@plt>
jmp    11b5 <evaluate_match_signing+0x65>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <strcmp@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
test   %ebx,%ebx
jne    11d5 <evaluate_match_signing+0x85>
xor    %r13d,%r13d
test   %r14d,%r14d
sete   %r13b
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @evaluate_match_signing(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 2, i32* %8
store i32 0, i32* %9
%13 = load i8*, i8** %5
%14 = call i8* @normalize(i8* %13)
store i8* %14, i8** %11
%15 = load i8*, i8** %6
%16 = call i8* @normalize(i8* %15)
store i8* %16, i8** %12
%17 = load i8*, i8** %5
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %3
%20 = load i8*, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %24, label %22
22: ; preds = %19, %3
%23 = load i32, i32* %8
store i32 %23, i32* %4
br label %59
24: ; preds = %19
%25 = load i8*, i8** %5
%26 = call i32 @strlen(i8* %25)
store i32 %26, i32* %9
%27 = load i8*, i8** %5
%28 = load i32, i32* %9
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 42
br i1 %34, label %35, label %41
35: ; preds = %24
%36 = load i8*, i8** %11
%37 = load i8*, i8** %12
%38 = load i32, i32* %9
%39 = sub nsw i32 %38, 1
%40 = call i32 @strncmp(i8* %36, i8* %37, i32 %39)
store i32 %40, i32* %10
br label %45
41: ; preds = %24
%42 = load i8*, i8** %11
%43 = load i8*, i8** %12
%44 = call i32 @strcmp(i8* %42, i8* %43)
store i32 %44, i32* %10
br label %45
45: ; preds = %41, %35
%46 = load i8*, i8** %11
%47 = call i32 @free(i8* %46)
%48 = load i8*, i8** %12
%49 = call i32 @free(i8* %48)
%50 = load i32, i32* %10
%51 = icmp ne i32 %50, 0
br i1 %51, label %57, label %52
52: ; preds = %45
%53 = load i32, i32* %7
%54 = icmp ne i32 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %52
store i32 0, i32* %4
br label %59
56: ; preds = %52
store i32 1, i32* %4
br label %59
57: ; preds = %45
%58 = load i32, i32* %8
store i32 %58, i32* %4
br label %59
59: ; preds = %57, %56, %55, %22
%60 = load i32, i32* %4
ret i32 %60
}

LLVM IR (-O2):
define i32 @evaluate_match_signing(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @normalize(i8* %0)
%5 = tail call i8* @normalize(i8* %1)
%6 = icmp ne i8* %0, null
%7 = icmp ne i8* %1, null
%8 = and i1 %6, %7
br i1 %8, label %9, label %28
9: ; preds = %3
%10 = tail call i32 @strlen(i8* %0)
%11 = add nsw i32 %10, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 42
br i1 %15, label %16, label %18
16: ; preds = %9
%17 = tail call i32 @strncmp(i8* %4, i8* %5, i32 %11)
br label %20
18: ; preds = %9
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %4, i8* dereferenceable(1) %5)
br label %20
20: ; preds = %18, %16
%21 = phi i32 [ %17, %16 ], [ %19, %18 ]
%22 = tail call i32 @free(i8* %4)
%23 = tail call i32 @free(i8* %5)
%24 = icmp eq i32 %21, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = icmp eq i32 %2, 0
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %20, %25, %3
%29 = phi i32 [ 2, %3 ], [ %27, %25 ], [ 2, %20 ]
ret i32 %29
}