#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__ HashGet(char *);
int HashGetInt(char *);
int /*<<< orphan*/ printf(char *, char *, int);
scalar_t__ strcmp(char const *, char *);
int ConfigIsForVirtualhost(const char *host, int port, int verbose) {
  char *current_host;
  int current_port;
  current_host = (char *)HashGet("SERVER_IP");
  current_port = HashGetInt("SERVER_PORT");
  if (current_host != NULL && host != NULL &&
      (strcmp(host, current_host) == 0 || strcmp(host, "*") == 0))
    if (current_port == 0 || port == current_port) {
      if (verbose >= 2)
        (void)printf("--- Apply restriction for virtualhost '%s:%i' ---\n",
                     current_host, current_port);
      return (1);
    }
  return (0);
}


x86 assembly (clang, -O0):
<ConfigIsForVirtualhost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
lea    0xea7(%rip),%rdi
call   1060 <HashGet@plt>
mov    %rax,-0x20(%rbp)
lea    0xea1(%rip),%rdi
call   1030 <HashGetInt@plt>
mov    %eax,-0x24(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11fc <ConfigIsForVirtualhost+0xbc>
cmpq   $0x0,-0x10(%rbp)
je     11fc <ConfigIsForVirtualhost+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11b8 <ConfigIsForVirtualhost+0x78>
mov    -0x10(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11fc <ConfigIsForVirtualhost+0xbc>
cmpl   $0x0,-0x24(%rbp)
je     11ce <ConfigIsForVirtualhost+0x8e>
mov    -0x14(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    11f7 <ConfigIsForVirtualhost+0xb7>
cmpl   $0x2,-0x18(%rbp)
jl     11eb <ConfigIsForVirtualhost+0xab>
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    0xe32(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1203 <ConfigIsForVirtualhost+0xc3>
jmp    11fc <ConfigIsForVirtualhost+0xbc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConfigIsForVirtualhost>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r12d
mov    %rdi,%rbx
lea    0xea5(%rip),%rdi
call   1060 <HashGet@plt>
mov    %rax,%rbp
lea    0xea0(%rip),%rdi
call   1030 <HashGetInt@plt>
xor    %r13d,%r13d
test   %rbx,%rbx
je     11cb <ConfigIsForVirtualhost+0x8b>
test   %rbp,%rbp
je     11cb <ConfigIsForVirtualhost+0x8b>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11a3 <ConfigIsForVirtualhost+0x63>
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11cb <ConfigIsForVirtualhost+0x8b>
test   %r15d,%r15d
je     11ad <ConfigIsForVirtualhost+0x6d>
cmp    %r12d,%r15d
jne    11cb <ConfigIsForVirtualhost+0x8b>
mov    $0x1,%r13d
cmp    $0x2,%r14d
jl     11cb <ConfigIsForVirtualhost+0x8b>
lea    0xe58(%rip),%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1040 <printf@plt>
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"SERVER_IP\00"
@.str.1 = [12 x i8] c"SERVER_PORT\00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [51 x i8] c"--- Apply restriction for virtualhost '%s:%i' ---\0A\00"
define i32 @ConfigIsForVirtualhost(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = call i64 @HashGet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %8
%12 = call i32 @HashGetInt(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i32 %12, i32* %9
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %43
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %43
18: ; preds = %15
%19 = load i8*, i8** %5
%20 = load i8*, i8** %8
%21 = call i64 @strcmp(i8* %19, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %43
27: ; preds = %23, %18
%28 = load i32, i32* %9
%29 = icmp eq i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = load i32, i32* %6
%32 = load i32, i32* %9
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %42
34: ; preds = %30, %27
%35 = load i32, i32* %7
%36 = icmp sge i32 %35, 2
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i8*, i8** %8
%39 = load i32, i32* %9
%40 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %38, i32 %39)
br label %41
41: ; preds = %37, %34
store i32 1, i32* %4
br label %44
42: ; preds = %30
br label %43
43: ; preds = %42, %23, %15, %3
store i32 0, i32* %4
br label %44
44: ; preds = %43, %41
%45 = load i32, i32* %4
ret i32 %45
}

LLVM IR (-O2):
@.str = [10 x i8] c"SERVER_IP\00"
@.str.1 = [12 x i8] c"SERVER_PORT\00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [51 x i8] c"--- Apply restriction for virtualhost '%s:%i' ---\0A\00"
define i32 @ConfigIsForVirtualhost(i8* %0, i32 %1, i32 %2) {
%4 = tail call i64 @HashGet(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @HashGetInt(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp ne i64 %4, 0
%8 = icmp ne i8* %0, null
%9 = and i1 %8, %7
br i1 %9, label %10, label %24
10: ; preds = %3
%11 = tail call i64 @strcmp(i8* %0, i8* %5)
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13, %10
%17 = icmp eq i32 %6, 0
%18 = icmp eq i32 %6, %1
%19 = or i1 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = icmp sgt i32 %2, 1
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.3, i64 0, i64 0), i8* %5, i32 %6)
br label %24
24: ; preds = %3, %13, %16, %20, %22
%25 = phi i32 [ 1, %22 ], [ 1, %20 ], [ 0, %16 ], [ 0, %13 ], [ 0, %3 ]
ret i32 %25
}