#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*/ dbg_printf(char *, int, int, char *, char const *,
                              char const *);
scalar_t__ strcmp(char *, char const *);
int /*<<< orphan*/ tolower(char const);
int hostmatch(const char *hname, const char *pattern) {
  int seen_dot = 0;
  dbg_printf("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/ph1ee/nfs-server-2.3-5/refs/heads/"
             "master/libnfs/auth.c",
             1100, 0x0800, "\tmatch %s ~ %s\n", hname, pattern);
  if (0 == strcmp("*", pattern)) {
    return 1;
  }
  for (;;) {
    if (*hname == '\0' || *pattern == '\0')
      return (*hname == *pattern);
    switch (*pattern) {
    case '*':
      while (*hname != '.' && *hname != '\0')
        hname++;
      seen_dot = 1;
      pattern++;
      break;
    case '?':
      if (*hname == '.')
        return (0);
      hname++;
      pattern++;
      break;
    default:
      if (seen_dot) {
        if (tolower(*hname) != tolower(*pattern))
          return (0);
      } else if (*hname != *pattern)
        return (0);
      if (*pattern == '.')
        seen_dot = 1;
      hname++;
      pattern++;
      break;
    }
  }
}


x86 assembly (clang, -O0):
<hostmatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9
lea    0xeaa(%rip),%rdi
mov    $0x44c,%esi
mov    $0x800,%edx
lea    0xf2a(%rip),%rcx
call   1050 <dbg_printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xf2a(%rip),%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1196 <hostmatch+0x66>
movl   $0x1,-0x4(%rbp)
jmp    133e <hostmatch+0x20e>
jmp    119b <hostmatch+0x6b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11bb <hostmatch+0x8b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11db <hostmatch+0xab>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    133e <hostmatch+0x20e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x20(%rbp)
sub    $0x2a,%eax
je     1204 <hostmatch+0xd4>
jmp    11f3 <hostmatch+0xc3>
mov    -0x20(%rbp),%eax
sub    $0x3f,%eax
je     1267 <hostmatch+0x137>
jmp    12a0 <hostmatch+0x170>
jmp    1209 <hostmatch+0xd9>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x21(%rbp)
je     122e <hostmatch+0xfe>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    123e <hostmatch+0x10e>
jmp    124f <hostmatch+0x11f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1209 <hostmatch+0xd9>
movl   $0x1,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1339 <hostmatch+0x209>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1283 <hostmatch+0x153>
movl   $0x0,-0x4(%rbp)
jmp    133e <hostmatch+0x20e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1339 <hostmatch+0x209>
cmpl   $0x0,-0x1c(%rbp)
je     12e3 <hostmatch+0x1b3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
je     12de <hostmatch+0x1ae>
movl   $0x0,-0x4(%rbp)
jmp    133e <hostmatch+0x20e>
jmp    130a <hostmatch+0x1da>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1305 <hostmatch+0x1d5>
movl   $0x0,-0x4(%rbp)
jmp    133e <hostmatch+0x20e>
jmp    130a <hostmatch+0x1da>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1321 <hostmatch+0x1f1>
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    119b <hostmatch+0x6b>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hostmatch>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebb(%rip),%rdi
lea    0xf45(%rip),%rcx
mov    $0x44c,%esi
mov    $0x800,%edx
mov    %rbx,%r8
mov    %r14,%r9
call   1050 <dbg_printf@plt>
lea    0xf39(%rip),%rdi
mov    %r14,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1225 <hostmatch+0xf5>
mov    (%rbx),%cl
xor    %r12d,%r12d
test   %cl,%cl
je     122c <hostmatch+0xfc>
mov    $0x1,%r15d
jmp    11a4 <hostmatch+0x74>
xchg   %ax,%ax
mov    $0x1,%r12d
add    $0x1,%r14
mov    (%rbx),%cl
test   %cl,%cl
je     122c <hostmatch+0xfc>
movsbl (%r14),%eax
test   %eax,%eax
je     122e <hostmatch+0xfe>
cmp    $0x3f,%eax
je     11e0 <hostmatch+0xb0>
cmp    $0x2a,%eax
jne    11f0 <hostmatch+0xc0>
nopw   0x0(%rax,%rax,1)
test   %cl,%cl
je     1190 <hostmatch+0x60>
cmp    $0x2e,%cl
je     1190 <hostmatch+0x60>
movzbl 0x1(%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    11c4 <hostmatch+0x94>
jmp    1190 <hostmatch+0x60>
nopw   0x0(%rax,%rax,1)
cmp    $0x2e,%cl
je     123f <hostmatch+0x10f>
add    $0x1,%rbx
jmp    1196 <hostmatch+0x66>
nopl   0x0(%rax,%rax,1)
test   %r12d,%r12d
je     1211 <hostmatch+0xe1>
movsbl %cl,%edi
call   1040 <tolower@plt>
mov    %eax,%ebp
movsbl (%r14),%edi
call   1040 <tolower@plt>
cmp    %eax,%ebp
jne    123f <hostmatch+0x10f>
mov    (%r14),%cl
jmp    1215 <hostmatch+0xe5>
cmp    %al,%cl
jne    123f <hostmatch+0x10f>
cmp    $0x2e,%cl
cmove  %r15d,%r12d
add    $0x1,%rbx
jmp    1196 <hostmatch+0x66>
mov    $0x1,%eax
jmp    1236 <hostmatch+0x106>
xor    %ecx,%ecx
xor    %eax,%eax
cmp    (%r14),%cl
sete   %al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
jmp    1236 <hostmatch+0x106>

LLVM IR (-O0):
@.str = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ph1ee/nfs-server-2.3-5/refs/heads/master/libnfs/auth.c\00"
@.str.1 = [16 x i8] c"\09match %s ~ %s\0A\00"
@.str.2 = [2 x i8] c"*\00"
define i32 @hostmatch(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = call i32 @dbg_printf(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 1100, i32 2048, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %7, i8* %8)
%10 = load i8*, i8** %5
%11 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = icmp eq i64 0, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 1, i32* %3
br label %103
14: ; preds = %2
br label %15
15: ; preds = %102, %14
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %20, %15
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i8*, i8** %5
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %28, %31
%33 = zext i1 %32 to i32
store i32 %33, i32* %3
br label %103
34: ; preds = %20
%35 = load i8*, i8** %5
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
switch i32 %37, label %68 [
i32 42, label %38
i32 63, label %57
]
38: ; preds = %34
br label %39
39: ; preds = %51, %38
%40 = load i8*, i8** %4
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 46
br i1 %43, label %44, label %49
44: ; preds = %39
%45 = load i8*, i8** %4
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 0
br label %49
49: ; preds = %44, %39
%50 = phi i1 [ false, %39 ], [ %48, %44 ]
br i1 %50, label %51, label %54
51: ; preds = %49
%52 = load i8*, i8** %4
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %4
br label %39
54: ; preds = %49
store i32 1, i32* %6
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %5
br label %102
57: ; preds = %34
%58 = load i8*, i8** %4
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 46
br i1 %61, label %62, label %63
62: ; preds = %57
store i32 0, i32* %3
br label %103
63: ; preds = %57
%64 = load i8*, i8** %4
%65 = getelementptr inbounds i8, i8* %64, i32 1
store i8* %65, i8** %4
%66 = load i8*, i8** %5
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %5
br label %102
68: ; preds = %34
%69 = load i32, i32* %6
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %81
71: ; preds = %68
%72 = load i8*, i8** %4
%73 = load i8, i8* %72
%74 = call i32 @tolower(i8 signext %73)
%75 = load i8*, i8** %5
%76 = load i8, i8* %75
%77 = call i32 @tolower(i8 signext %76)
%78 = icmp ne i32 %74, %77
br i1 %78, label %79, label %80
79: ; preds = %71
store i32 0, i32* %3
br label %103
80: ; preds = %71
br label %91
81: ; preds = %68
%82 = load i8*, i8** %4
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = load i8*, i8** %5
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp ne i32 %84, %87
br i1 %88, label %89, label %90
89: ; preds = %81
store i32 0, i32* %3
br label %103
90: ; preds = %81
br label %91
91: ; preds = %90, %80
%92 = load i8*, i8** %5
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 46
br i1 %95, label %96, label %97
96: ; preds = %91
store i32 1, i32* %6
br label %97
97: ; preds = %96, %91
%98 = load i8*, i8** %4
%99 = getelementptr inbounds i8, i8* %98, i32 1
store i8* %99, i8** %4
%100 = load i8*, i8** %5
%101 = getelementptr inbounds i8, i8* %100, i32 1
store i8* %101, i8** %5
br label %102
102: ; preds = %97, %63, %54
br label %15
103: ; preds = %89, %79, %62, %25, %13
%104 = load i32, i32* %3
ret i32 %104
}

LLVM IR (-O2):
@.str = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ph1ee/nfs-server-2.3-5/refs/heads/master/libnfs/auth.c\00"
@.str.1 = [16 x i8] c"\09match %s ~ %s\0A\00"
@.str.2 = [2 x i8] c"*\00"
define i32 @hostmatch(i8* %0, i8* %1) {
%3 = tail call i32 @dbg_printf(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 1100, i32 2048, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1)
%4 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %56, label %6
6: ; preds = %2
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %6, %50
%10 = phi i8 [ %54, %50 ], [ %7, %6 ]
%11 = phi i32 [ %52, %50 ], [ 0, %6 ]
%12 = phi i8* [ %53, %50 ], [ %1, %6 ]
%13 = phi i8* [ %51, %50 ], [ %0, %6 ]
%14 = load i8, i8* %12
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %22
16: ; preds = %50, %9, %6
%17 = phi i8* [ %1, %6 ], [ %12, %9 ], [ %53, %50 ]
%18 = phi i8 [ 0, %6 ], [ %10, %9 ], [ 0, %50 ]
%19 = load i8, i8* %17
%20 = icmp eq i8 %18, %19
%21 = zext i1 %20 to i32
br label %56
22: ; preds = %9
%23 = sext i8 %14 to i32
switch i32 %23, label %34 [
i32 42, label %24
i32 63, label %30
]
24: ; preds = %22, %27
%25 = phi i8 [ %29, %27 ], [ %10, %22 ]
%26 = phi i8* [ %28, %27 ], [ %13, %22 ]
switch i8 %25, label %27 [
i8 46, label %50
i8 0, label %50
]
27: ; preds = %24
%28 = getelementptr inbounds i8, i8* %26, i64 1
%29 = load i8, i8* %28
br label %24
30: ; preds = %22
%31 = icmp eq i8 %10, 46
br i1 %31, label %56, label %32
32: ; preds = %30
%33 = getelementptr inbounds i8, i8* %13, i64 1
br label %50
34: ; preds = %22
%35 = icmp eq i32 %11, 0
br i1 %35, label %43, label %36
36: ; preds = %34
%37 = tail call i32 @tolower(i8 signext %10)
%38 = load i8, i8* %12
%39 = tail call i32 @tolower(i8 signext %38)
%40 = icmp eq i32 %37, %39
br i1 %40, label %41, label %56
41: ; preds = %36
%42 = load i8, i8* %12
br label %45
43: ; preds = %34
%44 = icmp eq i8 %10, %14
br i1 %44, label %45, label %56
45: ; preds = %41, %43
%46 = phi i8 [ %42, %41 ], [ %10, %43 ]
%47 = icmp eq i8 %46, 46
%48 = select i1 %47, i32 1, i32 %11
%49 = getelementptr inbounds i8, i8* %13, i64 1
br label %50
50: ; preds = %24, %24, %45, %32
%51 = phi i8* [ %49, %45 ], [ %33, %32 ], [ %26, %24 ], [ %26, %24 ]
%52 = phi i32 [ %48, %45 ], [ %11, %32 ], [ 1, %24 ], [ 1, %24 ]
%53 = getelementptr inbounds i8, i8* %12, i64 1
%54 = load i8, i8* %51
%55 = icmp eq i8 %54, 0
br i1 %55, label %16, label %9
56: ; preds = %43, %36, %30, %2, %16
%57 = phi i32 [ %21, %16 ], [ 1, %2 ], [ 0, %30 ], [ 0, %36 ], [ 0, %43 ]
ret i32 %57
}