#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__ strlen(char const *);
int strmatch(const char *pattern, const char *string) {
  if (strlen(pattern) != strlen(string))
    return 0;
  for (; *pattern != '\0'; pattern++, string++)
    if (*pattern != '*' && *string != *pattern)
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<strmatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     1152 <strmatch+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <strmatch+0xb2>
jmp    1157 <strmatch+0x47>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11bb <strmatch+0xab>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
je     1199 <strmatch+0x89>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1199 <strmatch+0x89>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <strmatch+0xb2>
jmp    119e <strmatch+0x8e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1157 <strmatch+0x47>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strmatch>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%r15
jne    1160 <strmatch+0x50>
xor    %eax,%eax
jmp    1144 <strmatch+0x34>
nopl   0x0(%rax)
add    $0x1,%rax
movzbl (%rbx,%rax,1),%ecx
cmp    $0x2a,%cl
je     1140 <strmatch+0x30>
test   %cl,%cl
je     115b <strmatch+0x4b>
cmp    %cl,(%r14,%rax,1)
je     1140 <strmatch+0x30>
xor    %eax,%eax
jmp    1160 <strmatch+0x50>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @strmatch(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = call i64 @strlen(i8* %6)
%8 = load i8*, i8** %5
%9 = call i64 @strlen(i8* %8)
%10 = icmp ne i64 %7, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %39
12: ; preds = %2
br label %13
13: ; preds = %33, %12
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %38
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 42
br i1 %22, label %23, label %32
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = load i8*, i8** %4
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %26, %29
br i1 %30, label %31, label %32
31: ; preds = %23
store i32 0, i32* %3
br label %39
32: ; preds = %23, %18
br label %33
33: ; preds = %32
%34 = load i8*, i8** %4
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %4
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %5
br label %13
38: ; preds = %13
store i32 1, i32* %3
br label %39
39: ; preds = %38, %31, %11
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @strmatch(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %16
6: ; preds = %2, %13
%7 = phi i8* [ %14, %13 ], [ %0, %2 ]
%8 = phi i8* [ %15, %13 ], [ %1, %2 ]
%9 = load i8, i8* %7
switch i8 %9, label %10 [
i8 0, label %16
i8 42, label %13
]
10: ; preds = %6
%11 = load i8, i8* %8
%12 = icmp eq i8 %11, %9
br i1 %12, label %13, label %16
13: ; preds = %6, %10
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = getelementptr inbounds i8, i8* %8, i64 1
br label %6
16: ; preds = %6, %10, %2
%17 = phi i32 [ 0, %2 ], [ 1, %6 ], [ 0, %10 ]
ret i32 %17
}