#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 */
typedef int uint32_t;
typedef int u_long;
typedef int /*<<< orphan*/ thetime;
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct rpc_timeval {
  int tv_sec;
  int tv_usec;
};
struct pollfd {
  int fd;
  int /*<<< orphan*/ events;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ from;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EINTR;
int /*<<< orphan*/ EIO;
int /*<<< orphan*/ ETIMEDOUT;
int /*<<< orphan*/ IPPORT_TIMESERVER;
int /*<<< orphan*/ POLLIN;
int SOCK_DGRAM;
int SOCK_STREAM;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ do_close(int);
scalar_t__ errno;
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int ntohl(int);
int poll(struct pollfd *, int, int);
int read(int, char *, int);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int, int /*<<< orphan*/);
int rtime(struct sockaddr_in *addrp, struct rpc_timeval *timep,
          struct rpc_timeval *timeout) {
  int s;
  struct pollfd fd;
  int milliseconds;
  int res;
  uint32_t thetime;
  struct sockaddr_in from;
  socklen_t fromlen;
  int type;
  if (timeout == NULL)
    type = SOCK_STREAM;
  else
    type = SOCK_DGRAM;
  s = socket(AF_INET, type, 0);
  if (s < 0)
    return (-1);
  addrp->sin_family = AF_INET;
  addrp->sin_port = htons(IPPORT_TIMESERVER);
  if (type == SOCK_DGRAM) {
    res = sendto(s, (char *)&thetime, sizeof(thetime), 0,
                 (struct sockaddr *)addrp, sizeof(*addrp));
    if (res < 0) {
      do_close(s);
      return -1;
    }
    milliseconds = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000);
    fd.fd = s;
    fd.events = POLLIN;
    do
      res = poll(&fd, 1, milliseconds);
    while (res < 0 && errno == EINTR);
    if (res <= 0) {
      if (res == 0)
        __set_errno(ETIMEDOUT);
      do_close(s);
      return (-1);
    }
    fromlen = sizeof(from);
    res = recvfrom(s, (char *)&thetime, sizeof(thetime), 0,
                   (struct sockaddr *)&from, &fromlen);
    do_close(s);
    if (res < 0)
      return -1;
  } else {
    if (connect(s, (struct sockaddr *)addrp, sizeof(*addrp)) < 0) {
      do_close(s);
      return -1;
    }
    res = read(s, (char *)&thetime, sizeof(thetime));
    do_close(s);
    if (res < 0)
      return (-1);
  }
  if (res != sizeof(thetime)) {
    __set_errno(EIO);
    return -1;
  }
  thetime = ntohl(thetime);
  timep->tv_sec =
      thetime -
      (u_long)(60 * 60 * 24 *
               (365 * (u_long)(1970 - 1900) + ((u_long)(1970 - 1900) / 4)));
  timep->tv_usec = 0;
  return 0;
}


