#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;
};
struct sockaddr_in {
  int dummy;
};
typedef int /*<<< orphan*/ CLIENT;

/* Variables and functions */
int RPC_ANYSOCK;
int /*<<< orphan*/ *clnttcp_create(struct sockaddr_in *, unsigned long,
                                   unsigned long, int *, int /*<<< orphan*/,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ *clntudp_create(struct sockaddr_in *, unsigned long,
                                   unsigned long, struct timeval, int *);
CLIENT *mkclient(struct sockaddr_in *sin, unsigned long prog,
                 unsigned long vers, int tcp) {
  static struct timeval tv = {15, 0};
  int fd = RPC_ANYSOCK;
  if (tcp)
    return clnttcp_create(sin, prog, vers, &fd, 0, 0);
  else
    return clntudp_create(sin, prog, vers, tv, &fd);
}


x86 assembly (clang, -O0):
<mkclient>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1171 <mkclient+0x51>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
xor    %r9d,%r9d
mov    %r9d,%r8d
call   1030 <clnttcp_create@plt>
mov    %rax,-0x8(%rbp)
jmp    1191 <mkclient+0x71>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    0x2eac(%rip),%rcx
lea    -0x28(%rbp),%r8
call   1040 <clntudp_create@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkclient>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
test   %ecx,%ecx
je     1144 <mkclient+0x24>
lea    0x4(%rsp),%rcx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <clnttcp_create@plt>
pop    %rcx
ret
lea    0x4(%rsp),%r8
mov    $0xf,%ecx
call   1040 <clntudp_create@plt>
pop    %rcx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.sockaddr_in = type { i32 }
@mkclient.tv = internal global %struct.timeval { i32 15, i32 0 }
@RPC_ANYSOCK = global i32 0
define i32* @mkclient(%struct.sockaddr_in* %0, i64 %1, i64 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca %struct.sockaddr_in*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %6
store i64 %1, i64* %7
store i64 %2, i64* %8
store i32 %3, i32* %9
%11 = load i32, i32* @RPC_ANYSOCK
store i32 %11, i32* %10
%12 = load i32, i32* %9
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %4
%15 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%16 = load i64, i64* %7
%17 = load i64, i64* %8
%18 = call i32* @clnttcp_create(%struct.sockaddr_in* %15, i64 %16, i64 %17, i32* %10, i32 0, i32 0)
store i32* %18, i32** %5
br label %25
19: ; preds = %4
%20 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%21 = load i64, i64* %7
%22 = load i64, i64* %8
%23 = load i64, i64* bitcast (%struct.timeval* @mkclient.tv to i64*)
%24 = call i32* @clntudp_create(%struct.sockaddr_in* %20, i64 %21, i64 %22, i64 %23, i32* %10)
store i32* %24, i32** %5
br label %25
25: ; preds = %19, %14
%26 = load i32*, i32** %5
ret i32* %26
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
@RPC_ANYSOCK = global i32 0
define i32* @mkclient(%struct.sockaddr_in* %0, i64 %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = load i32, i32* @RPC_ANYSOCK
store i32 %7, i32* %5
%8 = icmp eq i32 %3, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = call i32* @clnttcp_create(%struct.sockaddr_in* %0, i64 %1, i64 %2, i32* %5, i32 0, i32 0)
br label %13
11: ; preds = %4
%12 = call i32* @clntudp_create(%struct.sockaddr_in* %0, i64 %1, i64 %2, i64 15, i32* %5)
br label %13
13: ; preds = %11, %9
%14 = phi i32* [ %10, %9 ], [ %12, %11 ]
ret i32* %14
}