#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 scalar_t__ u_long;
typedef int /*<<< orphan*/ u_int;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
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 *);
scalar_t__ 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,
                 scalar_t__ *);
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 = 1;
  tv.tv_usec = 0;
  if (run_mode) {
    printf("port : %lu\n", (unsigned long)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    $0x88,%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,-0x5c(%rbp)
movl   $0xffffffff,-0x60(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11f8 <main+0x88>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2de9(%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    0x2d9e(%rip),%rax
mov    (%rax),%ecx
lea    -0x38(%rbp),%rdi
mov    $0x1,%edx
call   1040 <pmap_getport@plt>
mov    %rax,-0x48(%rbp)
movl   $0x1,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1259 <main+0xe9>
mov    -0x48(%rbp),%rax
mov    %eax,%esi
lea    0xdc2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%esi
mov    0x2d7d(%rip),%rax
mov    (%rax),%rax
mov    %eax,%r8d
lea    -0x5c(%rbp),%r9
mov    0x2d6c(%rip),%rax
mov    (%rax),%rax
mov    %eax,%ebx
lea    -0x60(%rbp),%r11
lea    -0x38(%rbp),%rdi
mov    $0x1,%ecx
lea    -0x58(%rbp),%r10
lea    -0x48(%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    0x2d18(%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    0xd47(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x88,%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,0x34(%rsp)
movl   $0xffffffff,0x30(%rsp)
ff
mov    0x8(%rbx),%rdi
call   1050 <gethostbyname@plt>
test   %rax,%rax
je     1259 <main+0xe9>
mov    0x2e3b(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x3c(%rsp)
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,0x38(%rsp)
mov    0x2df5(%rip),%rax
mov    (%rax),%ecx
lea    0x38(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <pmap_getport@plt>
mov    %rax,0x40(%rsp)
movl   $0x1,0x48(%rsp)
movq   $0x0,0x50(%rsp)
mov    0x2dea(%rip),%rax
mov    (%rax),%r8d
movups 0x48(%rsp),%xmm0
movups %xmm0,0x10(%rsp)
lea    0x40(%rsp),%rax
mov    %rax,0x20(%rsp)
lea    0x30(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %r8d,(%rsp)
lea    0x34(%rsp),%r9
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1070 <pmap_rmtcall@plt>
mov    0x2d9d(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%eax
setne  %bl
lea    0xdcd(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xd97(%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 = [12 x i8] c"port : %lu\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 i64
%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 i64 @pmap_getport(%struct.sockaddr_in* %10, i32 %39, i32 1, i32 %40)
store i64 %41, i64* %12
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
store i32 1, i32* %42
%43 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
store i64 0, i64* %43
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %29
%47 = load i64, i64* %12
%48 = trunc i64 %47 to i32
%49 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %46, %29
%51 = load i32, i32* %8
%52 = load i64, i64* @xdr_int
%53 = trunc i64 %52 to i32
%54 = bitcast i32* %14 to i8*
%55 = load i64, i64* @xdr_int
%56 = trunc i64 %55 to i32
%57 = bitcast i32* %15 to i8*
%58 = call i32 @pmap_rmtcall(%struct.sockaddr_in* %10, i32 %51, i32 1, i32 1, i32 %53, i8* %54, i32 %56, i8* %57, %struct.timeval* byval(%struct.timeval) align 8 %13, i64* %12)
store i32 %58, i32* %11
%59 = load i32, i32* %11
%60 = load i32, i32* @RPC_SUCCESS
%61 = icmp eq i32 %59, %60
%62 = zext i1 %61 to i64
%63 = select i1 %61, i32 0, i32 1
store i32 %63, i32* %7
%64 = load i32, i32* %7
%65 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %64)
%66 = load i32, i32* %7
ret i32 %66
}

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 i64
%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 i64* %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 i64 @pmap_getport(%struct.sockaddr_in* %3, i32 %10, i32 1, i32 %32)
store i64 %33, i64* %4
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
store i32 1, i32* %34
%35 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
store i64 0, i64* %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, i64* %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
}