#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*/ xdrproc_t;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct sockaddr_in {
  scalar_t__ sin_port;
};
struct pmaplist {
  int dummy;
};
typedef int /*<<< orphan*/ caddr_t;
typedef int /*<<< orphan*/ CLIENT;

/* Variables and functions */
scalar_t__ CLNT_CALL(int /*<<< orphan*/ *, int /*<<< orphan*/,
                     int /*<<< orphan*/, int /*<<< orphan*/ *,
                     int /*<<< orphan*/, int /*<<< orphan*/, struct timeval);
int /*<<< orphan*/ CLNT_DESTROY(int /*<<< orphan*/ *);
int /*<<< orphan*/ PMAPPORT;
int /*<<< orphan*/ PMAPPROC_DUMP;
int /*<<< orphan*/ PMAPPROG;
int /*<<< orphan*/ PMAPVERS;
scalar_t__ RPC_SUCCESS;
int /*<<< orphan*/ _(char *);
int /*<<< orphan*/ clnt_perror(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *clnttcp_create(struct sockaddr_in *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, int *, int, int);
scalar_t__ htons(int /*<<< orphan*/);
scalar_t__ xdr_pmaplist;
scalar_t__ xdr_void;
struct pmaplist *pmap_getmaps(struct sockaddr_in *address) {
  struct pmaplist *head = (struct pmaplist *)NULL;
  int _socket = -1;
  struct timeval minutetimeout;
  CLIENT *client;
  minutetimeout.tv_sec = 60;
  minutetimeout.tv_usec = 0;
  address->sin_port = htons(PMAPPORT);
  client = clnttcp_create(address, PMAPPROG, PMAPVERS, &_socket, 50, 500);
  if (client != (CLIENT *)NULL) {
    if (CLNT_CALL(client, PMAPPROC_DUMP, (xdrproc_t)xdr_void, NULL,
                  (xdrproc_t)xdr_pmaplist, (caddr_t)&head,
                  minutetimeout) != RPC_SUCCESS) {
      clnt_perror(client, _("pmap_getmaps rpc problem"));
    }
    CLNT_DESTROY(client);
  }
  address->sin_port = 0;
  return head;
}


x86 assembly (clang, -O0):
<pmap_getmaps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x3c,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
call   1030 <htons@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
mov    0x2e12(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rcx
mov    $0x32,%r8d
mov    $0x1f4,%r9d
call   1050 <clnttcp_create@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     125e <pmap_getmaps+0xfe>
mov    -0x30(%rbp),%rdi
mov    0x2e09(%rip),%rax
mov    (%rax),%esi
mov    0x2de8(%rip),%rax
mov    (%rax),%rax
mov    %eax,%edx
mov    0x2db4(%rip),%rax
mov    (%rax),%rax
mov    %eax,%r8d
lea    -0x10(%rbp),%rax
mov    %eax,%r9d
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x28(%rbp),%rax
mov    (%rax),%r10
mov    %r10,(%rsp)
mov    0x8(%rax),%rax
mov    %rax,0x8(%rsp)
call   1080 <CLNT_CALL@plt>
mov    0x2da3(%rip),%rcx
cmp    (%rcx),%rax
je     1255 <pmap_getmaps+0xf5>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xdbb(%rip),%rdi
call   1070 <_@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1040 <clnt_perror@plt>
mov    -0x30(%rbp),%rdi
call   1060 <CLNT_DESTROY@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pmap_getmaps>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%r14
movq   $0x0,0x20(%rsp)
movl   $0xffffffff,0x1c(%rsp)
ff
movl   $0x3c,0x28(%rsp)
movq   $0x0,0x30(%rsp)
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1030 <htons@plt>
mov    %rax,(%r14)
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
mov    0x2e1b(%rip),%rax
mov    (%rax),%edx
lea    0x1c(%rsp),%rcx
mov    %r14,%rdi
mov    $0x32,%r8d
mov    $0x1f4,%r9d
call   1050 <clnttcp_create@plt>
test   %rax,%rax
je     1235 <pmap_getmaps+0xd5>
mov    %rax,%rbx
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
mov    0x2df8(%rip),%rax
mov    (%rax),%edx
mov    0x2dc7(%rip),%rax
mov    (%rax),%r8d
lea    0x20(%rsp),%r9
movups 0x28(%rsp),%xmm0
movups %xmm0,(%rsp)
mov    %rbx,%rdi
xor    %ecx,%ecx
call   1080 <CLNT_CALL@plt>
mov    0x2dc5(%rip),%rcx
cmp    (%rcx),%rax
je     1226 <pmap_getmaps+0xc6>
lea    0xde9(%rip),%rdi
call   1070 <_@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <clnt_perror@plt>
mov    %rbx,%rdi
call   1060 <CLNT_DESTROY@plt>
mov    0x20(%rsp),%rax
jmp    1237 <pmap_getmaps+0xd7>
xor    %eax,%eax
movq   $0x0,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.pmaplist = type { i32 }
%struct.sockaddr_in = type { i64 }
%struct.timeval = type { i32, i64 }
@PMAPPORT = global i32 0
@PMAPPROG = global i32 0
@PMAPVERS = global i32 0
@PMAPPROC_DUMP = global i32 0
@xdr_void = global i64 0
@xdr_pmaplist = global i64 0
@RPC_SUCCESS = global i64 0
@.str = [25 x i8] c"pmap_getmaps rpc problem\00"
define %struct.pmaplist* @pmap_getmaps(%struct.sockaddr_in* %0) {
%2 = alloca %struct.sockaddr_in*
%3 = alloca %struct.pmaplist*
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = alloca i32*
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %2
store %struct.pmaplist* null, %struct.pmaplist** %3
store i32 -1, i32* %4
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
store i32 60, i32* %7
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
store i64 0, i64* %8
%9 = load i32, i32* @PMAPPORT
%10 = call i64 @htons(i32 %9)
%11 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i64 %10, i64* %12
%13 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%14 = load i32, i32* @PMAPPROG
%15 = load i32, i32* @PMAPVERS
%16 = call i32* @clnttcp_create(%struct.sockaddr_in* %13, i32 %14, i32 %15, i32* %4, i32 50, i32 500)
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %37
19: ; preds = %1
%20 = load i32*, i32** %6
%21 = load i32, i32* @PMAPPROC_DUMP
%22 = load i64, i64* @xdr_void
%23 = trunc i64 %22 to i32
%24 = load i64, i64* @xdr_pmaplist
%25 = trunc i64 %24 to i32
%26 = ptrtoint %struct.pmaplist** %3 to i32
%27 = call i64 @CLNT_CALL(i32* %20, i32 %21, i32 %23, i32* null, i32 %25, i32 %26, %struct.timeval* byval(%struct.timeval) align 8 %5)
%28 = load i64, i64* @RPC_SUCCESS
%29 = icmp ne i64 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %19
%31 = load i32*, i32** %6
%32 = call i32 @_(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @clnt_perror(i32* %31, i32 %32)
br label %34
34: ; preds = %30, %19
%35 = load i32*, i32** %6
%36 = call i32 @CLNT_DESTROY(i32* %35)
br label %37
37: ; preds = %34, %1
%38 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %38, i32 0, i32 0
store i64 0, i64* %39
%40 = load %struct.pmaplist*, %struct.pmaplist** %3
ret %struct.pmaplist* %40
}

LLVM IR (-O2):
%struct.pmaplist = type { i32 }
%struct.sockaddr_in = type { i64 }
%struct.timeval = type { i32, i64 }
@PMAPPORT = global i32 0
@PMAPPROG = global i32 0
@PMAPVERS = global i32 0
@PMAPPROC_DUMP = global i32 0
@xdr_void = global i64 0
@xdr_pmaplist = global i64 0
@RPC_SUCCESS = global i64 0
@.str = [25 x i8] c"pmap_getmaps rpc problem\00"
define %struct.pmaplist* @pmap_getmaps(%struct.sockaddr_in* %0) {
%2 = alloca %struct.pmaplist*
%3 = alloca i32
%4 = alloca %struct.timeval
%5 = bitcast %struct.pmaplist** %2 to i8*
store %struct.pmaplist* null, %struct.pmaplist** %2
%6 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%7 = bitcast %struct.timeval* %4 to i8*
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
store i32 60, i32* %8
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
store i64 0, i64* %9
%10 = load i32, i32* @PMAPPORT
%11 = tail call i64 @htons(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
store i64 %11, i64* %12
%13 = load i32, i32* @PMAPPROG
%14 = load i32, i32* @PMAPVERS
%15 = call i32* @clnttcp_create(%struct.sockaddr_in* %0, i32 %13, i32 %14, i32* %3, i32 50, i32 500)
%16 = icmp eq i32* %15, null
br i1 %16, label %34, label %17
17: ; preds = %1
%18 = load i32, i32* @PMAPPROC_DUMP
%19 = load i64, i64* @xdr_void
%20 = trunc i64 %19 to i32
%21 = load i64, i64* @xdr_pmaplist
%22 = trunc i64 %21 to i32
%23 = ptrtoint %struct.pmaplist** %2 to i64
%24 = trunc i64 %23 to i32
%25 = call i64 @CLNT_CALL(i32* %15, i32 %18, i32 %20, i32* null, i32 %22, i32 %24, %struct.timeval* byval(%struct.timeval) align 8 %4)
%26 = load i64, i64* @RPC_SUCCESS
%27 = icmp eq i64 %25, %26
br i1 %27, label %31, label %28
28: ; preds = %17
%29 = call i32 @_(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @clnt_perror(i32* %15, i32 %29)
br label %31
31: ; preds = %28, %17
%32 = call i32 @CLNT_DESTROY(i32* %15)
%33 = load %struct.pmaplist*, %struct.pmaplist** %2
br label %34
34: ; preds = %31, %1
%35 = phi %struct.pmaplist* [ %33, %31 ], [ null, %1 ]
store i64 0, i64* %12
ret %struct.pmaplist* %35
}