#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 const *strchr(char const *, char);
scalar_t__ strcmp(char const *, char const *);
int strlen(char const *);
char *strstr(char const *, char const *);
int matches_wildcard_name(const char *subjectname, const char *certname) {
  int match = (strcmp(subjectname, certname) == 0);
  if (!match && strlen(certname) > 3 && certname[0] == '*' &&
      certname[1] == '.') {
    if (strchr(certname + 2, '.')) {
      const char *cnmatch_str = subjectname;
      const char *tmp = strstr(cnmatch_str, certname + 1);
      match =
          tmp && strcmp(tmp, certname + 2) && tmp == strchr(cnmatch_str, '.');
    }
  }
  return match;
}


x86 assembly (clang, -O0):
<matches_wildcard_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    124b <matches_wildcard_name+0x10b>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jle    124b <matches_wildcard_name+0x10b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    124b <matches_wildcard_name+0x10b>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2e,%eax
jne    124b <matches_wildcard_name+0x10b>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     1246 <matches_wildcard_name+0x106>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x1,%rsi
call   1060 <strstr@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x28(%rbp)
mov    %al,-0x29(%rbp)
je     123b <matches_wildcard_name+0xfb>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
add    $0x2,%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
je     123b <matches_wildcard_name+0xfb>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
jmp    124b <matches_wildcard_name+0x10b>
mov    -0x14(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matches_wildcard_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1050 <strcmp@plt>
test   %rax,%rax
je     11c9 <matches_wildcard_name+0x89>
mov    %rbp,%rdi
call   1030 <strlen@plt>
xor    %r14d,%r14d
cmp    $0x4,%eax
jl     11cf <matches_wildcard_name+0x8f>
cmpb   $0x2a,0x0(%rbp)
jne    11cf <matches_wildcard_name+0x8f>
cmpb   $0x2e,0x1(%rbp)
jne    11cf <matches_wildcard_name+0x8f>
lea    0x2(%rbp),%r15
mov    %r15,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11cf <matches_wildcard_name+0x8f>
add    $0x1,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strstr@plt>
test   %rax,%rax
je     11cf <matches_wildcard_name+0x8f>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11cf <matches_wildcard_name+0x8f>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1040 <strchr@plt>
xor    %r14d,%r14d
cmp    %rax,%rbp
sete   %r14b
jmp    11cf <matches_wildcard_name+0x8f>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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