#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 hostent {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gethostbyaddr_r(char const *, int, int, struct hostent *,
                                   char *, size_t, struct hostent **, int *);
int __gnat_safe_gethostbyaddr(const char *addr, int len, int type,
                              struct hostent *ret, char *buf, size_t buflen,
                              int *h_errnop) {
  struct hostent *rh;
  int ri;
  (void)gethostbyaddr_r(addr, len, type, ret, buf, buflen, &rh, h_errnop);
  ri = (rh == NULL) ? -1 : 0;
  return ri;
}


x86 assembly (clang, -O0):
<__gnat_safe_gethostbyaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    0x10(%rbp),%rax
lea    -0x30(%rbp),%r10
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <gethostbyaddr_r@plt>
mov    -0x30(%rbp),%rdx
xor    %eax,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__gnat_safe_gethostbyaddr>:
push   %rax
mov    %rsp,%rax
push   0x10(%rsp)
push   %rax
call   1030 <gethostbyaddr_r@plt>
add    $0x10,%rsp
cmpq   $0x1,(%rsp)
sbb    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.hostent = type { i32 }
define i32 @__gnat_safe_gethostbyaddr(i8* %0, i32 %1, i32 %2, %struct.hostent* %3, i8* %4, i64 %5, i32* %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.hostent*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i32*
%15 = alloca %struct.hostent*
%16 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store %struct.hostent* %3, %struct.hostent** %11
store i8* %4, i8** %12
store i64 %5, i64* %13
store i32* %6, i32** %14
%17 = load i8*, i8** %8
%18 = load i32, i32* %9
%19 = load i32, i32* %10
%20 = load %struct.hostent*, %struct.hostent** %11
%21 = load i8*, i8** %12
%22 = load i64, i64* %13
%23 = load i32*, i32** %14
%24 = call i32 @gethostbyaddr_r(i8* %17, i32 %18, i32 %19, %struct.hostent* %20, i8* %21, i64 %22, %struct.hostent** %15, i32* %23)
%25 = load %struct.hostent*, %struct.hostent** %15
%26 = icmp eq %struct.hostent* %25, null
%27 = zext i1 %26 to i64
%28 = select i1 %26, i32 -1, i32 0
store i32 %28, i32* %16
%29 = load i32, i32* %16
ret i32 %29
}

LLVM IR (-O2):
%struct.hostent = type { i32 }
define i32 @__gnat_safe_gethostbyaddr(i8* %0, i32 %1, i32 %2, %struct.hostent* %3, i8* %4, i64 %5, i32* %6) {
%8 = alloca %struct.hostent*
%9 = bitcast %struct.hostent** %8 to i8*
%10 = call i32 @gethostbyaddr_r(i8* %0, i32 %1, i32 %2, %struct.hostent* %3, i8* %4, i64 %5, %struct.hostent** %8, i32* %6)
%11 = load %struct.hostent*, %struct.hostent** %8
%12 = icmp eq %struct.hostent* %11, null
%13 = sext i1 %12 to i32
ret i32 %13
}