#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 member_0;
  int /*<<< orphan*/ member_1;
};
typedef int /*<<< orphan*/ statstime;
typedef int /*<<< orphan*/ host_stat;
typedef int /*<<< orphan*/ CLIENT;

/* Variables and functions */
scalar_t__ RPC_SUCCESS;
int /*<<< orphan*/ RSTATPROC_STATS;
int /*<<< orphan*/ RSTATPROG;
int /*<<< orphan*/ RSTATVERS_TIME;
scalar_t__ clnt_call(int /*<<< orphan*/ *, int /*<<< orphan*/,
                     int /*<<< orphan*/, int /*<<< orphan*/ *,
                     int /*<<< orphan*/, int /*<<< orphan*/ *, struct timeval);
int /*<<< orphan*/ *clnt_create(char *, int /*<<< orphan*/, int /*<<< orphan*/,
                                char *);
int /*<<< orphan*/ clnt_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ clnt_spcreateerror(char *);
int /*<<< orphan*/ clnt_sperror(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ print_rup_data(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ warnx(char *, int /*<<< orphan*/);
int /*<<< orphan*/ xdr_statstime;
int /*<<< orphan*/ xdr_void;
int onehost(char *host) {
  CLIENT *rstat_clnt;
  statstime host_stat;
  static struct timeval timeout = {25, 0};
  rstat_clnt = clnt_create(host, RSTATPROG, RSTATVERS_TIME, "udp");
  if (rstat_clnt == NULL) {
    warnx("%s", clnt_spcreateerror(host));
    return 1;
  }
  (void)memset(&host_stat, 0, sizeof(host_stat));
  if (clnt_call(rstat_clnt, RSTATPROC_STATS, xdr_void, NULL, xdr_statstime,
                &host_stat, timeout) != RPC_SUCCESS) {
    warnx("%s", clnt_sperror(rstat_clnt, host));
    clnt_destroy(rstat_clnt);
    return 1;
  }
  print_rup_data(host, &host_stat);
  clnt_destroy(rstat_clnt);
  return 0;
}


x86 assembly (clang, -O0):
<onehost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
mov    0x2e10(%rip),%rax
mov    (%rax),%edx
lea    0xe57(%rip),%rcx
call   1070 <clnt_create@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e0 <onehost+0x60>
mov    -0x10(%rbp),%rdi
call   1060 <clnt_spcreateerror@plt>
mov    %eax,%esi
lea    0xe35(%rip),%rdi
call   1040 <warnx@plt>
movl   $0x1,-0x4(%rbp)
jmp    1283 <onehost+0x103>
lea    -0x1c(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    -0x18(%rbp),%rdi
mov    0x2dcd(%rip),%rax
mov    (%rax),%esi
mov    0x2ddc(%rip),%rax
mov    (%rax),%edx
mov    0x2deb(%rip),%rax
mov    (%rax),%r8d
mov    0x2e49(%rip),%rax
xor    %ecx,%ecx
lea    -0x1c(%rbp),%r9
mov    %rax,(%rsp)
call   1080 <clnt_call@plt>
mov    0x2dab(%rip),%rcx
cmp    (%rcx),%rax
je     1266 <onehost+0xe6>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <clnt_sperror@plt>
mov    %eax,%esi
lea    0xdb8(%rip),%rdi
call   1040 <warnx@plt>
mov    -0x18(%rbp),%rdi
call   1090 <clnt_destroy@plt>
movl   $0x1,-0x4(%rbp)
jmp    1283 <onehost+0x103>
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1030 <print_rup_data@plt>
mov    -0x18(%rbp),%rdi
call   1090 <clnt_destroy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<onehost>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
mov    0x2e2b(%rip),%rax
mov    (%rax),%esi
mov    0x2e12(%rip),%rax
mov    (%rax),%edx
lea    0xe59(%rip),%rcx
call   1070 <clnt_create@plt>
test   %rax,%rax
je     121f <onehost+0x9f>
mov    %rax,%rbx
lea    0x14(%rsp),%r12
xor    %r15d,%r15d
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1050 <memset@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
mov    0x2e05(%rip),%rax
mov    (%rax),%edx
mov    0x2e14(%rip),%rax
mov    (%rax),%r8d
movq   $0x19,(%rsp)
mov    %rbx,%rdi
xor    %ecx,%ecx
mov    %r12,%r9
call   1080 <clnt_call@plt>
mov    0x2dd5(%rip),%rcx
cmp    (%rcx),%rax
jne    1237 <onehost+0xb7>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   1030 <print_rup_data@plt>
mov    %rbx,%rdi
call   1090 <clnt_destroy@plt>
jmp    125e <onehost+0xde>
mov    %r14,%rdi
call   1060 <clnt_spcreateerror@plt>
lea    0xdd6(%rip),%rdi
mov    %eax,%esi
call   1040 <warnx@plt>
jmp    1258 <onehost+0xd8>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <clnt_sperror@plt>
lea    0xdbb(%rip),%rdi
mov    %eax,%esi
call   1040 <warnx@plt>
mov    %rbx,%rdi
call   1090 <clnt_destroy@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@onehost.timeout = internal global %struct.timeval { i32 25, i32 0 }
@RSTATPROG = global i32 0
@RSTATVERS_TIME = global i32 0
@.str = [4 x i8] c"udp\00"
@.str.1 = [3 x i8] c"%s\00"
@RSTATPROC_STATS = global i32 0
@xdr_void = global i32 0
@xdr_statstime = global i32 0
@RPC_SUCCESS = global i64 0
define i32 @onehost(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = load i32, i32* @RSTATPROG
%8 = load i32, i32* @RSTATVERS_TIME
%9 = call i32* @clnt_create(i8* %6, i32 %7, i32 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @clnt_spcreateerror(i8* %13)
%15 = call i32 @warnx(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
store i32 1, i32* %2
br label %38
16: ; preds = %1
%17 = call i32 @memset(i32* %5, i32 0, i32 4)
%18 = load i32*, i32** %4
%19 = load i32, i32* @RSTATPROC_STATS
%20 = load i32, i32* @xdr_void
%21 = load i32, i32* @xdr_statstime
%22 = load i64, i64* bitcast (%struct.timeval* @onehost.timeout to i64*)
%23 = call i64 @clnt_call(i32* %18, i32 %19, i32 %20, i32* null, i32 %21, i32* %5, i64 %22)
%24 = load i64, i64* @RPC_SUCCESS
%25 = icmp ne i64 %23, %24
br i1 %25, label %26, label %33
26: ; preds = %16
%27 = load i32*, i32** %4
%28 = load i8*, i8** %3
%29 = call i32 @clnt_sperror(i32* %27, i8* %28)
%30 = call i32 @warnx(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32*, i32** %4
%32 = call i32 @clnt_destroy(i32* %31)
store i32 1, i32* %2
br label %38
33: ; preds = %16
%34 = load i8*, i8** %3
%35 = call i32 @print_rup_data(i8* %34, i32* %5)
%36 = load i32*, i32** %4
%37 = call i32 @clnt_destroy(i32* %36)
store i32 0, i32* %2
br label %38
38: ; preds = %33, %26, %12
%39 = load i32, i32* %2
ret i32 %39
}

LLVM IR (-O2):
@RSTATPROG = global i32 0
@RSTATVERS_TIME = global i32 0
@.str = [4 x i8] c"udp\00"
@.str.1 = [3 x i8] c"%s\00"
@RSTATPROC_STATS = global i32 0
@xdr_void = global i32 0
@xdr_statstime = global i32 0
@RPC_SUCCESS = global i64 0
define i32 @onehost(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @RSTATPROG
%5 = load i32, i32* @RSTATVERS_TIME
%6 = tail call i32* @clnt_create(i8* %0, i32 %4, i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = tail call i32 @clnt_spcreateerror(i8* %0)
%10 = tail call i32 @warnx(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %26
11: ; preds = %1
%12 = call i32 @memset(i32* %2, i32 0, i32 4)
%13 = load i32, i32* @RSTATPROC_STATS
%14 = load i32, i32* @xdr_void
%15 = load i32, i32* @xdr_statstime
%16 = call i64 @clnt_call(i32* %6, i32 %13, i32 %14, i32* null, i32 %15, i32* %2, i64 25)
%17 = load i64, i64* @RPC_SUCCESS
%18 = icmp eq i64 %16, %17
br i1 %18, label %23, label %19
19: ; preds = %11
%20 = call i32 @clnt_sperror(i32* %6, i8* %0)
%21 = call i32 @warnx(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = call i32 @clnt_destroy(i32* %6)
br label %26
23: ; preds = %11
%24 = call i32 @print_rup_data(i8* %0, i32* %2)
%25 = call i32 @clnt_destroy(i32* %6)
br label %26
26: ; preds = %23, %19, %8
%27 = phi i32 [ 1, %8 ], [ 1, %19 ], [ 0, %23 ]
ret i32 %27
}