#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_8__ TYPE_2__;
typedef struct TYPE_7__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ ypsd;
typedef int /*<<< orphan*/ xdrproc_t;
struct TYPE_7__ {
  int /*<<< orphan*/ ypbind_binding_port;
  int /*<<< orphan*/ ypbind_binding_addr;
};
struct ypbind_setdom {
  char *ypsetdom_domain;
  int /*<<< orphan*/ ypsetdom_vers;
  TYPE_1__ ypsetdom_binding;
};
struct timeval {
  int member_0;
  int /*<<< orphan*/ member_1;
};
struct in_addr {
  int s_addr;
};
struct hostent {
  int **h_addr_list;
};
typedef int int16_t;
typedef int /*<<< orphan*/ caddr_t;
struct TYPE_8__ {
  int /*<<< orphan*/ cl_auth;
};
typedef TYPE_2__ CLIENT;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ YPBINDPROC_SETDOM;
int /*<<< orphan*/ YPBINDPROG;
int /*<<< orphan*/ YPBINDVERS;
int YPERR_YPBIND;
int /*<<< orphan*/ YPPROC_NULL;
int /*<<< orphan*/ YPPROG;
int /*<<< orphan*/ YPVERS;
int /*<<< orphan*/ authunix_create_default();
int clnt_call(TYPE_2__ *, int /*<<< orphan*/, int /*<<< orphan*/,
              int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/ *,
              struct timeval const);
TYPE_2__ *clnt_create(char const *, int /*<<< orphan*/, int /*<<< orphan*/,
                      char *);
