#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_bufcreate(struct sockaddr_in *, int, int,
                                      struct timeval, int *, int, 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;
  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;
  clnt = clntudp_bufcreate(&server_addr, progNum, 1, pertry_timeout, &sock,
                           1024, 1024);
  if (run_mode == 1) {
    printf("CLIENT : %p\n", clnt);
  }
  test_status = ((CLIENT *)clnt != NULL) ? 0 : 1;
  printf("%d\n", test_status);
  return test_status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%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   1080 <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    0x8(%rax),%rdi
call   1040 <gethostbyname@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    1202 <main+0x92>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe0d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <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   1070 <bcopy@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x50(%rbp),%ecx
mov    -0x48(%rbp),%r8
lea    -0x38(%rbp),%rdi
mov    $0x1,%edx
lea    -0x54(%rbp),%r9
movl   $0x400,(%rsp)
movl   $0x400,0x8(%rsp)
call   1060 <clntudp_bufcreate@plt>
mov    %rax,-0x28(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    128c <main+0x11c>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xd90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xd79(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x8(%rbx),%rdi
call   1040 <gethostbyname@plt>
test   %rax,%rax
je     1210 <main+0xa0>
mov    (%rax),%edx
mov    0x4(%rax),%edi
lea    0x8(%rsp),%rbx
lea    0xc(%rbx),%esi
call   1070 <bcopy@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x4(%rsp),%r9
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
xor    %r8d,%r8d
push   $0x400
push   $0x400
call   1060 <clntudp_bufcreate@plt>
add    $0x10,%rsp
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
lea    0xe17(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xddc(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1090 <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 = [13 x i8] c"CLIENT : %p\0A\00"
@.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 i32*
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.hostent*
%12 = alloca %struct.timeval
%13 = 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
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %8
store i32* null, i32** %9
store %struct.hostent* null, %struct.hostent** %11
%18 = load i32, i32* @RPC_ANYSOCK
store i32 %18, i32* %13
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call %struct.hostent* @gethostbyname(i8* %21)
store %struct.hostent* %22, %struct.hostent** %11
%23 = icmp eq %struct.hostent* %22, null
br i1 %23, label %24, label %31
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 -1)
unreachable
31: ; preds = %2
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
store i32 1, i32* %32
%33 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
store i64 0, i64* %33
%34 = load %struct.hostent*, %struct.hostent** %11
%35 = getelementptr inbounds %struct.hostent, %struct.hostent* %34, i32 0, i32 1
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
%38 = ptrtoint i32* %37 to i32
%39 = load %struct.hostent*, %struct.hostent** %11
%40 = getelementptr inbounds %struct.hostent, %struct.hostent* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = call i32 @bcopy(i32 %36, i32 %38, i32 %41)
%43 = load i32, i32* @AF_INET
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %43, i32* %44
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
store i64 0, i64* %45
%46 = load i32, i32* %8
%47 = bitcast %struct.timeval* %12 to { i32, i64 }*
%48 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %47, i32 0, i32 0
%49 = load i32, i32* %48
%50 = getelementptr inbounds { i32, i64 }, { i32, i64 }* %47, i32 0, i32 1
%51 = load i64, i64* %50
%52 = call i32* @clntudp_bufcreate(%struct.sockaddr_in* %10, i32 %46, i32 1, i32 %49, i64 %51, i32* %13, i32 1024, i32 1024)
store i32* %52, i32** %9
%53 = load i32, i32* %6
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %59
55: ; preds = %31
%56 = load i32*, i32** %9
%57 = ptrtoint i32* %56 to i32
%58 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %55, %31
%60 = load i32*, i32** %9
%61 = icmp ne i32* %60, null
%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 { 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.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 = 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 1
%12 = load i8*, i8** %11
%13 = tail call %struct.hostent* @gethostbyname(i8* %12)
%14 = icmp eq %struct.hostent* %13, null
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %11
%18 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = tail call i32 @exit(i32 -1)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds %struct.hostent, %struct.hostent* %13, i64 0, i32 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
%24 = ptrtoint i32* %23 to i64
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds %struct.hostent, %struct.hostent* %13, i64 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 @bcopy(i32 %22, i32 %25, i32 %27)
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %29, i32* %30
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i64 0, i64* %31
%32 = call i32* @clntudp_bufcreate(%struct.sockaddr_in* %3, i32 %7, i32 1, i32 1, i64 0, i32* %4, i32 1024, i32 1024)
%33 = icmp eq i32* %32, null
%34 = zext i1 %33 to i32
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %34)
ret i32 %34
}