#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 scalar_t__ u_long;
struct hostent {
  int /*<<< orphan*/ h_addr;
};

/* Variables and functions */
struct hostent *gethostbyname(char *);
scalar_t__ inet_addr(char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ memcmp(scalar_t__ *, int /*<<< orphan*/, int);
int __icheckhost(u_long raddr, register char *lhost) {
  register struct hostent *hp;
  register u_long laddr;
  register char **pp;
  if (isdigit(*lhost) && (long)(laddr = inet_addr(lhost)) != -1)
    return (raddr == laddr);
  hp = gethostbyname(lhost);
  if (hp == NULL)
    return 0;
  if (!memcmp(&raddr, hp->h_addr, sizeof(u_long)))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<__icheckhost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1195 <__icheckhost+0x55>
mov    -0x18(%rbp),%rdi
call   1050 <inet_addr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0xffffffffffffffff,%rax
je     1195 <__icheckhost+0x55>
mov    -0x10(%rbp),%rax
cmp    -0x28(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11e9 <__icheckhost+0xa9>
mov    -0x18(%rbp),%rdi
call   1060 <gethostbyname@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b9 <__icheckhost+0x79>
movl   $0x0,-0x4(%rbp)
jmp    11e9 <__icheckhost+0xa9>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdi
mov    $0x8,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
jne    11e2 <__icheckhost+0xa2>
movl   $0x1,-0x4(%rbp)
jmp    11e9 <__icheckhost+0xa9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__icheckhost>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdi,(%rsp)
movsbl (%rsi),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     116e <__icheckhost+0x2e>
mov    %rbx,%rdi
call   1050 <inet_addr@plt>
cmp    $0xffffffffffffffff,%rax
je     116e <__icheckhost+0x2e>
cmp    %r14,%rax
jmp    118c <__icheckhost+0x4c>
mov    %rbx,%rdi
call   1060 <gethostbyname@plt>
test   %rax,%rax
je     1191 <__icheckhost+0x51>
mov    (%rax),%esi
mov    %rsp,%rdi
mov    $0x8,%edx
call   1040 <memcmp@plt>
test   %eax,%eax
sete   %al
jmp    1193 <__icheckhost+0x53>
xor    %eax,%eax
movzbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.hostent = type { i32 }
define i32 @__icheckhost(i64 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
%6 = alloca %struct.hostent*
%7 = alloca i64
%8 = alloca i8**
store i64 %0, i64* %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = load i8, i8* %9
%11 = call i64 @isdigit(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %2
%14 = load i8*, i8** %5
%15 = call i64 @inet_addr(i8* %14)
store i64 %15, i64* %7
%16 = icmp ne i64 %15, -1
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = load i64, i64* %4
%19 = load i64, i64* %7
%20 = icmp eq i64 %18, %19
%21 = zext i1 %20 to i32
store i32 %21, i32* %3
br label %36
22: ; preds = %13, %2
%23 = load i8*, i8** %5
%24 = call %struct.hostent* @gethostbyname(i8* %23)
store %struct.hostent* %24, %struct.hostent** %6
%25 = load %struct.hostent*, %struct.hostent** %6
%26 = icmp eq %struct.hostent* %25, null
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 0, i32* %3
br label %36
28: ; preds = %22
%29 = load %struct.hostent*, %struct.hostent** %6
%30 = getelementptr inbounds %struct.hostent, %struct.hostent* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = call i32 @memcmp(i64* %4, i32 %31, i32 8)
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %28
store i32 1, i32* %3
br label %36
35: ; preds = %28
store i32 0, i32* %3
br label %36
36: ; preds = %35, %34, %27, %17
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
%struct.hostent = type { i32 }
define i32 @__icheckhost(i64 %0, i8* %1) {
%3 = alloca i64
store i64 %0, i64* %3
%4 = load i8, i8* %1
%5 = tail call i64 @isdigit(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = tail call i64 @inet_addr(i8* %1)
%9 = icmp eq i64 %8, -1
br i1 %9, label %12, label %10
10: ; preds = %7
%11 = icmp eq i64 %8, %0
br label %20
12: ; preds = %7, %2
%13 = tail call %struct.hostent* @gethostbyname(i8* %1)
%14 = icmp eq %struct.hostent* %13, null
br i1 %14, label %20, label %15
15: ; preds = %12
%16 = getelementptr inbounds %struct.hostent, %struct.hostent* %13, i64 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @memcmp(i64* %3, i32 %17, i32 8)
%19 = icmp eq i32 %18, 0
br label %20
20: ; preds = %15, %12, %10
%21 = phi i1 [ %11, %10 ], [ false, %12 ], [ %19, %15 ]
%22 = zext i1 %21 to i32
ret i32 %22
}