#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__ Curl_raw_equal(char const *, char const *);
int hostmatch(char const *, char const *);
int Tool_Curl_cert_hostcheck(const char *match_pattern, const char *hostname) {
  if (!match_pattern || !*match_pattern || !hostname || !*hostname)
    return 0;
  if (Curl_raw_equal(hostname, match_pattern))
    return 1;
  if (hostmatch(hostname, match_pattern) == 1)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<Tool_Curl_cert_hostcheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1160 <Tool_Curl_cert_hostcheck+0x40>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1160 <Tool_Curl_cert_hostcheck+0x40>
cmpq   $0x0,-0x18(%rbp)
je     1160 <Tool_Curl_cert_hostcheck+0x40>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116c <Tool_Curl_cert_hostcheck+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    11b8 <Tool_Curl_cert_hostcheck+0x98>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <Curl_raw_equal@plt>
cmp    $0x0,%rax
je     118f <Tool_Curl_cert_hostcheck+0x6f>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <Tool_Curl_cert_hostcheck+0x98>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <hostmatch@plt>
cmp    $0x1,%eax
jne    11b1 <Tool_Curl_cert_hostcheck+0x91>
movl   $0x1,-0x4(%rbp)
jmp    11b8 <Tool_Curl_cert_hostcheck+0x98>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Tool_Curl_cert_hostcheck>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
test   %rdi,%rdi
je     116e <Tool_Curl_cert_hostcheck+0x4e>
mov    %rsi,%r14
test   %rsi,%rsi
je     116e <Tool_Curl_cert_hostcheck+0x4e>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     116e <Tool_Curl_cert_hostcheck+0x4e>
cmpb   $0x0,(%r14)
je     116e <Tool_Curl_cert_hostcheck+0x4e>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <Curl_raw_equal@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    116e <Tool_Curl_cert_hostcheck+0x4e>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <hostmatch@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @Tool_Curl_cert_hostcheck(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 = icmp ne i8* %6, null
br i1 %7, label %8, label %19
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i8*, i8** %5
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %15, %12, %8, %2
store i32 0, i32* %3
br label %33
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = load i8*, i8** %4
%23 = call i64 @Curl_raw_equal(i8* %21, i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 1, i32* %3
br label %33
26: ; preds = %20
%27 = load i8*, i8** %5
%28 = load i8*, i8** %4
%29 = call i32 @hostmatch(i8* %27, i8* %28)
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %32
31: ; preds = %26
store i32 1, i32* %3
br label %33
32: ; preds = %26
store i32 0, i32* %3
br label %33
33: ; preds = %32, %31, %25, %19
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @Tool_Curl_cert_hostcheck(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %19, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp ne i8 %5, 0
%7 = icmp ne i8* %1, null
%8 = and i1 %7, %6
br i1 %8, label %9, label %19
9: ; preds = %4
%10 = load i8, i8* %1
%11 = icmp eq i8 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = tail call i64 @Curl_raw_equal(i8* %1, i8* %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = tail call i32 @hostmatch(i8* %1, i8* %0)
%17 = icmp eq i32 %16, 1
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %15, %12, %2, %4, %9
%20 = phi i32 [ 0, %9 ], [ 0, %4 ], [ 0, %2 ], [ 1, %12 ], [ %18, %15 ]
ret i32 %20
}