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

/* Variables and functions */
struct hostent *gethostbyname(char const *);
scalar_t__ iruserok(int /*<<< orphan*/, int, char const *, char const *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int ruserok(const char *rhost, int superuser, const char *ruser,
            const char *luser) {
  struct hostent *hp;
  u_long addr;
  char **ap;
  hp = gethostbyname(rhost);
  if (hp == NULL)
    return -1;
  memcpy(&addr, hp->h_addr, sizeof(addr));
  if (iruserok(addr, superuser, ruser, luser) == 0)
    return (0);
  return (-1);
}


x86 assembly (clang, -O0):
<ruserok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    116b <ruserok+0x3b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11af <ruserok+0x7f>
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
lea    -0x34(%rbp),%rdi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x34(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <iruserok@plt>
cmp    $0x0,%rax
jne    11a8 <ruserok+0x78>
movl   $0x0,-0x4(%rbp)
jmp    11af <ruserok+0x7f>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ruserok>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%ebp
call   1030 <gethostbyname@plt>
test   %rax,%rax
je     1173 <ruserok+0x43>
mov    (%rax),%esi
lea    0xc(%rsp),%rdi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    0xc(%rsp),%edi
mov    %ebp,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1050 <iruserok@plt>
neg    %rax
sbb    %eax,%eax
jmp    1178 <ruserok+0x48>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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