#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ u_long;
typedef int /*<<< orphan*/ u_int;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct sockaddr_in {
  scalar_t__ sin_family;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_zero;
  scalar_t__ sin_port;
};
struct protoent {
  int dummy;
};
struct hostent {
  scalar_t__ h_addrtype;
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ h_addr;
};
typedef int /*<<< orphan*/ caddr_t;
struct TYPE_3__ {
  int /*<<< orphan*/ re_errno;
};
struct TYPE_4__ {
  TYPE_1__ cf_error;
  int /*<<< orphan*/ cf_stat;
};
typedef int /*<<< orphan*/ CLIENT;

/* Variables and functions */
scalar_t__ AF_INET;
int /*<<< orphan*/ CLSET_TIMEOUT;
int /*<<< orphan*/ EAFNOSUPPORT;
int RPC_ANYSOCK;
int /*<<< orphan*/ RPC_SYSTEMERROR;
int /*<<< orphan*/ RPC_UNKNOWNHOST;
int /*<<< orphan*/ bcopy(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(int /*<<< orphan*/, int);
int /*<<< orphan*/ clnt_control(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                int /*<<< orphan*/);
int /*<<< orphan*/ *clntaudp_create(struct sockaddr_in *, int /*<<< orphan*/,
                                    int /*<<< orphan*/, struct timeval, int *,
                                    int /*<<< orphan*/);
struct hostent *gethostbyname(char *);
TYPE_2__ rpc_createerr;
CLIENT *clnt_acreate(char *hostname, u_long prog, u_long vers, u_int numasync) {
  struct hostent *h;
  struct protoent *p;
  struct sockaddr_in sin;
  int sock;
  struct timeval tv;
  CLIENT *client;
  h = gethostbyname(hostname);
  if (h == NULL) {
    rpc_createerr.cf_stat = RPC_UNKNOWNHOST;
    return (NULL);
  }
  if (h->h_addrtype != AF_INET) {
    rpc_createerr.cf_stat = RPC_SYSTEMERROR;
    rpc_createerr.cf_error.re_errno = EAFNOSUPPORT;
    return (NULL);
  }
  sin.sin_family = h->h_addrtype;
  sin.sin_port = 0;
  bzero(sin.sin_zero, sizeof(sin.sin_zero));
  bcopy(h->h_addr, (char *)&sin.sin_addr, h->h_length);
  sock = RPC_ANYSOCK;
  tv.tv_sec = 5;
  tv.tv_usec = 0;
  client = clntaudp_create(&sin, prog, vers, tv, &sock, numasync);
  if (client == NULL) {
    return (NULL);
  }
  tv.tv_sec = 25;
  clnt_control(client, CLSET_TIMEOUT, (caddr_t)&tv);
  return (client);
}


x86 assembly (clang, -O0):
<clnt_acreate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <gethostbyname@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    119d <clnt_acreate+0x4d>
mov    0x2e3c(%rip),%rax
mov    (%rax),%ecx
mov    0x2e63(%rip),%rax
mov    %ecx,0x4(%rax)
movq   $0x0,-0x8(%rbp)
jmp    129f <clnt_acreate+0x14f>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2e35(%rip),%rcx
cmp    (%rcx),%rax
je     11e6 <clnt_acreate+0x96>
mov    0x2e1d(%rip),%rax
mov    (%rax),%ecx
mov    0x2e2c(%rip),%rax
mov    %ecx,0x4(%rax)
mov    0x2de2(%rip),%rax
mov    (%rax),%ecx
mov    0x2e19(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    129f <clnt_acreate+0x14f>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x3c(%rbp),%edi
mov    $0x4,%esi
call   1070 <bzero@plt>
mov    -0x28(%rbp),%rax
mov    0xc(%rax),%edi
lea    -0x48(%rbp),%rsi
add    $0x8,%rsi
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%edx
call   1060 <bcopy@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
movl   $0x5,-0x60(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%eax
mov    -0x60(%rbp),%ecx
mov    -0x58(%rbp),%r8
lea    -0x48(%rbp),%rdi
lea    -0x4c(%rbp),%r9
mov    %eax,(%rsp)
call   1040 <clntaudp_create@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1278 <clnt_acreate+0x128>
movq   $0x0,-0x8(%rbp)
jmp    129f <clnt_acreate+0x14f>
movl   $0x19,-0x60(%rbp)
mov    -0x68(%rbp),%rdi
mov    0x2d2e(%rip),%rax
mov    (%rax),%esi
lea    -0x60(%rbp),%rax
mov    %eax,%edx
call   1030 <clnt_control@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clnt_acreate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r15d
call   1050 <gethostbyname@plt>
test   %rax,%rax
je     1211 <clnt_acreate+0xc1>
mov    %rax,%rbp
mov    (%rax),%rax
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%rax
jne    1226 <clnt_acreate+0xd6>
mov    %rax,0x20(%rsp)
movq   $0x0,0x30(%rsp)
mov    $0x4,%esi
call   1070 <bzero@plt>
mov    0x8(%rbp),%edx
mov    0xc(%rbp),%edi
lea    0x28(%rsp),%rsi
call   1060 <bcopy@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
movq   $0x0,0x18(%rsp)
mov    %ebx,(%rsp)
xor    %ebx,%ebx
lea    0x20(%rsp),%rdi
lea    0xc(%rsp),%r9
mov    %r15d,%esi
mov    %r14d,%edx
mov    $0x5,%ecx
xor    %r8d,%r8d
call   1040 <clntaudp_create@plt>
test   %rax,%rax
je     1246 <clnt_acreate+0xf6>
mov    %rax,%rbp
movl   $0x19,0x10(%rsp)
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %rbp,%rdi
call   1030 <clnt_control@plt>
mov    %rbp,%rbx
jmp    1246 <clnt_acreate+0xf6>
mov    0x2da8(%rip),%rax
mov    (%rax),%eax
mov    0x2dcf(%rip),%rcx
mov    %eax,0x4(%rcx)
jmp    1244 <clnt_acreate+0xf4>
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    0x2dba(%rip),%rcx
mov    %eax,0x4(%rcx)
mov    0x2d70(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rcx)
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { %struct.TYPE_3__, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.hostent = type { i64, i32, i32 }
%struct.protoent = type { i32 }
%struct.sockaddr_in = type { i64, i32, i32, i64 }
%struct.timeval = type { i32, i64 }
@RPC_UNKNOWNHOST = global i32 0
@rpc_createerr = global %struct.TYPE_4__ zeroinitializer
@AF_INET = global i64 0
@RPC_SYSTEMERROR = global i32 0
@EAFNOSUPPORT = global i32 0
@RPC_ANYSOCK = global i32 0
@CLSET_TIMEOUT = global i32 0
define i32* @clnt_acreate(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.hostent*
%11 = alloca %struct.protoent*
%12 = alloca %struct.sockaddr_in
%13 = alloca i32
%14 = alloca %struct.timeval
%15 = alloca i32*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%16 = load i8*, i8** %6
%17 = call %struct.hostent* @gethostbyname(i8* %16)
store %struct.hostent* %17, %struct.hostent** %10
%18 = load %struct.hostent*, %struct.hostent** %10
%19 = icmp eq %struct.hostent* %18, null
br i1 %19, label %20, label %22
20: ; preds = %4
%21 = load i32, i32* @RPC_UNKNOWNHOST
store i32 %21, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i32 0, i32 1)
store i32* null, i32** %5
br label %71
22: ; preds = %4
%23 = load %struct.hostent*, %struct.hostent** %10
%24 = getelementptr inbounds %struct.hostent, %struct.hostent* %23, i32 0, i32 0
%25 = load i64, i64* %24
%26 = load i64, i64* @AF_INET
%27 = icmp ne i64 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32, i32* @RPC_SYSTEMERROR
store i32 %29, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i32 0, i32 1)
%30 = load i32, i32* @EAFNOSUPPORT
store i32 %30, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i32 0, i32 0, i32 0)
store i32* null, i32** %5
br label %71
31: ; preds = %22
%32 = load %struct.hostent*, %struct.hostent** %10
%33 = getelementptr inbounds %struct.hostent, %struct.hostent* %32, i32 0, i32 0
%34 = load i64, i64* %33
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
store i64 %34, i64* %35
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 3
store i64 0, i64* %36
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
%38 = load i32, i32* %37
%39 = call i32 @bzero(i32 %38, i32 4)
%40 = load %struct.hostent*, %struct.hostent** %10
%41 = getelementptr inbounds %struct.hostent, %struct.hostent* %40, i32 0, i32 2
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%44 = bitcast i32* %43 to i8*
%45 = load %struct.hostent*, %struct.hostent** %10
%46 = getelementptr inbounds %struct.hostent, %struct.hostent* %45, i32 0, i32 1
%47 = load i32, i32* %46
%48 = call i32 @bcopy(i32 %42, i8* %44, i32 %47)
%49 = load i32, i32* @RPC_ANYSOCK
store i32 %49, i32* %13
%50 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i32 5, i32* %50
%51 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
store i64 0, i64* %51
%52 = load i32, i32* %7
%53 = load i32, i32* %8
%54 = load i32, i32* %9
%55 = bitcast %struct.timeval* %14 to { i32, i64 }*
%56 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %55, i32 0, i32 0
%57 = load i32, i32* %56
%58 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %55, i32 0, i32 1
%59 = load i64, i64* %58
%60 = call i32* @clntaudp_create(%struct.sockaddr_in* %12, i32 %52, i32 %53, i32 %57, i64 %59, i32* %13, i32 %54)
store i32* %60, i32** %15
%61 = load i32*, i32** %15
%62 = icmp eq i32* %61, null
br i1 %62, label %63, label %64
63: ; preds = %31
store i32* null, i32** %5
br label %71
64: ; preds = %31
%65 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i32 25, i32* %65
%66 = load i32*, i32** %15
%67 = load i32, i32* @CLSET_TIMEOUT
%68 = ptrtoint %struct.timeval* %14 to i32
%69 = call i32 @clnt_control(i32* %66, i32 %67, i32 %68)
%70 = load i32*, i32** %15
store i32* %70, i32** %5
br label %71
71: ; preds = %64, %63, %28, %20
%72 = load i32*, i32** %5
ret i32* %72
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { %struct.TYPE_3__, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.sockaddr_in = type { i64, i32, i32, i64 }
%struct.timeval = type { i32, i64 }
%struct.protoent = type { i32 }
%struct.hostent = type { i64, i32, i32 }
@RPC_UNKNOWNHOST = global i32 0
@rpc_createerr = global %struct.TYPE_4__ zeroinitializer
@AF_INET = global i64 0
@RPC_SYSTEMERROR = global i32 0
@EAFNOSUPPORT = global i32 0
@RPC_ANYSOCK = global i32 0
@CLSET_TIMEOUT = global i32 0
define i32* @clnt_acreate(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca %struct.timeval
%8 = bitcast %struct.sockaddr_in* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = bitcast %struct.timeval* %7 to i8*
%11 = tail call %struct.hostent* @gethostbyname(i8* %0)
%12 = icmp eq %struct.hostent* %11, null
br i1 %12, label %13, label %15
13: ; preds = %4
%14 = load i32, i32* @RPC_UNKNOWNHOST
store i32 %14, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 1)
br label %44
15: ; preds = %4
%16 = getelementptr inbounds %struct.hostent, %struct.hostent* %11, i64 0, i32 0
%17 = load i64, i64* %16
%18 = load i64, i64* @AF_INET
%19 = icmp eq i64 %17, %18
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = load i32, i32* @RPC_SYSTEMERROR
store i32 %21, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 1)
%22 = load i32, i32* @EAFNOSUPPORT
store i32 %22, i32* getelementptr inbounds (%struct.TYPE_4__, %struct.TYPE_4__* @rpc_createerr, i64 0, i32 0, i32 0)
br label %44
23: ; preds = %15
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i64 %17, i64* %24
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 3
store i64 0, i64* %25
%26 = tail call i32 @bzero(i32 undef, i32 4)
%27 = getelementptr inbounds %struct.hostent, %struct.hostent* %11, i64 0, i32 2
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
%30 = bitcast i32* %29 to i8*
%31 = getelementptr inbounds %struct.hostent, %struct.hostent* %11, i64 0, i32 1
%32 = load i32, i32* %31
%33 = call i32 @bcopy(i32 %28, i8* %30, i32 %32)
%34 = load i32, i32* @RPC_ANYSOCK
store i32 %34, i32* %6
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
store i64 0, i64* %35
%36 = call i32* @clntaudp_create(%struct.sockaddr_in* %5, i32 %1, i32 %2, i32 5, i64 0, i32* %6, i32 %3)
%37 = icmp eq i32* %36, null
br i1 %37, label %44, label %38
38: ; preds = %23
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
store i32 25, i32* %39
%40 = load i32, i32* @CLSET_TIMEOUT
%41 = ptrtoint %struct.timeval* %7 to i64
%42 = trunc i64 %41 to i32
%43 = call i32 @clnt_control(i32* %36, i32 %40, i32 %42)
br label %44
44: ; preds = %23, %38, %20, %13
%45 = phi i32* [ null, %13 ], [ null, %20 ], [ %36, %38 ], [ null, %23 ]
ret i32* %45
}