#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 /*<<< orphan*/ thetime;
struct timeval {
  unsigned long tv_sec;
  scalar_t__ tv_usec;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct servent {
  int /*<<< orphan*/ s_port;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ from;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EINTR;
scalar_t__ EIO;
scalar_t__ ETIMEDOUT;
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int SOCK_DGRAM;
int SOCK_STREAM;
scalar_t__ _connect(int, struct sockaddr *, int);
int _read(int, char *, int);
int _recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/ _rpc_dtablesize();
int _select(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
            int /*<<< orphan*/ *, struct timeval *);
int _sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int _socket(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ do_close(int);
scalar_t__ errno;
struct servent *getservbyname(char *, char *);
unsigned long ntohl(unsigned long);
int rtime(struct sockaddr_in *addrp, struct timeval *timep,
          struct timeval *timeout) {
  int s;
  fd_set readfds;
  int res;
  unsigned long thetime;
  struct sockaddr_in from;
  socklen_t fromlen;
  int type;
  struct servent *serv;
  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;
  if ((serv = getservbyname("time", "tcp")) == NULL) {
    return (-1);
  }
  addrp->sin_port = serv->s_port;
  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);
    }
    do {
      FD_ZERO(&readfds);
      FD_SET(s, &readfds);
      res = _select(_rpc_dtablesize(), &readfds, (fd_set *)NULL, (fd_set *)NULL,
                    timeout);
    } while (res < 0 && errno == EINTR);
    if (res <= 0) {
      if (res == 0) {
        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)) {
    errno = EIO;
    return (-1);
  }
  thetime = ntohl(thetime);
  timep->tv_sec =
      thetime - (unsigned long)(60 * 60 * 24 *
                                (365 * (unsigned long)(1970 - 1900) +
                                 ((unsigned 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    11f0 <rtime+0x30>
mov    0x2de2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
jmp    11fc <rtime+0x3c>
mov    0x2de9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%esi
xor    %edx,%edx
call   1080 <_socket@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1228 <rtime+0x68>
movl   $0xffffffff,-0x4(%rbp)
jmp    147d <rtime+0x2bd>
mov    0x2db9(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
lea    0xdc1(%rip),%rdi
lea    0xdbf(%rip),%rsi
call   1040 <getservbyname@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    1265 <rtime+0xa5>
movl   $0xffffffff,-0x4(%rbp)
jmp    147d <rtime+0x2bd>
mov    -0x50(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%eax
mov    0x2d65(%rip),%rcx
cmp    (%rcx),%eax
jne    13b1 <rtime+0x1f1>
mov    -0x24(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    -0x10(%rbp),%r8
mov    $0x8,%r9d
xor    %ecx,%ecx
mov    %r9d,%edx
call   1090 <_sendto@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    12bf <rtime+0xff>
mov    -0x24(%rbp),%edi
call   10b0 <do_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    147d <rtime+0x2bd>
jmp    12c4 <rtime+0x104>
lea    -0x28(%rbp),%rdi
call   1070 <FD_ZERO@plt>
mov    -0x24(%rbp),%edi
lea    -0x28(%rbp),%rsi
call   10e0 <FD_SET@plt>
mov    $0x0,%al
call   1050 <_rpc_dtablesize@plt>
mov    %eax,%edi
mov    -0x20(%rbp),%r8
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1060 <_select@plt>
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x51(%rbp)
jge    1322 <rtime+0x162>
mov    0x2cb1(%rip),%rax
mov    (%rax),%rax
mov    0x2c97(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    12c4 <rtime+0x104>
cmpl   $0x0,-0x2c(%rbp)
jg     1369 <rtime+0x1a9>
cmpl   $0x0,-0x2c(%rbp)
jne    1355 <rtime+0x195>
mov    0x2c70(%rip),%rax
mov    (%rax),%rcx
mov    0x2c6e(%rip),%rax
mov    %rcx,(%rax)
mov    -0x24(%rbp),%edi
call   10b0 <do_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    147d <rtime+0x2bd>
movl   $0x8,-0x44(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%r8
mov    $0x8,%edx
xor    %ecx,%ecx
lea    -0x44(%rbp),%r9
call   1030 <_recvfrom@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
call   10b0 <do_close@plt>
cmpl   $0x0,-0x2c(%rbp)
jge    13ac <rtime+0x1ec>
movl   $0xffffffff,-0x4(%rbp)
jmp    147d <rtime+0x2bd>
jmp    1417 <rtime+0x257>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x8,%edx
call   10a0 <_connect@plt>
cmp    $0x0,%rax
jge    13e0 <rtime+0x220>
mov    -0x24(%rbp),%edi
call   10b0 <do_close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    147d <rtime+0x2bd>
mov    -0x24(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x8,%edx
call   10c0 <_read@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
call   10b0 <do_close@plt>
cmpl   $0x0,-0x2c(%rbp)
jge    1412 <rtime+0x252>
movl   $0xffffffff,-0x4(%rbp)
jmp    147d <rtime+0x2bd>
jmp    1417 <rtime+0x257>
movslq -0x2c(%rbp),%rax
cmp    $0x8,%rax
je     1445 <rtime+0x285>
mov    0x2ba4(%rip),%rax
mov    (%rax),%rcx
mov    0x2b8a(%rip),%rax
mov    %rcx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    147d <rtime+0x2bd>
mov    -0x38(%rbp),%rdi
call   10d0 <ntohl@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rcx
movabs $0x83aa7e80,%rax
sub    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,0x8(%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,%rbx
mov    %rsi,0x10(%rsp)
mov    %rdi,%r12
test   %rdx,%rdx
jne    11e7 <rtime+0x27>
mov    0x2de3(%rip),%rax
jmp    11ee <rtime+0x2e>
mov    0x2df2(%rip),%rax
mov    (%rax),%ebp
mov    0x2df1(%rip),%r14
mov    (%r14),%edi
mov    %ebp,%esi
xor    %edx,%edx
call   1080 <_socket@plt>
mov    $0xffffffff,%r15d
test   %eax,%eax
js     138b <rtime+0x1cb>
mov    %eax,%r13d
mov    (%r14),%eax
mov    %eax,0x4(%r12)
lea    0xddd(%rip),%rdi
lea    0xddb(%rip),%rsi
call   1040 <getservbyname@plt>
test   %rax,%rax
je     138b <rtime+0x1cb>
mov    (%rax),%eax
mov    %eax,(%r12)
mov    0x2d9b(%rip),%rax
cmp    (%rax),%ebp
jne    12f6 <rtime+0x136>
mov    %rsp,%rsi
mov    %r13d,%edi
mov    $0x8,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    $0x8,%r9d
call   1090 <_sendto@plt>
test   %eax,%eax
js     1383 <rtime+0x1c3>
lea    0x1c(%rsp),%rbp
mov    0x2d44(%rip),%r12
mov    0x2d2d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
call   1070 <FD_ZERO@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
call   10e0 <FD_SET@plt>
xor    %eax,%eax
call   1050 <_rpc_dtablesize@plt>
mov    %eax,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   1060 <_select@plt>
test   %eax,%eax
jns    12c8 <rtime+0x108>
mov    (%r14),%rcx
cmp    %rcx,(%r12)
je     1290 <rtime+0xd0>
test   %eax,%eax
jle    1373 <rtime+0x1b3>
movl   $0x8,0xc(%rsp)
mov    %rsp,%rsi
lea    0x20(%rsp),%r8
lea    0xc(%rsp),%r9
mov    %r13d,%edi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1030 <_recvfrom@plt>
jmp    131b <rtime+0x15b>
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0x8,%edx
call   10a0 <_connect@plt>
test   %rax,%rax
js     1383 <rtime+0x1c3>
mov    %rsp,%rsi
mov    %r13d,%edi
mov    $0x8,%edx
call   10c0 <_read@plt>
mov    %eax,%ebx
mov    %r13d,%edi
call   10b0 <do_close@plt>
test   %ebx,%ebx
js     138b <rtime+0x1cb>
cmp    $0x8,%ebx
jne    135d <rtime+0x19d>
mov    (%rsp),%rdi
call   10d0 <ntohl@plt>
mov    %rax,(%rsp)
movabs $0xffffffff7c558180,%rcx
ff ff ff
add    %rax,%rcx
mov    0x10(%rsp),%rax
mov    %rcx,(%rax)
movq   $0x0,0x8(%rax)
xor    %r15d,%r15d
jmp    138b <rtime+0x1cb>
mov    0x2c6c(%rip),%rax
mov    (%rax),%rax
mov    0x2c52(%rip),%rcx
mov    %rax,(%rcx)
jmp    138b <rtime+0x1cb>
jne    1383 <rtime+0x1c3>
mov    0x2c3c(%rip),%rax
mov    (%rax),%rax
mov    %rax,(%r12)
mov    %r13d,%edi
call   10b0 <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.timeval = type { i64, i64 }
%struct.servent = type { i32 }
%struct.sockaddr = type { i32 }
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
@AF_INET = global i32 0
@.str = [5 x i8] c"time\00"
@.str.1 = [4 x i8] c"tcp\00"
@errno = global i64 0
@EINTR = global i64 0
@ETIMEDOUT = global i64 0
@EIO = global i64 0
define i32 @rtime(%struct.sockaddr_in* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca i32
%5 = alloca %struct.sockaddr_in*
%6 = alloca %struct.timeval*
%7 = alloca %struct.timeval*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca %struct.sockaddr_in
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.servent*
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %5
store %struct.timeval* %1, %struct.timeval** %6
store %struct.timeval* %2, %struct.timeval** %7
%16 = load %struct.timeval*, %struct.timeval** %7
%17 = icmp eq %struct.timeval* %16, null
br i1 %17, label %18, label %20
18: ; preds = %3
%19 = load i32, i32* @SOCK_STREAM
store i32 %19, i32* %14
br label %22
20: ; preds = %3
%21 = load i32, i32* @SOCK_DGRAM
store i32 %21, i32* %14
br label %22
22: ; preds = %20, %18
%23 = load i32, i32* @AF_INET
%24 = load i32, i32* %14
%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 %129
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 = call %struct.servent* @getservbyname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store %struct.servent* %33, %struct.servent** %15
%34 = icmp eq %struct.servent* %33, null
br i1 %34, label %35, label %36
35: ; preds = %29
store i32 -1, i32* %4
br label %129
36: ; preds = %29
%37 = load %struct.servent*, %struct.servent** %15
%38 = getelementptr inbounds %struct.servent, %struct.servent* %37, i32 0, i32 0
%39 = load i32, i32* %38
%40 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %40, i32 0, i32 0
store i32 %39, i32* %41
%42 = load i32, i32* %14
%43 = load i32, i32* @SOCK_DGRAM
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %95
45: ; preds = %36
%46 = load i32, i32* %8
%47 = bitcast i64* %11 to i8*
%48 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%49 = bitcast %struct.sockaddr_in* %48 to %struct.sockaddr*
%50 = call i32 @_sendto(i32 %46, i8* %47, i32 8, i32 0, %struct.sockaddr* %49, i32 8)
store i32 %50, i32* %10
%51 = load i32, i32* %10
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %45
%54 = load i32, i32* %8
%55 = call i32 @do_close(i32 %54)
store i32 -1, i32* %4
br label %129
56: ; preds = %45
br label %57
57: ; preds = %71, %56
%58 = call i32 @FD_ZERO(i32* %9)
%59 = load i32, i32* %8
%60 = call i32 @FD_SET(i32 %59, i32* %9)
%61 = call i32 (...) @_rpc_dtablesize()
%62 = load %struct.timeval*, %struct.timeval** %7
%63 = call i32 @_select(i32 %61, i32* %9, i32* null, i32* null, %struct.timeval* %62)
store i32 %63, i32* %10
br label %64
64: ; preds = %57
%65 = load i32, i32* %10
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = load i64, i64* @errno
%69 = load i64, i64* @EINTR
%70 = icmp eq i64 %68, %69
br label %71
71: ; preds = %67, %64
%72 = phi i1 [ false, %64 ], [ %70, %67 ]
br i1 %72, label %57, label %73
73: ; preds = %71
%74 = load i32, i32* %10
%75 = icmp sle i32 %74, 0
br i1 %75, label %76, label %84
76: ; preds = %73
%77 = load i32, i32* %10
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %76
%80 = load i64, i64* @ETIMEDOUT
store i64 %80, i64* @errno
br label %81
81: ; preds = %79, %76
%82 = load i32, i32* %8
%83 = call i32 @do_close(i32 %82)
store i32 -1, i32* %4
br label %129
84: ; preds = %73
store i32 8, i32* %13
%85 = load i32, i32* %8
%86 = bitcast i64* %11 to i8*
%87 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%88 = call i32 @_recvfrom(i32 %85, i8* %86, i32 8, i32 0, %struct.sockaddr* %87, i32* %13)
store i32 %88, i32* %10
%89 = load i32, i32* %8
%90 = call i32 @do_close(i32 %89)
%91 = load i32, i32* %10
%92 = icmp slt i32 %91, 0
br i1 %92, label %93, label %94
93: ; preds = %84
store i32 -1, i32* %4
br label %129
94: ; preds = %84
br label %114
95: ; preds = %36
%96 = load i32, i32* %8
%97 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%98 = bitcast %struct.sockaddr_in* %97 to %struct.sockaddr*
%99 = call i64 @_connect(i32 %96, %struct.sockaddr* %98, i32 8)
%100 = icmp slt i64 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %95
%102 = load i32, i32* %8
%103 = call i32 @do_close(i32 %102)
store i32 -1, i32* %4
br label %129
104: ; preds = %95
%105 = load i32, i32* %8
%106 = bitcast i64* %11 to i8*
%107 = call i32 @_read(i32 %105, i8* %106, i32 8)
store i32 %107, i32* %10
%108 = load i32, i32* %8
%109 = call i32 @do_close(i32 %108)
%110 = load i32, i32* %10
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %113
112: ; preds = %104
store i32 -1, i32* %4
br label %129
113: ; preds = %104
br label %114
114: ; preds = %113, %94
%115 = load i32, i32* %10
%116 = sext i32 %115 to i64
%117 = icmp ne i64 %116, 8
br i1 %117, label %118, label %120
118: ; preds = %114
%119 = load i64, i64* @EIO
store i64 %119, i64* @errno
store i32 -1, i32* %4
br label %129
120: ; preds = %114
%121 = load i64, i64* %11
%122 = call i64 @ntohl(i64 %121)
store i64 %122, i64* %11
%123 = load i64, i64* %11
%124 = sub i64 %123, 2208988800
%125 = load %struct.timeval*, %struct.timeval** %6
%126 = getelementptr inbounds %struct.timeval, %struct.timeval* %125, i32 0, i32 0
store i64 %124, i64* %126
%127 = load %struct.timeval*, %struct.timeval** %6
%128 = getelementptr inbounds %struct.timeval, %struct.timeval* %127, i32 0, i32 1
store i64 0, i64* %128
store i32 0, i32* %4
br label %129
129: ; preds = %120, %118, %112, %101, %93, %81, %53, %35, %28
%130 = load i32, i32* %4
ret i32 %130
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.timeval = type { i64, i64 }
%struct.servent = type { i32 }
%struct.sockaddr = type { i32 }
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
@AF_INET = global i32 0
@.str = [5 x i8] c"time\00"
@.str.1 = [4 x i8] c"tcp\00"
@errno = global i64 0
@EINTR = global i64 0
@ETIMEDOUT = global i64 0
@EIO = global i64 0
define i32 @rtime(%struct.sockaddr_in* %0, %struct.timeval* nocapture writeonly %1, %struct.timeval* %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = bitcast i32* %4 to i8*
%9 = bitcast i64* %5 to i8*
%10 = bitcast %struct.sockaddr_in* %6 to i8*
%11 = bitcast i32* %7 to i8*
%12 = icmp eq %struct.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 %79, 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 = tail call %struct.servent* @getservbyname(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq %struct.servent* %22, null
br i1 %23, label %79, label %24
24: ; preds = %19
%25 = getelementptr inbounds %struct.servent, %struct.servent* %22, i64 0, i32 0
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
store i32 %26, i32* %27
%28 = load i32, i32* @SOCK_DGRAM
%29 = icmp eq i32 %15, %28
%30 = bitcast %struct.sockaddr_in* %0 to %struct.sockaddr*
br i1 %29, label %31, label %59
31: ; preds = %24
%32 = call i32 @_sendto(i32 %17, i8* %9, i32 8, i32 0, %struct.sockaddr* %30, i32 8)
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @do_close(i32 %17)
br label %79
36: ; preds = %31, %36
%37 = call i32 @FD_ZERO(i32* %4)
%38 = call i32 @FD_SET(i32 %17, i32* %4)
%39 = call i32 (...) @_rpc_dtablesize()
%40 = call i32 @_select(i32 %39, i32* %4, i32* null, i32* null, %struct.timeval* %2)
%41 = icmp slt i32 %40, 0
%42 = load i64, i64* @errno
%43 = load i64, i64* @EINTR
%44 = icmp eq i64 %42, %43
%45 = select i1 %41, i1 %44, i1 false
br i1 %45, label %36, label %46
46: ; preds = %36
%47 = icmp slt i32 %40, 1
br i1 %47, label %48, label %54
48: ; preds = %46
%49 = icmp eq i32 %40, 0
br i1 %49, label %50, label %52
50: ; preds = %48
%51 = load i64, i64* @ETIMEDOUT
store i64 %51, i64* @errno
br label %52
52: ; preds = %50, %48
%53 = call i32 @do_close(i32 %17)
br label %79
54: ; preds = %46
store i32 8, i32* %7
%55 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%56 = call i32 @_recvfrom(i32 %17, i8* %9, i32 8, i32 0, %struct.sockaddr* %55, i32* %7)
%57 = call i32 @do_close(i32 %17)
%58 = icmp slt i32 %56, 0
br i1 %58, label %79, label %68
59: ; preds = %24
%60 = tail call i64 @_connect(i32 %17, %struct.sockaddr* %30, i32 8)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = tail call i32 @do_close(i32 %17)
br label %79
64: ; preds = %59
%65 = call i32 @_read(i32 %17, i8* %9, i32 8)
%66 = call i32 @do_close(i32 %17)
%67 = icmp slt i32 %65, 0
br i1 %67, label %79, label %68
68: ; preds = %64, %54
%69 = phi i32 [ %56, %54 ], [ %65, %64 ]
%70 = icmp eq i32 %69, 8
br i1 %70, label %73, label %71
71: ; preds = %68
%72 = load i64, i64* @EIO
store i64 %72, i64* @errno
br label %79
73: ; preds = %68
%74 = load i64, i64* %5
%75 = call i64 @ntohl(i64 %74)
store i64 %75, i64* %5
%76 = add i64 %75, -2208988800
%77 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
store i64 %76, i64* %77
%78 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
store i64 0, i64* %78
br label %79
79: ; preds = %64, %54, %19, %3, %73, %71, %62, %52, %34
%80 = phi i32 [ -1, %34 ], [ -1, %52 ], [ -1, %71 ], [ 0, %73 ], [ -1, %62 ], [ -1, %3 ], [ -1, %19 ], [ -1, %54 ], [ -1, %64 ]
ret i32 %80
}