#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_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 *);
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;
  int nbCall = atoi(argc[3]);
  int nbOk = 0;
  int i;
  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 : %lu\n", (unsigned long)port);
  }
  for (i = 0; i < nbCall; i++) {
    cs = pmap_rmtcall(&sin, progNum, 1, 1, (xdrproc_t)xdr_int, (char *)&var_snd,
                      (xdrproc_t)xdr_int, (char *)&var_rec, tv, &port);
    if (cs == RPC_SUCCESS)
      nbOk++;
  }
  if (run_mode == 1) {
    printf("Aimed : %d\n", nbCall);
    printf("Got : %d\n", nbOk);
  }
  test_status = (nbOk == nbCall) ? 0 : 1;
  printf("%d\n", test_status);
  return test_status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x98,%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    0x18(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    120f <main+0x9f>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2dd2(%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    0x2d87(%rip),%rax
mov    (%rax),%ecx
lea    -0x38(%rbp),%rdi
mov    $0x1,%edx
call   1040 <pmap_getport@plt>
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
movl   $0x64,-0x58(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1270 <main+0x100>
mov    -0x48(%rbp),%rax
mov    %eax,%esi
lea    0xdab(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    130e <main+0x19e>
mov    -0x24(%rbp),%esi
mov    0x2d53(%rip),%rax
mov    (%rax),%rax
mov    %eax,%r8d
lea    -0x5c(%rbp),%r9
mov    0x2d42(%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),%eax
mov    0x2cee(%rip),%rcx
cmp    (%rcx),%eax
jne    12fb <main+0x18b>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1300 <main+0x190>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1277 <main+0x107>
cmpl   $0x1,-0x1c(%rbp)
jne    1336 <main+0x1c6>
mov    -0x64(%rbp),%esi
lea    0xd00(%rip),%rdi
call   1030 <printf@plt>
mov    -0x68(%rbp),%esi
lea    0xcfd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x68(%rbp),%edx
mov    -0x64(%rbp),%esi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xcd5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x98,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbp
mov    0x10(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebx
movl   $0xa,0x3c(%rsp)
movl   $0xffffffff,0x38(%rsp)
ff
mov    0x18(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%r13d
mov    0x8(%rbp),%rdi
call   1050 <gethostbyname@plt>
test   %rax,%rax
je     129f <main+0x12f>
mov    0x2e27(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x2c(%rsp)
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,0x28(%rsp)
mov    0x2de1(%rip),%rax
mov    (%rax),%ecx
lea    0x28(%rsp),%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1040 <pmap_getport@plt>
mov    %rax,0x40(%rsp)
movq   $0x0,0x50(%rsp)
movl   $0x64,0x48(%rsp)
test   %r13d,%r13d
mov    %r13d,0x34(%rsp)
jle    1275 <main+0x105>
xor    %ebp,%ebp
lea    0x28(%rsp),%r15
lea    0x3c(%rsp),%r12
mov    0x2dbb(%rip),%r14
nopl   (%rax)
mov    0x2db9(%rip),%rax
mov    (%rax),%r8d
movups 0x48(%rsp),%xmm0
movups %xmm0,0x10(%rsp)
lea    0x40(%rsp),%rax
mov    %rax,0x20(%rsp)
lea    0x38(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %r8d,(%rsp)
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
mov    %r12,%r9
call   1070 <pmap_rmtcall@plt>
xor    %ecx,%ecx
cmp    (%r14),%eax
sete   %cl
add    %ecx,%ebp
add    $0xffffffff,%r13d
jne    1220 <main+0xb0>
jmp    1277 <main+0x107>
xor    %ebp,%ebp
xor    %ebx,%ebx
cmp    0x34(%rsp),%ebp
setne  %bl
lea    0xd8f(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%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 = [12 x i8] c"Aimed : %d\0A\00"
@.str.3 = [10 x i8] c"Got : %d\0A\00"
@.str.4 = [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
%16 = alloca i32
%17 = alloca i32
%18 = 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
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %8
store %struct.hostent* null, %struct.hostent** %9
store i32 10, i32* %14
store i32 -1, i32* %15
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %16
store i32 0, i32* %17
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call %struct.hostent* @gethostbyname(i8* %29)
store %struct.hostent* %30, %struct.hostent** %9
%31 = icmp eq %struct.hostent* %30, null
br i1 %31, label %32, label %36
32: ; preds = %2
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %2
%37 = load i32, i32* @AF_INET
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %37, i32* %38
%39 = load %struct.hostent*, %struct.hostent** %9
%40 = getelementptr inbounds %struct.hostent, %struct.hostent* %39, i32 0, i32 0
%41 = load i64, i64* %40
%42 = inttoptr i64 %41 to i32*
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%45 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %44, i32 0, i32 0
store i32 %43, i32* %45
%46 = load i32, i32* %8
%47 = load i32, i32* @IPPROTO_UDP
%48 = call i64 @pmap_getport(%struct.sockaddr_in* %10, i32 %46, i32 1, i32 %47)
store i64 %48, i64* %12
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
store i64 0, i64* %49
%50 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
store i32 100, i32* %50
%51 = load i32, i32* %6
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %57
53: ; preds = %36
%54 = load i64, i64* %12
%55 = trunc i64 %54 to i32
%56 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %55)
br label %57
57: ; preds = %53, %36
store i32 0, i32* %18
br label %58
58: ; preds = %78, %57
%59 = load i32, i32* %18
%60 = load i32, i32* %16
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %81
62: ; preds = %58
%63 = load i32, i32* %8
%64 = load i64, i64* @xdr_int
%65 = trunc i64 %64 to i32
%66 = bitcast i32* %14 to i8*
%67 = load i64, i64* @xdr_int
%68 = trunc i64 %67 to i32
%69 = bitcast i32* %15 to i8*
%70 = call i32 @pmap_rmtcall(%struct.sockaddr_in* %10, i32 %63, i32 1, i32 1, i32 %65, i8* %66, i32 %68, i8* %69, %struct.timeval* byval(%struct.timeval) align 8 %13, i64* %12)
store i32 %70, i32* %11
%71 = load i32, i32* %11
%72 = load i32, i32* @RPC_SUCCESS
%73 = icmp eq i32 %71, %72
br i1 %73, label %74, label %77
74: ; preds = %62
%75 = load i32, i32* %17
%76 = add nsw i32 %75, 1
store i32 %76, i32* %17
br label %77
77: ; preds = %74, %62
br label %78
78: ; preds = %77
%79 = load i32, i32* %18
%80 = add nsw i32 %79, 1
store i32 %80, i32* %18
br label %58
81: ; preds = %58
%82 = load i32, i32* %6
%83 = icmp eq i32 %82, 1
br i1 %83, label %84, label %89
84: ; preds = %81
%85 = load i32, i32* %16
%86 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %85)
%87 = load i32, i32* %17
%88 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %87)
br label %89
89: ; preds = %84, %81
%90 = load i32, i32* %17
%91 = load i32, i32* %16
%92 = icmp eq i32 %90, %91
%93 = zext i1 %92 to i64
%94 = select i1 %92, i32 0, i32 1
store i32 %94, i32* %7
%95 = load i32, i32* %7
%96 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %95)
%97 = load i32, i32* %7
ret i32 %97
}

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.4 = [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 3
%17 = load i8*, i8** %16
%18 = tail call i32 @atoi(i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call %struct.hostent* @gethostbyname(i8* %20)
%22 = icmp eq %struct.hostent* %21, null
br i1 %22, label %23, label %27
23: ; preds = %2
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %2
%28 = load i32, i32* @AF_INET
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %28, i32* %29
%30 = getelementptr inbounds %struct.hostent, %struct.hostent* %21, i64 0, i32 0
%31 = load i64, i64* %30
%32 = inttoptr i64 %31 to i32*
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %33, i32* %34
%35 = load i32, i32* @IPPROTO_UDP
%36 = call i64 @pmap_getport(%struct.sockaddr_in* %3, i32 %10, i32 1, i32 %35)
store i64 %36, i64* %4
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
store i64 0, i64* %37
%38 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
store i32 100, i32* %38
%39 = icmp sgt i32 %18, 0
br i1 %39, label %40, label %52
40: ; preds = %27, %40
%41 = phi i32 [ %50, %40 ], [ 0, %27 ]
%42 = phi i32 [ %49, %40 ], [ 0, %27 ]
%43 = load i64, i64* @xdr_int
%44 = trunc i64 %43 to i32
%45 = call i32 @pmap_rmtcall(%struct.sockaddr_in* %3, i32 %10, i32 1, i32 1, i32 %44, i8* %14, i32 %44, i8* %15, %struct.timeval* byval(%struct.timeval) align 8 %5, i64* %4)
%46 = load i32, i32* @RPC_SUCCESS
%47 = icmp eq i32 %45, %46
%48 = zext i1 %47 to i32
%49 = add nuw nsw i32 %42, %48
%50 = add nuw nsw i32 %41, 1
%51 = icmp eq i32 %50, %18
br i1 %51, label %52, label %40
52: ; preds = %40, %27
%53 = phi i32 [ 0, %27 ], [ %49, %40 ]
%54 = icmp ne i32 %53, %18
%55 = zext i1 %54 to i32
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %55)
ret i32 %55
}