int /*<<< orphan*/ clnt_destroy(TYPE_2__ *);
int /*<<< orphan*/ clnt_perror(TYPE_2__ *, char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
struct hostent *gethostbyname2(char *, int /*<<< orphan*/);
int /*<<< orphan*/ getrpcport(char *, int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/);
char *gettext(char *);
int htons(int /*<<< orphan*/);
scalar_t__ inet_aton(char *, struct in_addr *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int *, int);
int /*<<< orphan*/ memset(struct ypbind_setdom *, char, int);
int /*<<< orphan*/ stderr;
scalar_t__ xdr_void;
scalar_t__ xdr_ypbind_setdom;
char *yperr_string(int);
int bind_tohost_v2(const char *hostname, char *domainname, char *new_server) {
  struct ypbind_setdom ypsd;
  const struct timeval tv = {15, 0};
  struct hostent *hp;
  CLIENT *client;
  int port;
  int16_t port16;
  int res;
  struct in_addr server_addr;
  if ((port = htons(
           getrpcport(new_server, YPPROG, YPPROC_NULL, IPPROTO_UDP))) == 0) {
    fprintf(stderr, gettext("%s not running ypserv.\n"), new_server);
    exit(1);
  }
  memset(&ypsd, '\0', sizeof(ypsd));
  if ((hp = gethostbyname2(new_server, AF_INET)) != NULL)
    memcpy(&ypsd.ypsetdom_binding.ypbind_binding_addr, hp->h_addr_list[0],
           sizeof(ypsd.ypsetdom_binding.ypbind_binding_addr));
  else if (inet_aton(new_server, &server_addr) == 0) {
    fprintf(stderr, gettext("can't find IPv4 address for %s\n"), new_server);
    exit(1);
  } else
    memcpy(&ypsd.ypsetdom_binding.ypbind_binding_addr, &server_addr.s_addr,
           sizeof(server_addr.s_addr));
  ypsd.ypsetdom_domain = domainname;
  port16 = port;
  memcpy(&ypsd.ypsetdom_binding.ypbind_binding_port, &port16,
         sizeof(ypsd.ypsetdom_binding.ypbind_binding_port));
  ypsd.ypsetdom_vers = YPVERS;
  client = clnt_create(hostname, YPBINDPROG, YPBINDVERS, "udp");
  if (client == NULL) {
    fprintf(stderr, gettext("can't yp_bind: Reason: %s\n"),
            yperr_string(YPERR_YPBIND));
    return YPERR_YPBIND;
  }
  client->cl_auth = authunix_create_default();
  res = clnt_call(client, YPBINDPROC_SETDOM, (xdrproc_t)xdr_ypbind_setdom,
                  (caddr_t)&ypsd, (xdrproc_t)xdr_void, NULL, tv);
  if (res) {
    fprintf(stderr, gettext("Cannot ypset for domain %s on host %s.\n"),
            domainname, hostname);
    clnt_perror(client, gettext("Reason"));
    clnt_destroy(client);
    return YPERR_YPBIND;
  }
  clnt_destroy(client);
  return 0;
}


x86 assembly (clang, -O0):
<bind_tohost_v2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    0xdf2(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
mov    0x2d7a(%rip),%rax
mov    (%rax),%edx
mov    0x2d51(%rip),%rax
mov    (%rax),%ecx
call   1030 <getrpcport@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,-0x54(%rbp)
cmp    $0x0,%eax
jne    127c <bind_tohost_v2+0x8c>
mov    0x2d60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
lea    0xdac(%rip),%rdi
call   1040 <gettext@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%rsi
mov    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
mov    -0x20(%rbp),%rdi
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
call   1070 <gethostbyname2@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
je     12d1 <bind_tohost_v2+0xe1>
lea    -0x38(%rbp),%rdi
add    $0xc,%rdi
add    $0x4,%rdi
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
jmp    133a <bind_tohost_v2+0x14a>
mov    -0x20(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   10c0 <inet_aton@plt>
cmp    $0x0,%rax
jne    131b <bind_tohost_v2+0x12b>
mov    0x2cc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
lea    0xd25(%rip),%rdi
call   1040 <gettext@plt>
mov    -0x68(%rbp),%edi
mov    %rax,%rsi
mov    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x38(%rbp),%rdi
add    $0xc,%rdi
add    $0x4,%rdi
lea    -0x60(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
jmp    133a <bind_tohost_v2+0x14a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x58(%rbp)
lea    -0x38(%rbp),%rdi
add    $0xc,%rdi
lea    -0x58(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    0x2c63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2c33(%rip),%rax
mov    (%rax),%esi
mov    0x2c3a(%rip),%rax
mov    (%rax),%edx
lea    0xcb9(%rip),%rcx
call   10d0 <clnt_create@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13e7 <bind_tohost_v2+0x1f7>
mov    0x2c0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
lea    0xc96(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,-0x70(%rbp)
mov    0x2bd2(%rip),%rax
mov    (%rax),%edi
call   10e0 <yperr_string@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rsi
mov    %rax,%rdx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2bb3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14bc <bind_tohost_v2+0x2cc>
mov    $0x0,%al
call   10b0 <authunix_create_default@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rdi
mov    0x2b97(%rip),%rax
mov    (%rax),%esi
mov    0x2bde(%rip),%rax
mov    (%rax),%rax
mov    %eax,%edx
lea    -0x38(%rbp),%rax
mov    %eax,%ecx
mov    0x2bb4(%rip),%rax
mov    (%rax),%rax
mov    %eax,%r8d
mov    -0x40(%rbp),%rax
xor    %r9d,%r9d
mov    %rax,(%rsp)
call   10f0 <clnt_call@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
je     14ac <bind_tohost_v2+0x2bc>
mov    0x2b6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
lea    0xc0a(%rip),%rdi
call   1040 <gettext@plt>
mov    -0x84(%rbp),%edi
mov    %rax,%rsi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    0xc06(%rip),%rdi
call   1040 <gettext@plt>
mov    -0x80(%rbp),%rdi
mov    %rax,%rsi
call   1080 <clnt_perror@plt>
mov    -0x50(%rbp),%rdi
call   1100 <clnt_destroy@plt>
mov    0x2aee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14bc <bind_tohost_v2+0x2cc>
mov    -0x50(%rbp),%rdi
call   1100 <clnt_destroy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bind_tohost_v2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
mov    0x2d8d(%rip),%rax
mov    (%rax),%edx
mov    0x2d64(%rip),%rax
mov    (%rax),%ecx
mov    %rbx,%rdi
call   1030 <getrpcport@plt>
mov    %eax,%edi
call   1050 <htons@plt>
test   %eax,%eax
je     13d4 <bind_tohost_v2+0x1e4>
mov    %eax,%ebp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
mov    0x2d91(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <gethostbyname2@plt>
test   %rax,%rax
je     126b <bind_tohost_v2+0x7b>
lea    0x20(%rsp),%rdi
mov    (%rax),%rax
mov    (%rax),%rsi
jmp    128b <bind_tohost_v2+0x9b>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   10c0 <inet_aton@plt>
test   %rax,%rax
je     13e6 <bind_tohost_v2+0x1f6>
lea    0x20(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    %r14,0x10(%rsp)
mov    %ebp,0xc(%rsp)
lea    0x1c(%rsp),%rdi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
call   10a0 <memcpy@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    0x2ce2(%rip),%rax
mov    (%rax),%esi
mov    0x2ce9(%rip),%rax
mov    (%rax),%edx
lea    0xd60(%rip),%rcx
mov    %r15,%rdi
call   10d0 <clnt_create@plt>
test   %rax,%rax
je     1384 <bind_tohost_v2+0x194>
mov    %rax,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   10b0 <authunix_create_default@plt>
mov    %eax,(%rbx)
mov    0x2c9a(%rip),%rax
mov    (%rax),%esi
mov    0x2ce1(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rcx
mov    0x2cbb(%rip),%rax
mov    (%rax),%r8d
movq   $0xf,(%rsp)
mov    %rbx,%rdi
xor    %r9d,%r9d
call   10f0 <clnt_call@plt>
test   %eax,%eax
je     13bf <bind_tohost_v2+0x1cf>
mov    0x2c76(%rip),%rax
mov    (%rax),%ebp
lea    0xd14(%rip),%rdi
call   1040 <gettext@plt>
mov    %ebp,%edi
mov    %rax,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
lea    0xd1e(%rip),%rdi
call   1040 <gettext@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1080 <clnt_perror@plt>
mov    %rbx,%rdi
call   1100 <clnt_destroy@plt>
mov    0x2c10(%rip),%rax
mov    (%rax),%ebp
jmp    13c7 <bind_tohost_v2+0x1d7>
mov    0x2c25(%rip),%rax
mov    (%rax),%ebx
lea    0xca8(%rip),%rdi
call   1040 <gettext@plt>
mov    %rax,%rbp
mov    0x2bed(%rip),%r14
mov    (%r14),%edi
call   10e0 <yperr_string@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%r14),%ebp
jmp    13c7 <bind_tohost_v2+0x1d7>
mov    %rbx,%rdi
call   1100 <clnt_destroy@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bd5(%rip),%rax
mov    (%rax),%ebp
lea    0xc1c(%rip),%rdi
jmp    13f6 <bind_tohost_v2+0x206>
mov    0x2bc3(%rip),%rax
mov    (%rax),%ebp
lea    0xc22(%rip),%rdi
call   1040 <gettext@plt>
mov    %ebp,%edi
mov    %rax,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.ypbind_setdom = type { i8*, i32, %struct.TYPE_7__ }
%struct.TYPE_7__ = type { i32, i32 }
%struct.hostent = type { i32** }
%struct.TYPE_8__ = type { i32 }
%struct.in_addr = type { i32 }
@__const.bind_tohost_v2.tv = %struct.timeval { i32 15, i32 0 }
@YPPROG = global i32 0
@YPPROC_NULL = global i32 0
@IPPROTO_UDP = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"%s not running ypserv.\0A\00"
@AF_INET = global i32 0
@.str.1 = [32 x i8] c"can't find IPv4 address for %s\0A\00"
@YPVERS = global i32 0
@YPBINDPROG = global i32 0
@YPBINDVERS = global i32 0
@.str.2 = [4 x i8] c"udp\00"
@.str.3 = [27 x i8] c"can't yp_bind: Reason: %s\0A\00"
@YPERR_YPBIND = global i32 0
@YPBINDPROC_SETDOM = global i32 0
@xdr_ypbind_setdom = global i64 0
@xdr_void = global i64 0
@.str.4 = [40 x i8] c"Cannot ypset for domain %s on host %s.\0A\00"
@.str.5 = [7 x i8] c"Reason\00"
define i32 @bind_tohost_v2(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.ypbind_setdom
%9 = alloca %struct.timeval
%10 = alloca %struct.hostent*
%11 = alloca %struct.TYPE_8__*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.in_addr
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%16 = bitcast %struct.timeval* %9 to i8*
%17 = load i8*, i8** %7
%18 = load i32, i32* @YPPROG
%19 = load i32, i32* @YPPROC_NULL
%20 = load i32, i32* @IPPROTO_UDP
%21 = call i32 @getrpcport(i8* %17, i32 %18, i32 %19, i32 %20)
%22 = call i32 @htons(i32 %21)
store i32 %22, i32* %12
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %3
%25 = load i32, i32* @stderr
%26 = call i8* @gettext(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%27 = load i8*, i8** %7
%28 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %25, i8* %26, i8* %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %3
%31 = call i32 @memset(%struct.ypbind_setdom* %8, i8 signext 0, i32 24)
%32 = load i8*, i8** %7
%33 = load i32, i32* @AF_INET
%34 = call %struct.hostent* @gethostbyname2(i8* %32, i32 %33)
store %struct.hostent* %34, %struct.hostent** %10
%35 = icmp ne %struct.hostent* %34, null
br i1 %35, label %36, label %45
36: ; preds = %30
%37 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %8, i32 0, i32 2
%38 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %37, i32 0, i32 1
%39 = load %struct.hostent*, %struct.hostent** %10
%40 = getelementptr inbounds %struct.hostent, %struct.hostent* %39, i32 0, i32 0
%41 = load i32**, i32*** %40
%42 = getelementptr inbounds i32*, i32** %41, i64 0
%43 = load i32*, i32** %42
%44 = call i32 @memcpy(i32* %38, i32* %43, i32 4)
br label %61
45: ; preds = %30
%46 = load i8*, i8** %7
%47 = call i64 @inet_aton(i8* %46, %struct.in_addr* %15)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %55
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = call i8* @gettext(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%52 = load i8*, i8** %7
%53 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %50, i8* %51, i8* %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %45
%56 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %8, i32 0, i32 2
%57 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %56, i32 0, i32 1
%58 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %15, i32 0, i32 0
%59 = call i32 @memcpy(i32* %57, i32* %58, i32 4)
br label %60
60: ; preds = %55
br label %61
61: ; preds = %60, %36
%62 = load i8*, i8** %6
%63 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %8, i32 0, i32 0
store i8* %62, i8** %63
%64 = load i32, i32* %12
store i32 %64, i32* %13
%65 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %8, i32 0, i32 2
%66 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %65, i32 0, i32 0
%67 = call i32 @memcpy(i32* %66, i32* %13, i32 4)
%68 = load i32, i32* @YPVERS
%69 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %8, i32 0, i32 1
store i32 %68, i32* %69
%70 = load i8*, i8** %5
%71 = load i32, i32* @YPBINDPROG
%72 = load i32, i32* @YPBINDVERS
%73 = call %struct.TYPE_8__* @clnt_create(i8* %70, i32 %71, i32 %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store %struct.TYPE_8__* %73, %struct.TYPE_8__** %11
%74 = load %struct.TYPE_8__*, %struct.TYPE_8__** %11
%75 = icmp eq %struct.TYPE_8__* %74, null
br i1 %75, label %76, label %83
76: ; preds = %61
%77 = load i32, i32* @stderr
%78 = call i8* @gettext(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%79 = load i32, i32* @YPERR_YPBIND
%80 = call i8* @yperr_string(i32 %79)
%81 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %77, i8* %78, i8* %80)
%82 = load i32, i32* @YPERR_YPBIND
store i32 %82, i32* %4
br label %114
83: ; preds = %61
%84 = call i32 (...) @authunix_create_default()
%85 = load %struct.TYPE_8__*, %struct.TYPE_8__** %11
%86 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %85, i32 0, i32 0
store i32 %84, i32* %86
%87 = load %struct.TYPE_8__*, %struct.TYPE_8__** %11
%88 = load i32, i32* @YPBINDPROC_SETDOM
%89 = load i64, i64* @xdr_ypbind_setdom
%90 = trunc i64 %89 to i32
%91 = ptrtoint %struct.ypbind_setdom* %8 to i32
%92 = load i64, i64* @xdr_void
%93 = trunc i64 %92 to i32
%94 = bitcast %struct.timeval* %9 to i64*
%95 = load i64, i64* %94
%96 = call i32 @clnt_call(%struct.TYPE_8__* %87, i32 %88, i32 %90, i32 %91, i32 %93, i32* null, i64 %95)
store i32 %96, i32* %14
%97 = load i32, i32* %14
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %111
99: ; preds = %83
%100 = load i32, i32* @stderr
%101 = call i8* @gettext(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%102 = load i8*, i8** %6
%103 = load i8*, i8** %5
%104 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %100, i8* %101, i8* %102, i8* %103)
%105 = load %struct.TYPE_8__*, %struct.TYPE_8__** %11
%106 = call i8* @gettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%107 = call i32 @clnt_perror(%struct.TYPE_8__* %105, i8* %106)
%108 = load %struct.TYPE_8__*, %struct.TYPE_8__** %11
%109 = call i32 @clnt_destroy(%struct.TYPE_8__* %108)
%110 = load i32, i32* @YPERR_YPBIND
store i32 %110, i32* %4
br label %114
111: ; preds = %83
%112 = load %struct.TYPE_8__*, %struct.TYPE_8__** %11
%113 = call i32 @clnt_destroy(%struct.TYPE_8__* %112)
store i32 0, i32* %4
br label %114
114: ; preds = %111, %99, %76
%115 = load i32, i32* %4
ret i32 %115
}

LLVM IR (-O2):
%struct.ypbind_setdom = type { i8*, i32, %struct.TYPE_7__ }
%struct.TYPE_7__ = type { i32, i32 }
%struct.in_addr = type { i32 }
%struct.hostent = type { i32** }
%struct.TYPE_8__ = type { i32 }
@YPPROG = global i32 0
@YPPROC_NULL = global i32 0
@IPPROTO_UDP = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"%s not running ypserv.\0A\00"
@AF_INET = global i32 0
@.str.1 = [32 x i8] c"can't find IPv4 address for %s\0A\00"
@YPVERS = global i32 0
@YPBINDPROG = global i32 0
@YPBINDVERS = global i32 0
@.str.2 = [4 x i8] c"udp\00"
@.str.3 = [27 x i8] c"can't yp_bind: Reason: %s\0A\00"
@YPERR_YPBIND = global i32 0
@YPBINDPROC_SETDOM = global i32 0
@xdr_ypbind_setdom = global i64 0
@xdr_void = global i64 0
@.str.4 = [40 x i8] c"Cannot ypset for domain %s on host %s.\0A\00"
@.str.5 = [7 x i8] c"Reason\00"
define i32 @bind_tohost_v2(i8* %0, i8* %1, i8* %2) {
%4 = alloca %struct.ypbind_setdom
%5 = alloca i32
%6 = alloca %struct.in_addr
%7 = bitcast %struct.ypbind_setdom* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast %struct.in_addr* %6 to i8*
%10 = load i32, i32* @YPPROG
%11 = load i32, i32* @YPPROC_NULL
%12 = load i32, i32* @IPPROTO_UDP
%13 = tail call i32 @getrpcport(i8* %2, i32 %10, i32 %11, i32 %12)
%14 = tail call i32 @htons(i32 %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = tail call i8* @gettext(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* %18, i8* %2)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %3
%22 = call i32 @memset(%struct.ypbind_setdom* %4, i8 signext 0, i32 24)
%23 = load i32, i32* @AF_INET
%24 = call %struct.hostent* @gethostbyname2(i8* %2, i32 %23)
%25 = icmp eq %struct.hostent* %24, null
br i1 %25, label %32, label %26
26: ; preds = %21
%27 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %4, i64 0, i32 2, i32 1
%28 = getelementptr inbounds %struct.hostent, %struct.hostent* %24, i64 0, i32 0
%29 = load i32**, i32*** %28
%30 = load i32*, i32** %29
%31 = call i32 @memcpy(i32* %27, i32* %30, i32 4)
br label %44
32: ; preds = %21
%33 = call i64 @inet_aton(i8* %2, %struct.in_addr* %6)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = load i32, i32* @stderr
%37 = call i8* @gettext(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %36, i8* %37, i8* %2)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %32
%41 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %4, i64 0, i32 2, i32 1
%42 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %6, i64 0, i32 0
%43 = call i32 @memcpy(i32* %41, i32* %42, i32 4)
br label %44
44: ; preds = %40, %26
%45 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %4, i64 0, i32 0
store i8* %1, i8** %45
store i32 %14, i32* %5
%46 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %4, i64 0, i32 2, i32 0
%47 = call i32 @memcpy(i32* %46, i32* %5, i32 4)
%48 = load i32, i32* @YPVERS
%49 = getelementptr inbounds %struct.ypbind_setdom, %struct.ypbind_setdom* %4, i64 0, i32 1
store i32 %48, i32* %49
%50 = load i32, i32* @YPBINDPROG
%51 = load i32, i32* @YPBINDVERS
%52 = call %struct.TYPE_8__* @clnt_create(i8* %0, i32 %50, i32 %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%53 = icmp eq %struct.TYPE_8__* %52, null
br i1 %53, label %54, label %61
54: ; preds = %44
%55 = load i32, i32* @stderr
%56 = call i8* @gettext(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%57 = load i32, i32* @YPERR_YPBIND
%58 = call i8* @yperr_string(i32 %57)
%59 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %55, i8* %56, i8* %58)
%60 = load i32, i32* @YPERR_YPBIND
br label %83
61: ; preds = %44
%62 = call i32 (...) @authunix_create_default()
%63 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %52, i64 0, i32 0
store i32 %62, i32* %63
%64 = load i32, i32* @YPBINDPROC_SETDOM
%65 = load i64, i64* @xdr_ypbind_setdom
%66 = trunc i64 %65 to i32
%67 = ptrtoint %struct.ypbind_setdom* %4 to i64
%68 = trunc i64 %67 to i32
%69 = load i64, i64* @xdr_void
%70 = trunc i64 %69 to i32
%71 = call i32 @clnt_call(%struct.TYPE_8__* %52, i32 %64, i32 %66, i32 %68, i32 %70, i32* null, i64 15)
%72 = icmp eq i32 %71, 0
br i1 %72, label %81, label %73
73: ; preds = %61
%74 = load i32, i32* @stderr
%75 = call i8* @gettext(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
%76 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %74, i8* %75, i8* %1, i8* %0)
%77 = call i8* @gettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%78 = call i32 @clnt_perror(%struct.TYPE_8__* %52, i8* %77)
%79 = call i32 @clnt_destroy(%struct.TYPE_8__* %52)
%80 = load i32, i32* @YPERR_YPBIND
br label %83
81: ; preds = %61
%82 = call i32 @clnt_destroy(%struct.TYPE_8__* %52)
br label %83
83: ; preds = %81, %73, %54
%84 = phi i32 [ %60, %54 ], [ %80, %73 ], [ 0, %81 ]
ret i32 %84
}