#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*/ rpcproc_t;
typedef int /*<<< orphan*/ CLIENT;

/* Variables and functions */
scalar_t__ CLNT_CALL(int /*<<< orphan*/ *, int /*<<< orphan*/,
                     int /*<<< orphan*/, int /*<<< orphan*/ *,
                     int /*<<< orphan*/, struct pmaplist **, struct timeval);
int /*<<< orphan*/ CLNT_DESTROY(int /*<<< orphan*/ *);
int /*<<< orphan*/ PMAPPORT;
scalar_t__ PMAPPROC_DUMP;
int /*<<< orphan*/ PMAPPROG;
int /*<<< orphan*/ PMAPVERS;
scalar_t__ RPC_SUCCESS;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ clnt_perror(int /*<<< orphan*/ *, char *);
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 = NULL;
  int sock = -1;
  struct timeval minutetimeout;
  CLIENT *client;
  assert(address != NULL);
  minutetimeout.tv_sec = 60;
  minutetimeout.tv_usec = 0;
  address->sin_port = htons(PMAPPORT);
  client = clnttcp_create(address, PMAPPROG, PMAPVERS, &sock, 50, 500);
  if (client != NULL) {
    if (CLNT_CALL(client, (rpcproc_t)PMAPPROC_DUMP, (xdrproc_t)xdr_void, NULL,
                  (xdrproc_t)xdr_pmaplist, &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    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
movl   $0x3c,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1030 <htons@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    0x2e21(%rip),%rax
mov    (%rax),%esi
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rcx
mov    $0x32,%r8d
mov    $0x1f4,%r9d
call   1060 <clnttcp_create@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1261 <pmap_getmaps+0x101>
mov    -0x30(%rbp),%rdi
mov    0x2df7(%rip),%rax
mov    (%rax),%rax
mov    %eax,%esi
mov    0x2dd3(%rip),%rax
mov    (%rax),%rax
mov    %eax,%edx
mov    0x2d9f(%rip),%rax
mov    (%rax),%rax
mov    %eax,%r8d
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x10(%rbp),%r9
lea    -0x28(%rbp),%rax
mov    (%rax),%r10
mov    %r10,(%rsp)
mov    0x8(%rax),%rax
mov    %rax,0x8(%rsp)
call   1080 <CLNT_CALL@plt>
mov    0x2d91(%rip),%rcx
cmp    (%rcx),%rax
je     1258 <pmap_getmaps+0xf8>
mov    -0x30(%rbp),%rdi
lea    0xdad(%rip),%rsi
call   1040 <clnt_perror@plt>
mov    -0x30(%rbp),%rdi
call   1070 <CLNT_DESTROY@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x40,%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
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
movl   $0x3c,0x28(%rsp)
movq   $0x0,0x30(%rsp)
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1030 <htons@plt>
mov    %rax,(%r14)
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
mov    0x2e0d(%rip),%rax
mov    (%rax),%edx
lea    0x1c(%rsp),%rcx
mov    %r14,%rdi
mov    $0x32,%r8d
mov    $0x1f4,%r9d
call   1060 <clnttcp_create@plt>
test   %rax,%rax
je     123c <pmap_getmaps+0xdc>
mov    %rax,%rbx
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
mov    0x2dea(%rip),%rax
mov    (%rax),%edx
mov    0x2db9(%rip),%rax
mov    (%rax),%r8d
movups 0x28(%rsp),%xmm0
movups %xmm0,(%rsp)
lea    0x20(%rsp),%r9
mov    %rbx,%rdi
xor    %ecx,%ecx
call   1080 <CLNT_CALL@plt>
mov    0x2db7(%rip),%rcx
cmp    (%rcx),%rax
je     122d <pmap_getmaps+0xcd>
lea    0xddb(%rip),%rsi
mov    %rbx,%rdi
call   1040 <clnt_perror@plt>
mov    %rbx,%rdi
call   1070 <CLNT_DESTROY@plt>
mov    0x20(%rsp),%rax
jmp    123e <pmap_getmaps+0xde>
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 i64 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 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%8 = icmp ne %struct.sockaddr_in* %7, null
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
store i32 60, i32* %11
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 1
store i64 0, i64* %12
%13 = load i32, i32* @PMAPPORT
%14 = call i64 @htons(i32 %13)
%15 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
store i64 %14, i64* %16
%17 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%18 = load i32, i32* @PMAPPROG
%19 = load i32, i32* @PMAPVERS
%20 = call i32* @clnttcp_create(%struct.sockaddr_in* %17, i32 %18, i32 %19, i32* %4, i32 50, i32 500)
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %40
23: ; preds = %1
%24 = load i32*, i32** %6
%25 = load i64, i64* @PMAPPROC_DUMP
%26 = trunc i64 %25 to i32
%27 = load i64, i64* @xdr_void
%28 = trunc i64 %27 to i32
%29 = load i64, i64* @xdr_pmaplist
%30 = trunc i64 %29 to i32
%31 = call i64 @CLNT_CALL(i32* %24, i32 %26, i32 %28, i32* null, i32 %30, %struct.pmaplist** %3, %struct.timeval* byval(%struct.timeval) align 8 %5)
%32 = load i64, i64* @RPC_SUCCESS
%33 = icmp ne i64 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %23
%35 = load i32*, i32** %6
%36 = call i32 @clnt_perror(i32* %35, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %34, %23
%38 = load i32*, i32** %6
%39 = call i32 @CLNT_DESTROY(i32* %38)
br label %40
40: ; preds = %37, %1
%41 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %41, i32 0, i32 0
store i64 0, i64* %42
%43 = load %struct.pmaplist*, %struct.pmaplist** %3
ret %struct.pmaplist* %43
}

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 i64 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 = icmp ne %struct.sockaddr_in* %0, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
store i32 60, i32* %11
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
store i64 0, i64* %12
%13 = load i32, i32* @PMAPPORT
%14 = tail call i64 @htons(i32 %13)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
store i64 %14, i64* %15
%16 = load i32, i32* @PMAPPROG
%17 = load i32, i32* @PMAPVERS
%18 = call i32* @clnttcp_create(%struct.sockaddr_in* %0, i32 %16, i32 %17, i32* %3, i32 50, i32 500)
%19 = icmp eq i32* %18, null
br i1 %19, label %35, label %20
20: ; preds = %1
%21 = load i64, i64* @PMAPPROC_DUMP
%22 = trunc i64 %21 to i32
%23 = load i64, i64* @xdr_void
%24 = trunc i64 %23 to i32
%25 = load i64, i64* @xdr_pmaplist
%26 = trunc i64 %25 to i32
%27 = call i64 @CLNT_CALL(i32* %18, i32 %22, i32 %24, i32* null, i32 %26, %struct.pmaplist** %2, %struct.timeval* byval(%struct.timeval) align 8 %4)
%28 = load i64, i64* @RPC_SUCCESS
%29 = icmp eq i64 %27, %28
br i1 %29, label %32, label %30
30: ; preds = %20
%31 = call i32 @clnt_perror(i32* %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %30, %20
%33 = call i32 @CLNT_DESTROY(i32* %18)
%34 = load %struct.pmaplist*, %struct.pmaplist** %2
br label %35
35: ; preds = %32, %1
%36 = phi %struct.pmaplist* [ %34, %32 ], [ null, %1 ]
store i64 0, i64* %15
ret %struct.pmaplist* %36
}