x86 assembly (clang, -O0):
<rtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d0 <rtime+0x30>
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
jmp    11dc <rtime+0x3c>
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1208 <rtime+0x68>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <rtime+0x296>
mov    0x2dd9(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
call   1040 <htons@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%eax
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%eax
jne    137c <rtime+0x1dc>
mov    -0x24(%rbp),%edi
lea    -0x3c(%rbp),%rsi
mov    -0x10(%rbp),%r8
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0x8,%r9d
call   1050 <sendto@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    127e <rtime+0xde>
mov    -0x24(%rbp),%edi
call   1090 <do_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <rtime+0x296>
mov    -0x20(%rbp),%rax
imul   $0x3e8,(%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x34(%rbp),%edx
lea    -0x30(%rbp),%rdi
mov    $0x1,%esi
call   1080 <poll@plt>
mov    %eax,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x38(%rbp)
mov    %al,-0x55(%rbp)
jge    12f3 <rtime+0x153>
mov    0x2cd8(%rip),%rax
mov    (%rax),%rax
mov    0x2cbe(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    12b6 <rtime+0x116>
cmpl   $0x0,-0x38(%rbp)
jg     1334 <rtime+0x194>
cmpl   $0x0,-0x38(%rbp)
jne    1320 <rtime+0x180>
mov    0x2c97(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    -0x24(%rbp),%edi
call   1090 <do_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <rtime+0x296>
movl   $0x8,-0x4c(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x3c(%rbp),%rsi
lea    -0x48(%rbp),%r8
mov    $0x4,%edx
xor    %ecx,%ecx
lea    -0x4c(%rbp),%r9
call   1070 <recvfrom@plt>
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
call   1090 <do_close@plt>
cmpl   $0x0,-0x38(%rbp)
jge    1377 <rtime+0x1d7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <rtime+0x296>
jmp    13e2 <rtime+0x242>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   10a0 <connect@plt>
cmp    $0x0,%rax
jge    13ab <rtime+0x20b>
mov    -0x24(%rbp),%edi
call   1090 <do_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <rtime+0x296>
mov    -0x24(%rbp),%edi
lea    -0x3c(%rbp),%rsi
mov    $0x4,%edx
call   1060 <read@plt>
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%edi
call   1090 <do_close@plt>
cmpl   $0x0,-0x38(%rbp)
jge    13dd <rtime+0x23d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <rtime+0x296>
jmp    13e2 <rtime+0x242>
movslq -0x38(%rbp),%rax
cmp    $0x4,%rax
je     140a <rtime+0x26a>
mov    0x2bd1(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1436 <rtime+0x296>
mov    -0x3c(%rbp),%edi
call   10b0 <ntohl@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%ecx
sub    $0x83aa7e80,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,0x4(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtime>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r13
mov    %rdi,%rbp
test   %rdx,%rdx
mov    %rsi,0x18(%rsp)
jne    11c7 <rtime+0x27>
mov    0x2dfb(%rip),%rax
jmp    11ce <rtime+0x2e>
mov    0x2e12(%rip),%rax
mov    (%rax),%ebx
mov    0x2e11(%rip),%r14
mov    (%r14),%edi
mov    %ebx,%esi
xor    %edx,%edx
call   10c0 <socket@plt>
mov    $0xffffffff,%r15d
test   %eax,%eax
js     135f <rtime+0x1bf>
mov    %eax,%r12d
mov    (%r14),%eax
mov    %eax,0x4(%rbp)
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
call   1040 <htons@plt>
mov    %eax,0x0(%rbp)
mov    0x2dce(%rip),%rax
cmp    (%rax),%ebx
jne    12dc <rtime+0x13c>
lea    0x8(%rsp),%rsi
mov    %r12d,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    %rbp,%r8
mov    $0x8,%r9d
call   1050 <sendto@plt>
test   %eax,%eax
js     1357 <rtime+0x1b7>
imul   $0x3e8,0x0(%r13),%eax
movslq 0x4(%r13),%rcx
imul   $0x10624dd3,%rcx,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rbx
add    %ecx,%ebx
add    %eax,%ebx
mov    %r12d,0x10(%rsp)
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
lea    0x10(%rsp),%r13
mov    0x2d39(%rip),%rbp
mov    0x2d22(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1080 <poll@plt>
test   %eax,%eax
jns    12ac <rtime+0x10c>
mov    (%r14),%rcx
cmp    %rcx,0x0(%rbp)
je     1290 <rtime+0xf0>
test   %eax,%eax
jle    1347 <rtime+0x1a7>
movl   $0x8,0xc(%rsp)
lea    0x8(%rsp),%rsi
lea    0x20(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %r12d,%edi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1070 <recvfrom@plt>
jmp    1303 <rtime+0x163>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x8,%edx
call   10a0 <connect@plt>
test   %rax,%rax
js     1357 <rtime+0x1b7>
lea    0x8(%rsp),%rsi
mov    %r12d,%edi
mov    $0x4,%edx
call   1060 <read@plt>
mov    %eax,%ebx
mov    %r12d,%edi
call   1090 <do_close@plt>
test   %ebx,%ebx
js     135f <rtime+0x1bf>
cmp    $0x4,%ebx
jne    1337 <rtime+0x197>
mov    0x8(%rsp),%edi
call   10b0 <ntohl@plt>
add    $0x7c558180,%eax
mov    0x18(%rsp),%rcx
mov    %eax,(%rcx)
movl   $0x0,0x4(%rcx)
xor    %r15d,%r15d
jmp    135f <rtime+0x1bf>
mov    0x2c8a(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
jmp    135f <rtime+0x1bf>
jne    1357 <rtime+0x1b7>
mov    0x2c60(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    %r12d,%edi
call   1090 <do_close@plt>
mov    %r15d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.rpc_timeval = type { i32, i32 }
%struct.pollfd = type { i32, i32 }
%struct.sockaddr = type { i32 }
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
@AF_INET = global i32 0
@IPPORT_TIMESERVER = global i32 0
@POLLIN = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@ETIMEDOUT = global i32 0
@EIO = global i32 0
define i32 @rtime(%struct.sockaddr_in* %0, %struct.rpc_timeval* %1, %struct.rpc_timeval* %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr_in*
%6 = alloca %struct.rpc_timeval*
%7 = alloca %struct.rpc_timeval*
%8 = alloca i32
%9 = alloca %struct.pollfd
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca %struct.sockaddr_in
%14 = alloca i32
%15 = alloca i32
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %5
store %struct.rpc_timeval* %1, %struct.rpc_timeval** %6
store %struct.rpc_timeval* %2, %struct.rpc_timeval** %7
%16 = load %struct.rpc_timeval*, %struct.rpc_timeval** %7
%17 = icmp eq %struct.rpc_timeval* %16, null
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = load i32, i32* @SOCK_STREAM
store i32 %19, i32* %15
br label %22
20: ; preds = %3
%21 = load i32, i32* @SOCK_DGRAM
store i32 %21, i32* %15
br label %22
22: ; preds = %20, %18
%23 = load i32, i32* @AF_INET
%24 = load i32, i32* %15
%25 = call i32 @socket(i32 %23, i32 %24, i32 0)
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 -1, i32* %4
br label %135
29: ; preds = %22
%30 = load i32, i32* @AF_INET
%31 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %31, i32 0, i32 1
store i32 %30, i32* %32
%33 = load i32, i32* @IPPORT_TIMESERVER
%34 = call i32 @htons(i32 %33)
%35 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %35, i32 0, i32 0
store i32 %34, i32* %36
%37 = load i32, i32* %15
%38 = load i32, i32* @SOCK_DGRAM
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %100
40: ; preds = %29
%41 = load i32, i32* %8
%42 = bitcast i32* %12 to i8*
%43 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%44 = bitcast %struct.sockaddr_in* %43 to %struct.sockaddr*
%45 = call i32 @sendto(i32 %41, i8* %42, i32 4, i32 0, %struct.sockaddr* %44, i32 8)
store i32 %45, i32* %11
%46 = load i32, i32* %11
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %40
%49 = load i32, i32* %8
%50 = call i32 @do_close(i32 %49)
store i32 -1, i32* %4
br label %135
51: ; preds = %40
%52 = load %struct.rpc_timeval*, %struct.rpc_timeval** %7
%53 = getelementptr inbounds %struct.rpc_timeval, %struct.rpc_timeval* %52, i32 0, i32 0
%54 = load i32, i32* %53
%55 = mul nsw i32 %54, 1000
%56 = load %struct.rpc_timeval*, %struct.rpc_timeval** %7
%57 = getelementptr inbounds %struct.rpc_timeval, %struct.rpc_timeval* %56, i32 0, i32 1
%58 = load i32, i32* %57
%59 = sdiv i32 %58, 1000
%60 = add nsw i32 %55, %59
store i32 %60, i32* %10
%61 = load i32, i32* %8
%62 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %9, i32 0, i32 0
store i32 %61, i32* %62
%63 = load i32, i32* @POLLIN
%64 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %9, i32 0, i32 1
store i32 %63, i32* %64
br label %65
65: ; preds = %75, %51
%66 = load i32, i32* %10
%67 = call i32 @poll(%struct.pollfd* %9, i32 1, i32 %66)
store i32 %67, i32* %11
br label %68
68: ; preds = %65
%69 = load i32, i32* %11
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %75
71: ; preds = %68
%72 = load i64, i64* @errno
%73 = load i64, i64* @EINTR
%74 = icmp eq i64 %72, %73
br label %75
75: ; preds = %71, %68
%76 = phi i1 [ false, %68 ], [ %74, %71 ]
br i1 %76, label %65, label %77
77: ; preds = %75
%78 = load i32, i32* %11
%79 = icmp sle i32 %78, 0
br i1 %79, label %80, label %89
80: ; preds = %77
%81 = load i32, i32* %11
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = load i32, i32* @ETIMEDOUT
%85 = call i32 @__set_errno(i32 %84)
br label %86
86: ; preds = %83, %80
%87 = load i32, i32* %8
%88 = call i32 @do_close(i32 %87)
store i32 -1, i32* %4
br label %135
89: ; preds = %77
store i32 8, i32* %14
%90 = load i32, i32* %8
%91 = bitcast i32* %12 to i8*
%92 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%93 = call i32 @recvfrom(i32 %90, i8* %91, i32 4, i32 0, %struct.sockaddr* %92, i32* %14)
store i32 %93, i32* %11
%94 = load i32, i32* %8
%95 = call i32 @do_close(i32 %94)
%96 = load i32, i32* %11
%97 = icmp slt i32 %96, 0
br i1 %97, label %98, label %99
98: ; preds = %89
store i32 -1, i32* %4
br label %135
99: ; preds = %89
br label %119
100: ; preds = %29
%101 = load i32, i32* %8
%102 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%103 = bitcast %struct.sockaddr_in* %102 to %struct.sockaddr*
%104 = call i64 @connect(i32 %101, %struct.sockaddr* %103, i32 8)
%105 = icmp slt i64 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %100
%107 = load i32, i32* %8
%108 = call i32 @do_close(i32 %107)
store i32 -1, i32* %4
br label %135
109: ; preds = %100
%110 = load i32, i32* %8
%111 = bitcast i32* %12 to i8*
%112 = call i32 @read(i32 %110, i8* %111, i32 4)
store i32 %112, i32* %11
%113 = load i32, i32* %8
%114 = call i32 @do_close(i32 %113)
%115 = load i32, i32* %11
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %118
117: ; preds = %109
store i32 -1, i32* %4
br label %135
118: ; preds = %109
br label %119
119: ; preds = %118, %99
%120 = load i32, i32* %11
%121 = sext i32 %120 to i64
%122 = icmp ne i64 %121, 4
br i1 %122, label %123, label %126
123: ; preds = %119
%124 = load i32, i32* @EIO
%125 = call i32 @__set_errno(i32 %124)
store i32 -1, i32* %4
br label %135
126: ; preds = %119
%127 = load i32, i32* %12
%128 = call i32 @ntohl(i32 %127)
store i32 %128, i32* %12
%129 = load i32, i32* %12
%130 = sub nsw i32 %129, -2085978496
%131 = load %struct.rpc_timeval*, %struct.rpc_timeval** %6
%132 = getelementptr inbounds %struct.rpc_timeval, %struct.rpc_timeval* %131, i32 0, i32 0
store i32 %130, i32* %132
%133 = load %struct.rpc_timeval*, %struct.rpc_timeval** %6
%134 = getelementptr inbounds %struct.rpc_timeval, %struct.rpc_timeval* %133, i32 0, i32 1
store i32 0, i32* %134
store i32 0, i32* %4
br label %135
135: ; preds = %126, %123, %117, %106, %98, %86, %48, %28
%136 = load i32, i32* %4
ret i32 %136
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.rpc_timeval = type { i32, i32 }
%struct.pollfd = type { i32, i32 }
%struct.sockaddr = type { i32 }
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
@AF_INET = global i32 0
@IPPORT_TIMESERVER = global i32 0
@POLLIN = global i32 0
@errno = global i64 0
@EINTR = global i64 0
@ETIMEDOUT = global i32 0
@EIO = global i32 0
define i32 @rtime(%struct.sockaddr_in* %0, %struct.rpc_timeval* nocapture writeonly %1, %struct.rpc_timeval* %2) {
%4 = alloca %struct.pollfd
%5 = alloca i32
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = bitcast %struct.pollfd* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast %struct.sockaddr_in* %6 to i8*
%11 = bitcast i32* %7 to i8*
%12 = icmp eq %struct.rpc_timeval* %2, null
%13 = load i32, i32* @SOCK_STREAM
%14 = load i32, i32* @SOCK_DGRAM
%15 = select i1 %12, i32 %13, i32 %14
%16 = load i32, i32* @AF_INET
%17 = tail call i32 @socket(i32 %16, i32 %15, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %86, label %19
19: ; preds = %3
%20 = load i32, i32* @AF_INET
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 1
store i32 %20, i32* %21
%22 = load i32, i32* @IPPORT_TIMESERVER
%23 = tail call i32 @htons(i32 %22)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
store i32 %23, i32* %24
%25 = load i32, i32* @SOCK_DGRAM
%26 = icmp eq i32 %15, %25
%27 = bitcast %struct.sockaddr_in* %0 to %struct.sockaddr*
br i1 %26, label %28, label %65
28: ; preds = %19
%29 = call i32 @sendto(i32 %17, i8* %9, i32 4, i32 0, %struct.sockaddr* %27, i32 8)
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @do_close(i32 %17)
br label %86
33: ; preds = %28
%34 = getelementptr inbounds %struct.rpc_timeval, %struct.rpc_timeval* %2, i64 0, i32 0
%35 = load i32, i32* %34
%36 = mul nsw i32 %35, 1000
%37 = getelementptr inbounds %struct.rpc_timeval, %struct.rpc_timeval* %2, i64 0, i32 1
%38 = load i32, i32* %37
%39 = sdiv i32 %38, 1000
%40 = add nsw i32 %39, %36
%41 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %4, i64 0, i32 0
store i32 %17, i32* %41
%42 = load i32, i32* @POLLIN
%43 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %4, i64 0, i32 1
store i32 %42, i32* %43
br label %44
44: ; preds = %44, %33
%45 = call i32 @poll(%struct.pollfd* %4, i32 1, i32 %40)
%46 = icmp slt i32 %45, 0
%47 = load i64, i64* @errno
%48 = load i64, i64* @EINTR
%49 = icmp eq i64 %47, %48
%50 = select i1 %46, i1 %49, i1 false
br i1 %50, label %44, label %51
51: ; preds = %44
%52 = icmp slt i32 %45, 1
br i1 %52, label %53, label %60
53: ; preds = %51
%54 = icmp eq i32 %45, 0
br i1 %54, label %55, label %58
55: ; preds = %53
%56 = load i32, i32* @ETIMEDOUT
%57 = call i32 @__set_errno(i32 %56)
br label %58
58: ; preds = %55, %53
%59 = call i32 @do_close(i32 %17)
br label %86
60: ; preds = %51
store i32 8, i32* %7
%61 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%62 = call i32 @recvfrom(i32 %17, i8* %9, i32 4, i32 0, %struct.sockaddr* %61, i32* %7)
%63 = call i32 @do_close(i32 %17)
%64 = icmp slt i32 %62, 0
br i1 %64, label %86, label %74
65: ; preds = %19
%66 = tail call i64 @connect(i32 %17, %struct.sockaddr* %27, i32 8)
%67 = icmp slt i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = tail call i32 @do_close(i32 %17)
br label %86
70: ; preds = %65
%71 = call i32 @read(i32 %17, i8* %9, i32 4)
%72 = tail call i32 @do_close(i32 %17)
%73 = icmp slt i32 %71, 0
br i1 %73, label %86, label %74
74: ; preds = %70, %60
%75 = phi i32 [ %62, %60 ], [ %71, %70 ]
%76 = icmp eq i32 %75, 4
br i1 %76, label %80, label %77
77: ; preds = %74
%78 = load i32, i32* @EIO
%79 = call i32 @__set_errno(i32 %78)
br label %86
80: ; preds = %74
%81 = load i32, i32* %5
%82 = call i32 @ntohl(i32 %81)
%83 = add nsw i32 %82, 2085978496
%84 = getelementptr inbounds %struct.rpc_timeval, %struct.rpc_timeval* %1, i64 0, i32 0
store i32 %83, i32* %84
%85 = getelementptr inbounds %struct.rpc_timeval, %struct.rpc_timeval* %1, i64 0, i32 1
store i32 0, i32* %85
br label %86
86: ; preds = %70, %60, %3, %80, %77, %68, %58, %31
%87 = phi i32 [ -1, %31 ], [ -1, %58 ], [ -1, %77 ], [ 0, %80 ], [ -1, %68 ], [ -1, %3 ], [ -1, %60 ], [ -1, %70 ]
ret i32 %87
}