#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 */
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct sockaddr_in {
  scalar_t__ sin_port;
  int /*<<< orphan*/ sin_family;
  int /*<<< orphan*/ sin_addr;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ h_addr;
};
typedef int /*<<< orphan*/ caddr_t;
typedef int /*<<< orphan*/ CLIENT;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int RPC_ANYSOCK;
int atoi(char *);
int /*<<< orphan*/ bcopy(int /*<<< orphan*/, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ *clntudp_create(struct sockaddr_in *, int, int,
                                   struct timeval, int *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int main(int argn, char *argc[]) {
  int run_mode = 0;
  int test_status = 1;
  int progNum = atoi(argc[2]);
  CLIENT *clnt = NULL;
  struct sockaddr_in server_addr;
  struct hostent *hp = NULL;
  struct timeval pertry_timeout;
  int sock = RPC_ANYSOCK;
  int nbCall = atoi(argc[3]);
  int nbOk = 0;
  int i;
  if ((hp = gethostbyname(argc[1])) == NULL) {
    fprintf(stderr, "can't get addr for %s\n", argc[1]);
    exit(-1);
  }
  pertry_timeout.tv_sec = 1;
  pertry_timeout.tv_usec = 0;
  bcopy(hp->h_addr, (caddr_t)&server_addr.sin_addr, hp->h_length);
  server_addr.sin_family = AF_INET;
  server_addr.sin_port = 0;
  for (i = 0; i < nbCall; i++) {
    clnt = clntudp_create(&server_addr, progNum, 1, pertry_timeout, &sock);
    if ((CLIENT *)clnt != NULL)
      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
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x40(%rbp)
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <gethostbyname@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    1219 <main+0xa9>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdf6(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
movl   $0x1,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
lea    -0x38(%rbp),%rax
add    $0xc,%rax
mov    %eax,%esi
mov    -0x40(%rbp),%rax
mov    (%rax),%edx
call   1060 <bcopy@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x58(%rbp),%eax
jge    12b2 <main+0x142>
mov    -0x1c(%rbp),%esi
mov    -0x50(%rbp),%ecx
mov    -0x48(%rbp),%r8
lea    -0x38(%rbp),%rdi
mov    $0x1,%edx
lea    -0x54(%rbp),%r9
call   1090 <clntudp_create@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     129f <main+0x12f>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12a4 <main+0x134>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    125f <main+0xef>
cmpl   $0x1,-0x14(%rbp)
jne    12da <main+0x16a>
mov    -0x58(%rbp),%esi
lea    0xd51(%rip),%rdi
call   1030 <printf@plt>
mov    -0x5c(%rbp),%esi
lea    0xd4e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x5c(%rbp),%edx
mov    -0x58(%rbp),%esi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xd26(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    0x10(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
mov    0x2e4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x18(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x8(%rbp),%rdi
call   1040 <gethostbyname@plt>
test   %rax,%rax
je     124e <main+0xde>
mov    (%rax),%edx
mov    0x4(%rax),%edi
lea    0x8(%rsp),%rsi
add    $0xc,%esi
call   1060 <bcopy@plt>
mov    0x2e17(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
movq   $0x0,0x8(%rsp)
xor    %ebp,%ebp
test   %r14d,%r14d
jle    1227 <main+0xb7>
lea    0x8(%rsp),%r15
lea    0x4(%rsp),%r12
mov    %r14d,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r13d,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
mov    %r12,%r9
call   1090 <clntudp_create@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    $0xffffffff,%ebx
jne    1200 <main+0x90>
xor    %ebx,%ebx
cmp    %r14d,%ebp
setne  %bl
lea    0xde1(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
lea    0xd9e(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i64, i32, i32 }
%struct.hostent = type { i32, i32 }
%struct.timeval = type { i32, i64 }
@RPC_ANYSOCK = global i32 0
@stderr = global i32 0
@.str = [23 x i8] c"can't get addr for %s\0A\00"
@AF_INET = global i32 0
@.str.1 = [12 x i8] c"Aimed : %d\0A\00"
@.str.2 = [10 x i8] c"Got : %d\0A\00"
@.str.3 = [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 i32*
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.hostent*
%12 = alloca %struct.timeval
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = 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
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %8
store i32* null, i32** %9
store %struct.hostent* null, %struct.hostent** %11
%21 = load i32, i32* @RPC_ANYSOCK
store i32 %21, i32* %13
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 3
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %14
store i32 0, i32* %15
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call %struct.hostent* @gethostbyname(i8* %28)
store %struct.hostent* %29, %struct.hostent** %11
%30 = icmp eq %struct.hostent* %29, null
br i1 %30, label %31, label %38
31: ; preds = %2
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %35)
%37 = call i32 @exit(i32 -1)
unreachable
38: ; preds = %2
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
store i32 1, i32* %39
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
store i64 0, i64* %40
%41 = load %struct.hostent*, %struct.hostent** %11
%42 = getelementptr inbounds %struct.hostent, %struct.hostent* %41, i32 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
%45 = ptrtoint i32* %44 to i32
%46 = load %struct.hostent*, %struct.hostent** %11
%47 = getelementptr inbounds %struct.hostent, %struct.hostent* %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 @bcopy(i32 %43, i32 %45, i32 %48)
%50 = load i32, i32* @AF_INET
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %50, i32* %51
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
store i64 0, i64* %52
store i32 0, i32* %16
br label %53
53: ; preds = %71, %38
%54 = load i32, i32* %16
%55 = load i32, i32* %14
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %74
57: ; preds = %53
%58 = load i32, i32* %8
%59 = bitcast %struct.timeval* %12 to { i32, i64 }*
%60 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %59, i32 0, i32 0
%61 = load i32, i32* %60
%62 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %59, i32 0, i32 1
%63 = load i64, i64* %62
%64 = call i32* @clntudp_create(%struct.sockaddr_in* %10, i32 %58, i32 1, i32 %61, i64 %63, i32* %13)
store i32* %64, i32** %9
%65 = load i32*, i32** %9
%66 = icmp ne i32* %65, null
br i1 %66, label %67, label %70
67: ; preds = %57
%68 = load i32, i32* %15
%69 = add nsw i32 %68, 1
store i32 %69, i32* %15
br label %70
70: ; preds = %67, %57
br label %71
71: ; preds = %70
%72 = load i32, i32* %16
%73 = add nsw i32 %72, 1
store i32 %73, i32* %16
br label %53
74: ; preds = %53
%75 = load i32, i32* %6
%76 = icmp eq i32 %75, 1
br i1 %76, label %77, label %82
77: ; preds = %74
%78 = load i32, i32* %14
%79 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %78)
%80 = load i32, i32* %15
%81 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %80)
br label %82
82: ; preds = %77, %74
%83 = load i32, i32* %15
%84 = load i32, i32* %14
%85 = icmp eq i32 %83, %84
%86 = zext i1 %85 to i64
%87 = select i1 %85, i32 0, i32 1
store i32 %87, i32* %7
%88 = load i32, i32* %7
%89 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %88)
%90 = load i32, i32* %7
ret i32 %90
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i64, i32, i32 }
%struct.hostent = type { i32, i32 }
@RPC_ANYSOCK = global i32 0
@stderr = global i32 0
@.str = [23 x i8] c"can't get addr for %s\0A\00"
@AF_INET = global i32 0
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = load i32, i32* @RPC_ANYSOCK
store i32 %10, i32* %4
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call %struct.hostent* @gethostbyname(i8* %15)
%17 = icmp eq %struct.hostent* %16, null
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %14
%21 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = tail call i32 @exit(i32 -1)
unreachable
23: ; preds = %2
%24 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 1
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
%27 = ptrtoint i32* %26 to i64
%28 = trunc i64 %27 to i32
%29 = getelementptr inbounds %struct.hostent, %struct.hostent* %16, i64 0, i32 0
%30 = load i32, i32* %29
%31 = call i32 @bcopy(i32 %25, i32 %28, i32 %30)
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %32, i32* %33
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i64 0, i64* %34
%35 = icmp sgt i32 %13, 0
br i1 %35, label %36, label %45
36: ; preds = %23, %36
%37 = phi i32 [ %43, %36 ], [ 0, %23 ]
%38 = phi i32 [ %42, %36 ], [ 0, %23 ]
%39 = call i32* @clntudp_create(%struct.sockaddr_in* %3, i32 %7, i32 1, i32 1, i64 0, i32* %4)
%40 = icmp ne i32* %39, null
%41 = zext i1 %40 to i32
%42 = add nuw nsw i32 %38, %41
%43 = add nuw nsw i32 %37, 1
%44 = icmp eq i32 %43, %13
br i1 %44, label %45, label %36
45: ; preds = %36, %23
%46 = phi i32 [ 0, %23 ], [ %42, %36 ]
%47 = icmp ne i32 %46, %13
%48 = zext i1 %47 to i32
%49 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %48)
ret i32 %48
}