#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;
struct timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct TYPE_2__ {
  scalar_t__ cf_stat;
};
typedef int /*<<< orphan*/ CLIENT;

/* Variables and functions */
scalar_t__ clnt_call(int /*<<< orphan*/ *, int, int /*<<< orphan*/, char *,
                     int /*<<< orphan*/, char *, struct timeval);
int /*<<< orphan*/ *clnt_create(char const *, int, int, char *);
int /*<<< orphan*/ clnt_destroy(int /*<<< orphan*/ *);
TYPE_1__ rpc_createerr;
int tcp_callrpc(const char *host, int prognum, int versnum, int procnum,
                xdrproc_t inproc, char *in, xdrproc_t outproc, char *out) {
  CLIENT *client;
  struct timeval timeout;
  int rval;
  if ((client = clnt_create(host, prognum, versnum, "tcp")) == NULL &&
      (client = clnt_create(host, prognum, versnum, "udp")) == NULL)
    return ((int)rpc_createerr.cf_stat);
  timeout.tv_sec = 25;
  timeout.tv_usec = 0;
  rval = (int)clnt_call(client, procnum, inproc, in, outproc, out, timeout);
  clnt_destroy(client);
  return rval;
}


x86 assembly (clang, -O0):
<tcp_callrpc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe9b(%rip),%rcx
call   1030 <clnt_create@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11ae <tcp_callrpc+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe7b(%rip),%rcx
call   1030 <clnt_create@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11ae <tcp_callrpc+0x7e>
mov    0x2e4d(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
jmp    11fe <tcp_callrpc+0xce>
movl   $0x19,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    0x10(%rbp),%r8d
mov    0x18(%rbp),%r9
lea    -0x40(%rbp),%rax
mov    (%rax),%r10
mov    %r10,(%rsp)
mov    0x8(%rax),%rax
mov    %rax,0x8(%rsp)
call   1040 <clnt_call@plt>
mov    %eax,-0x44(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <clnt_destroy@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcp_callrpc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x10(%rsp)
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xea8(%rip),%rcx
call   1030 <clnt_create@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1181 <tcp_callrpc+0x51>
lea    0xe98(%rip),%rcx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
call   1030 <clnt_create@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11d4 <tcp_callrpc+0xa4>
mov    0x68(%rsp),%r9
mov    0x60(%rsp),%r8d
movl   $0x19,0x18(%rsp)
movq   $0x0,0x20(%rsp)
movups 0x18(%rsp),%xmm0
movups %xmm0,(%rsp)
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
mov    0x10(%rsp),%rcx
call   1040 <clnt_call@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1050 <clnt_destroy@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e15(%rip),%rax
mov    (%rax),%rbx
jmp    11c3 <tcp_callrpc+0x93>

LLVM IR (-O0):
%struct.TYPE_2__ = type { i64 }
%struct.timeval = type { i32, i64 }
@.str = [4 x i8] c"tcp\00"
@.str.1 = [4 x i8] c"udp\00"
@rpc_createerr = global %struct.TYPE_2__ zeroinitializer
define i32 @tcp_callrpc(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i8* %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i32*
%19 = alloca %struct.timeval
%20 = alloca i32
store i8* %0, i8** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i8* %5, i8** %15
store i32 %6, i32* %16
store i8* %7, i8** %17
%21 = load i8*, i8** %10
%22 = load i32, i32* %11
%23 = load i32, i32* %12
%24 = call i32* @clnt_create(i8* %21, i32 %22, i32 %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %18
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %35
26: ; preds = %8
%27 = load i8*, i8** %10
%28 = load i32, i32* %11
%29 = load i32, i32* %12
%30 = call i32* @clnt_create(i8* %27, i32 %28, i32 %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %18
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i64, i64* getelementptr inbounds (%struct.TYPE_2__, %struct.TYPE_2__* @rpc_createerr, i32 0, i32 0)
%34 = trunc i64 %33 to i32
store i32 %34, i32* %9
br label %49
35: ; preds = %26, %8
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
store i32 25, i32* %36
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
store i64 0, i64* %37
%38 = load i32*, i32** %18
%39 = load i32, i32* %13
%40 = load i32, i32* %14
%41 = load i8*, i8** %15
%42 = load i32, i32* %16
%43 = load i8*, i8** %17
%44 = call i64 @clnt_call(i32* %38, i32 %39, i32 %40, i8* %41, i32 %42, i8* %43, %struct.timeval* byval(%struct.timeval) align 8 %19)
%45 = trunc i64 %44 to i32
store i32 %45, i32* %20
%46 = load i32*, i32** %18
%47 = call i32 @clnt_destroy(i32* %46)
%48 = load i32, i32* %20
store i32 %48, i32* %9
br label %49
49: ; preds = %35, %32
%50 = load i32, i32* %9
ret i32 %50
}

LLVM IR (-O2):
%struct.TYPE_2__ = type { i64 }
%struct.timeval = type { i32, i64 }
@.str = [4 x i8] c"tcp\00"
@.str.1 = [4 x i8] c"udp\00"
@rpc_createerr = global %struct.TYPE_2__ zeroinitializer
define i32 @tcp_callrpc(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i8* %7) {
%9 = alloca %struct.timeval
%10 = bitcast %struct.timeval* %9 to i8*
%11 = tail call i32* @clnt_create(i8* %0, i32 %1, i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = tail call i32* @clnt_create(i8* %0, i32 %1, i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = load i64, i64* getelementptr inbounds (%struct.TYPE_2__, %struct.TYPE_2__* @rpc_createerr, i64 0, i32 0)
br label %24
18: ; preds = %13, %8
%19 = phi i32* [ %14, %13 ], [ %11, %8 ]
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0, i32 0
store i32 25, i32* %20
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i64 0, i32 1
store i64 0, i64* %21
%22 = tail call i64 @clnt_call(i32* %19, i32 %3, i32 %4, i8* %5, i32 %6, i8* %7, %struct.timeval* byval(%struct.timeval) align 8 %9)
%23 = tail call i32 @clnt_destroy(i32* %19)
br label %24
24: ; preds = %18, %16
%25 = phi i64 [ %17, %16 ], [ %22, %18 ]
%26 = trunc i64 %25 to i32
ret i32 %26
}