#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;
};
typedef int /*<<< orphan*/ socklen_t;
typedef enum nss_status { ____Placeholder_nss_status } nss_status;

/* Variables and functions */
int AF_INET6;
int NSS_STATUS_NOTFOUND;
int inject(char *);
enum nss_status _nss_inject_gethostbyaddr_r(const char *address, socklen_t len,
                                            int family, struct hostent *result,
                                            char *buffer, size_t buflen,
                                            int *errnop, int *h_errnop) {
  if (family != AF_INET6)
    return NSS_STATUS_NOTFOUND;
  return inject("gethostbyaddr");
}


x86 assembly (clang, -O0):
<_nss_inject_gethostbyaddr_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2ea8(%rip),%rcx
cmp    (%rcx),%eax
je     1159 <_nss_inject_gethostbyaddr_r+0x49>
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1168 <_nss_inject_gethostbyaddr_r+0x58>
lea    0xea0(%rip),%rdi
call   1030 <inject@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_nss_inject_gethostbyaddr_r>:
mov    0x2ed1(%rip),%rax
cmp    %edx,(%rax)
jne    1127 <_nss_inject_gethostbyaddr_r+0x17>
lea    0xede(%rip),%rdi
jmp    1030 <inject@plt>
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
%struct.hostent = type { i32 }
@AF_INET6 = global i32 0
@NSS_STATUS_NOTFOUND = global i32 0
@.str = [14 x i8] c"gethostbyaddr\00"
define i32 @_nss_inject_gethostbyaddr_r(i8* %0, i32 %1, i32 %2, %struct.hostent* %3, i8* %4, i64 %5, i32* %6, i32* %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.hostent*
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i32*
%17 = alloca i32*
store i8* %0, i8** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store %struct.hostent* %3, %struct.hostent** %13
store i8* %4, i8** %14
store i64 %5, i64* %15
store i32* %6, i32** %16
store i32* %7, i32** %17
%18 = load i32, i32* %12
%19 = load i32, i32* @AF_INET6
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %8
%22 = load i32, i32* @NSS_STATUS_NOTFOUND
store i32 %22, i32* %9
br label %25
23: ; preds = %8
%24 = call i32 @inject(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 %24, i32* %9
br label %25
25: ; preds = %23, %21
%26 = load i32, i32* %9
ret i32 %26
}

LLVM IR (-O2):
%struct.hostent = type { i32 }
@AF_INET6 = global i32 0
@NSS_STATUS_NOTFOUND = global i32 0
@.str = [14 x i8] c"gethostbyaddr\00"
define i32 @_nss_inject_gethostbyaddr_r(i8* nocapture readnone %0, i32 %1, i32 %2, %struct.hostent* nocapture readnone %3, i8* nocapture readnone %4, i64 %5, i32* nocapture readnone %6, i32* nocapture readnone %7) {
%9 = load i32, i32* @AF_INET6
%10 = icmp eq i32 %9, %2
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = load i32, i32* @NSS_STATUS_NOTFOUND
br label %15
13: ; preds = %8
%14 = tail call i32 @inject(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ %12, %11 ], [ %14, %13 ]
ret i32 %16
}