#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_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ xdrproc_t;
typedef int u_long;
typedef int /*<<< orphan*/ u_int;
struct timeval {
  int tv_usec;
  scalar_t__ tv_sec;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct hostent {
  scalar_t__ h_addr;
};
typedef enum clnt_stat { ____Placeholder_clnt_stat } clnt_stat;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_UDP;
int RPC_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct hostent *gethostbyname(char *);
int pmap_getport(struct sockaddr_in *, int, int, int /*<<< orphan*/);
int pmap_rmtcall(struct sockaddr_in *, int, int, int, int /*<<< orphan*/,
                 char *, int /*<<< orphan*/, char *, struct timeval, int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ xdr_int;
int main(int argn, char *argc[]) {
  int run_mode = 0;
  int test_status = 1;
  int progNum = atoi(argc[2]);
  struct hostent *hp = NULL;
  struct sockaddr_in sin;
  enum clnt_stat cs;
  u_long port;
  struct timeval tv;
  int var_snd = 10;
  int var_rec = -1;
  if ((hp = gethostbyname(argc[1])) == NULL) {
    fprintf(stderr, "gethostbyname failed\n");
    exit(1);
  }
  sin.sin_family = AF_INET;
  sin.sin_addr.s_addr = *(u_int *)hp->h_addr;
  port = pmap_getport(&sin, progNum, 1, IPPROTO_UDP);
  tv.tv_sec = 0;
  tv.tv_usec = 100;
  if (run_mode) {
    printf("port : %d\n", port);
  }
  cs = pmap_rmtcall(&sin, progNum, 1, 1, (xdrproc_t)xdr_int, (char *)&var_snd,
                    (xdrproc_t)xdr_int, (char *)&var_rec, tv, &port);
  test_status = (cs == RPC_SUCCESS) ? 0 : 1;
  printf("%d\n", test_status);
  return test_status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x78,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0xa,-0x54(%rbp)
movl   $0xffffffff,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11f5 <main+0x85>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe1a(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%esi
mov    0x2da1(%rip),%rax
mov    (%rax),%ecx
lea    -0x38(%rbp),%rdi
mov    $0x1,%edx
call   1040 <pmap_getport@plt>
mov    %eax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0x64,-0x50(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1252 <main+0xe2>
mov    -0x40(%rbp),%esi
lea    0xdc9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
mov    0x2d84(%rip),%rax
mov    (%rax),%rax
mov    %eax,%r8d
lea    -0x54(%rbp),%r9
mov    0x2d73(%rip),%rax
mov    (%rax),%rax
mov    %eax,%ebx
lea    -0x58(%rbp),%r11
lea    -0x38(%rbp),%rdi
mov    $0x1,%ecx
lea    -0x50(%rbp),%r10
lea    -0x40(%rbp),%rax
mov    %ecx,%edx
mov    %ebx,(%rsp)
mov    %r11,0x8(%rsp)
mov    (%r10),%r11
mov    %r11,0x10(%rsp)
mov    0x8(%r10),%r10
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
call   1070 <pmap_rmtcall@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edx
mov    0x2d1f(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xd49(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
movl   $0xa,0x38(%rsp)
movl   $0xffffffff,0x34(%rsp)
ff
mov    0x8(%rbx),%rdi
call   1050 <gethostbyname@plt>
test   %rax,%rax
je     1258 <main+0xe8>
mov    0x2e3b(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x44(%rsp)
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
mov    0x2df5(%rip),%rax
mov    (%rax),%ecx
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <pmap_getport@plt>
mov    %eax,0x3c(%rsp)
movq   $0x0,0x50(%rsp)
movl   $0x64,0x48(%rsp)
mov    0x2deb(%rip),%rax
mov    (%rax),%r8d
movups 0x48(%rsp),%xmm0
movups %xmm0,0x10(%rsp)
lea    0x3c(%rsp),%rax
mov    %rax,0x20(%rsp)
lea    0x34(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %r8d,(%rsp)
lea    0x38(%rsp),%r9
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1070 <pmap_rmtcall@plt>
mov    0x2d9e(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%eax
setne  %bl
lea    0xdce(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    0xd98(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i64 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
@stderr = global i32 0
@.str = [22 x i8] c"gethostbyname failed\0A\00"
@AF_INET = global i32 0
@IPPROTO_UDP = global i32 0
@.str.1 = [11 x i8] c"port : %d\0A\00"
@xdr_int = global i64 0
@RPC_SUCCESS = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.hostent*
%10 = alloca %struct.sockaddr_in
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.timeval
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %8
store %struct.hostent* null, %struct.hostent** %9
store i32 10, i32* %14
store i32 -1, i32* %15
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call %struct.hostent* @gethostbyname(i8* %22)
store %struct.hostent* %23, %struct.hostent** %9
%24 = icmp eq %struct.hostent* %23, null
br i1 %24, label %25, label %29
25: ; preds = %2
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
%30 = load i32, i32* @AF_INET
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %30, i32* %31
%32 = load %struct.hostent*, %struct.hostent** %9
%33 = getelementptr inbounds %struct.hostent, %struct.hostent* %32, i32 0, i32 0
%34 = load i64, i64* %33
%35 = inttoptr i64 %34 to i32*
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%38 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %37, i32 0, i32 0
store i32 %36, i32* %38
%39 = load i32, i32* %8
%40 = load i32, i32* @IPPROTO_UDP
%41 = call i32 @pmap_getport(%struct.sockaddr_in* %10, i32 %39, i32 1, i32 %40)
store i32 %41, i32* %12
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
store i64 0, i64* %42
%43 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
store i32 100, i32* %43
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %29
%47 = load i32, i32* %12
%48 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %46, %29
%50 = load i32, i32* %8
%51 = load i64, i64* @xdr_int
%52 = trunc i64 %51 to i32
%53 = bitcast i32* %14 to i8*
%54 = load i64, i64* @xdr_int
%55 = trunc i64 %54 to i32
%56 = bitcast i32* %15 to i8*
%57 = call i32 @pmap_rmtcall(%struct.sockaddr_in* %10, i32 %50, i32 1, i32 1, i32 %52, i8* %53, i32 %55, i8* %56, %struct.timeval* byval(%struct.timeval) align 8 %13, i32* %12)
store i32 %57, i32* %11
%58 = load i32, i32* %11
%59 = load i32, i32* @RPC_SUCCESS
%60 = icmp eq i32 %58, %59
%61 = zext i1 %60 to i64
%62 = select i1 %60, i32 0, i32 1
store i32 %62, i32* %7
%63 = load i32, i32* %7
%64 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %7
ret i32 %65
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timeval = type { i32, i64 }
%struct.hostent = type { i64 }
@stderr = global i32 0
@.str = [22 x i8] c"gethostbyname failed\0A\00"
@AF_INET = global i32 0
@IPPROTO_UDP = global i32 0
@xdr_int = global i64 0
@RPC_SUCCESS = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca %struct.timeval
%6 = alloca i32
%7 = alloca i32
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = bitcast %struct.sockaddr_in* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast %struct.timeval* %5 to i8*
%14 = bitcast i32* %6 to i8*
store i32 10, i32* %6
%15 = bitcast i32* %7 to i8*
store i32 -1, i32* %7
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call %struct.hostent* @gethostbyname(i8* %17)
%19 = icmp eq %struct.hostent* %18, null
br i1 %19, label %20, label %24
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = load i32, i32* @AF_INET
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %25, i32* %26
%27 = getelementptr inbounds %struct.hostent, %struct.hostent* %18, i64 0, i32 0
%28 = load i64, i64* %27
%29 = inttoptr i64 %28 to i32*
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %30, i32* %31
%32 = load i32, i32* @IPPROTO_UDP
%33 = call i32 @pmap_getport(%struct.sockaddr_in* %3, i32 %10, i32 1, i32 %32)
store i32 %33, i32* %4
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
store i64 0, i64* %34
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
store i32 100, i32* %35
%36 = load i64, i64* @xdr_int
%37 = trunc i64 %36 to i32
%38 = call i32 @pmap_rmtcall(%struct.sockaddr_in* %3, i32 %10, i32 1, i32 1, i32 %37, i8* %14, i32 %37, i8* %15, %struct.timeval* byval(%struct.timeval) align 8 %5, i32* %4)
%39 = load i32, i32* @RPC_SUCCESS
%40 = icmp ne i32 %38, %39
%41 = zext i1 %40 to i32
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %41)
ret i32 %41
}