#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;
  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 : %d\n", 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    $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,-0x54(%rbp)
movl   $0xffffffff,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x5c(%rbp)
movl   $0x0,-0x60(%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    %eax,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0x64,-0x50(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     126c <main+0xfc>
mov    -0x40(%rbp),%esi
lea    0xdaf(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jge    130a <main+0x19a>
mov    -0x24(%rbp),%esi
mov    0x2d57(%rip),%rax
mov    (%rax),%rax
mov    %eax,%r8d
lea    -0x54(%rbp),%r9
mov    0x2d46(%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),%eax
mov    0x2cf2(%rip),%rcx
cmp    (%rcx),%eax
jne    12f7 <main+0x187>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    12fc <main+0x18c>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1273 <main+0x103>
cmpl   $0x1,-0x1c(%rbp)
jne    1332 <main+0x1c2>
mov    -0x5c(%rbp),%esi
lea    0xd03(%rip),%rdi
call   1030 <printf@plt>
mov    -0x60(%rbp),%esi
lea    0xd00(%rip),%rdi
call   1030 <printf@plt>
mov    -0x60(%rbp),%edx
mov    -0x5c(%rbp),%esi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xcd8(%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   %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,0x40(%rsp)
movl   $0xffffffff,0x3c(%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,0x34(%rsp)
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,0x30(%rsp)
mov    0x2de1(%rip),%rax
mov    (%rax),%ecx
lea    0x30(%rsp),%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1040 <pmap_getport@plt>
mov    %eax,0x44(%rsp)
movq   $0x0,0x50(%rsp)
movl   $0x64,0x48(%rsp)
test   %r13d,%r13d
mov    %r13d,0x38(%rsp)
jle    1275 <main+0x105>
xor    %ebp,%ebp
lea    0x30(%rsp),%r15
lea    0x40(%rsp),%r12
mov    0x2dbc(%rip),%r14
nopl   0x0(%rax)
mov    0x2db9(%rip),%rax
mov    (%rax),%r8d
movups 0x48(%rsp),%xmm0
movups %xmm0,0x10(%rsp)
lea    0x44(%rsp),%rax
mov    %rax,0x20(%rsp)
lea    0x3c(%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    0x38(%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 = [11 x i8] c"port : %d\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 i32
%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 i32 @pmap_getport(%struct.sockaddr_in* %10, i32 %46, i32 1, i32 %47)
store i32 %48, i32* %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 %56
53: ; preds = %36
%54 = load i32, i32* %12
%55 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %36
store i32 0, i32* %18
br label %57
57: ; preds = %77, %56
%58 = load i32, i32* %18
%59 = load i32, i32* %16
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %80
61: ; preds = %57
%62 = load i32, i32* %8
%63 = load i64, i64* @xdr_int
%64 = trunc i64 %63 to i32
%65 = bitcast i32* %14 to i8*
%66 = load i64, i64* @xdr_int
%67 = trunc i64 %66 to i32
%68 = bitcast i32* %15 to i8*
%69 = call i32 @pmap_rmtcall(%struct.sockaddr_in* %10, i32 %62, i32 1, i32 1, i32 %64, i8* %65, i32 %67, i8* %68, %struct.timeval* byval(%struct.timeval) align 8 %13, i32* %12)
store i32 %69, i32* %11
%70 = load i32, i32* %11
%71 = load i32, i32* @RPC_SUCCESS
%72 = icmp eq i32 %70, %71
br i1 %72, label %73, label %76
73: ; preds = %61
%74 = load i32, i32* %17
%75 = add nsw i32 %74, 1
store i32 %75, i32* %17
br label %76
76: ; preds = %73, %61
br label %77
77: ; preds = %76
%78 = load i32, i32* %18
%79 = add nsw i32 %78, 1
store i32 %79, i32* %18
br label %57
80: ; preds = %57
%81 = load i32, i32* %6
%82 = icmp eq i32 %81, 1
br i1 %82, label %83, label %88
83: ; preds = %80
%84 = load i32, i32* %16
%85 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %84)
%86 = load i32, i32* %17
%87 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %83, %80
%89 = load i32, i32* %17
%90 = load i32, i32* %16
%91 = icmp eq i32 %89, %90
%92 = zext i1 %91 to i64
%93 = select i1 %91, i32 0, i32 1
store i32 %93, i32* %7
%94 = load i32, i32* %7
%95 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %94)
%96 = load i32, i32* %7
ret i32 %96
}

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 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 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 i32 @pmap_getport(%struct.sockaddr_in* %3, i32 %10, i32 1, i32 %35)
store i32 %36, i32* %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, i32* %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
}