#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*/ strcmp(char const *, char const *);
int cert_hostcheck(const char *pattern, const char *hostname) {
  if (!hostname || !pattern || !*hostname || !*pattern)
    return 0;
  if (!strcmp(hostname, pattern))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<cert_hostcheck>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1150 <cert_hostcheck+0x40>
cmpq   $0x0,-0x10(%rbp)
je     1150 <cert_hostcheck+0x40>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1150 <cert_hostcheck+0x40>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    115c <cert_hostcheck+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    1185 <cert_hostcheck+0x75>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    117e <cert_hostcheck+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    1185 <cert_hostcheck+0x75>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cert_hostcheck>:
push   %rax
xor    %eax,%eax
test   %rdi,%rdi
je     113e <cert_hostcheck+0x2e>
test   %rsi,%rsi
je     113e <cert_hostcheck+0x2e>
cmpb   $0x0,(%rsi)
je     113e <cert_hostcheck+0x2e>
mov    %rdi,%rcx
cmpb   $0x0,(%rdi)
je     113e <cert_hostcheck+0x2e>
mov    %rsi,%rdi
mov    %rcx,%rsi
call   1030 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
pop    %rcx
ret

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

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