#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*/ byte_copy(char *, int, char *);
int dd(char *, char *, char *);
scalar_t__ dns_domain_equal(char *, char *);
int globalip(char *d, char ip[4]) {
  if (dns_domain_equal(d, "\011localhost\0")) {
    byte_copy(ip, 4, "\177\0\0\1");
    return 1;
  }
  if (dd(d, "", ip) == 4)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<globalip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <dns_domain_equal@plt>
cmp    $0x0,%rax
je     117b <globalip+0x4b>
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
lea    0xea2(%rip),%rdx
call   1030 <byte_copy@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ab <globalip+0x7b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe87(%rip),%rsi
call   1040 <dd@plt>
cmp    $0x4,%eax
jne    11a4 <globalip+0x74>
movl   $0x1,-0x4(%rbp)
jmp    11ab <globalip+0x7b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<globalip>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rsi
call   1050 <dns_domain_equal@plt>
test   %rax,%rax
je     1166 <globalip+0x36>
lea    0xeba(%rip),%rdx
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <byte_copy@plt>
mov    $0x1,%eax
jmp    1182 <globalip+0x52>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1040 <dd@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x4,%ecx
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"\09localhost\00\00"
@.str.1 = [5 x i8] c"\7F\00\00\01\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @globalip(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 = call i64 @dns_domain_equal(i8* %6, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = call i32 @byte_copy(i8* %10, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %19
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i8*, i8** %5
%15 = call i32 @dd(i8* %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = icmp eq i32 %15, 4
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 1, i32* %3
br label %19
18: ; preds = %12
store i32 0, i32* %3
br label %19
19: ; preds = %18, %17, %9
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [12 x i8] c"\09localhost\00\00"
@.str.1 = [5 x i8] c"\7F\00\00\01\00"
@.str.2 = [1 x i8] zeroinitializer
define i32 @globalip(i8* %0, i8* %1) {
%3 = tail call i64 @dns_domain_equal(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @byte_copy(i8* %1, i32 4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %11
7: ; preds = %2
%8 = tail call i32 @dd(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%9 = icmp eq i32 %8, 4
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %7, %5
%12 = phi i32 [ 1, %5 ], [ %10, %7 ]
ret i32 %12
}