#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 */
typedef unsigned long uint32_t;
struct hostent {
  scalar_t__ *h_addr_list;
};

/* Variables and functions */
unsigned long INADDR_NONE;
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ memcpy(unsigned long *, char *, int);
uint32_t _vthttp_dntoip(char *host) {
  struct hostent *hent;
  char *addr;
  unsigned long lip;
  if ((hent = gethostbyname(host)) == NULL)
    return INADDR_NONE;
  addr = (char *)hent->h_addr_list[0];
  memcpy(&lip, addr, 4);
  return lip;
}


x86 assembly (clang, -O0):
<_vthttp_dntoip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <gethostbyname@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1156 <_vthttp_dntoip+0x36>
mov    0x2e9e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    117e <_vthttp_dntoip+0x5e>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vthttp_dntoip>:
push   %rbx
sub    $0x10,%rsp
call   1030 <gethostbyname@plt>
test   %rax,%rax
je     1149 <_vthttp_dntoip+0x29>
mov    (%rax),%rax
mov    (%rax),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%edx
call   1040 <memcpy@plt>
jmp    1150 <_vthttp_dntoip+0x30>
mov    0x2e98(%rip),%rbx
mov    (%rbx),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.hostent = type { i64* }
@INADDR_NONE = global i64 0
define i64 @_vthttp_dntoip(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca %struct.hostent*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call %struct.hostent* @gethostbyname(i8* %7)
store %struct.hostent* %8, %struct.hostent** %4
%9 = icmp eq %struct.hostent* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load i64, i64* @INADDR_NONE
store i64 %11, i64* %2
br label %22
12: ; preds = %1
%13 = load %struct.hostent*, %struct.hostent** %4
%14 = getelementptr inbounds %struct.hostent, %struct.hostent* %13, i32 0, i32 0
%15 = load i64*, i64** %14
%16 = getelementptr inbounds i64, i64* %15, i64 0
%17 = load i64, i64* %16
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %5
%19 = load i8*, i8** %5
%20 = call i32 @memcpy(i64* %6, i8* %19, i32 4)
%21 = load i64, i64* %6
store i64 %21, i64* %2
br label %22
22: ; preds = %12, %10
%23 = load i64, i64* %2
ret i64 %23
}

LLVM IR (-O2):
%struct.hostent = type { i64* }
@INADDR_NONE = global i64 0
define i64 @_vthttp_dntoip(i8* %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = tail call %struct.hostent* @gethostbyname(i8* %0)
%5 = icmp eq %struct.hostent* %4, null
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = getelementptr inbounds %struct.hostent, %struct.hostent* %4, i64 0, i32 0
%8 = load i64*, i64** %7
%9 = load i64, i64* %8
%10 = inttoptr i64 %9 to i8*
%11 = call i32 @memcpy(i64* %2, i8* %10, i32 4)
br label %12
12: ; preds = %1, %6
%13 = phi i64* [ %2, %6 ], [ @INADDR_NONE, %1 ]
%14 = load i64, i64* %13
ret i64 %14
}