#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 */
struct in6_addr {
  int dummy;
};

/* Variables and functions */
int _ResolveAddress(char const *, unsigned int, struct in6_addr *);
int _ResolveAddressImmediate(char const *, unsigned int, struct in6_addr *);
scalar_t__ strcmp(char const *, char *);
int ResolveAddress(const char *DomainName, unsigned AllowedAddress,
                   int SkipResolver, struct in6_addr *resultIP) {
  if (!DomainName || !DomainName[0])
    return 0;
  if (SkipResolver && strcmp(DomainName, "localhost"))
    return _ResolveAddressImmediate(DomainName, AllowedAddress, resultIP);
  else
    return _ResolveAddress(DomainName, AllowedAddress, resultIP);
}


x86 assembly (clang, -O0):
<ResolveAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115e <ResolveAddress+0x2e>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116a <ResolveAddress+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <ResolveAddress+0x89>
cmpl   $0x0,-0x18(%rbp)
je     11a6 <ResolveAddress+0x76>
mov    -0x10(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11a6 <ResolveAddress+0x76>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1050 <_ResolveAddressImmediate@plt>
mov    %eax,-0x4(%rbp)
jmp    11b9 <ResolveAddress+0x89>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1030 <_ResolveAddress@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ResolveAddress>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     116f <ResolveAddress+0x3f>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     116f <ResolveAddress+0x3f>
mov    %rcx,%r14
mov    %esi,%ebp
test   %edx,%edx
je     1176 <ResolveAddress+0x46>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1176 <ResolveAddress+0x46>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <_ResolveAddressImmediate@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <_ResolveAddress@plt>

LLVM IR (-O0):
%struct.in6_addr = type { i32 }
@.str = [10 x i8] c"localhost\00"
define i32 @ResolveAddress(i8* %0, i32 %1, i32 %2, %struct.in6_addr* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.in6_addr*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store %struct.in6_addr* %3, %struct.in6_addr** %9
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %12, %4
store i32 0, i32* %5
br label %35
18: ; preds = %12
%19 = load i32, i32* %8
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i8*, i8** %6
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8*, i8** %6
%27 = load i32, i32* %7
%28 = load %struct.in6_addr*, %struct.in6_addr** %9
%29 = call i32 @_ResolveAddressImmediate(i8* %26, i32 %27, %struct.in6_addr* %28)
store i32 %29, i32* %5
br label %35
30: ; preds = %21, %18
%31 = load i8*, i8** %6
%32 = load i32, i32* %7
%33 = load %struct.in6_addr*, %struct.in6_addr** %9
%34 = call i32 @_ResolveAddress(i8* %31, i32 %32, %struct.in6_addr* %33)
store i32 %34, i32* %5
br label %35
35: ; preds = %30, %25, %17
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
%struct.in6_addr = type { i32 }
@.str = [10 x i8] c"localhost\00"
define i32 @ResolveAddress(i8* %0, i32 %1, i32 %2, %struct.in6_addr* %3) {
%5 = icmp eq i8* %0, null
br i1 %5, label %18, label %6
6: ; preds = %4
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %6
%10 = icmp eq i32 %2, 0
br i1 %10, label %16, label %11
11: ; preds = %9
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @_ResolveAddressImmediate(i8* %0, i32 %1, %struct.in6_addr* %3)
br label %18
16: ; preds = %11, %9
%17 = tail call i32 @_ResolveAddress(i8* %0, i32 %1, %struct.in6_addr* %3)
br label %18
18: ; preds = %4, %6, %16, %14
%19 = phi i32 [ %15, %14 ], [ %17, %16 ], [ 0, %6 ], [ 0, %4 ]
ret i32 %19
}