#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_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ uha;
struct tm {
  int dummy;
};
struct timezone {
  int dummy;
};
struct timeval {
  int /*<<< orphan*/ tv_usec;
  int /*<<< orphan*/ tv_sec;
};
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int sin_port;
  TYPE_1__ sin_addr;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ h_addr;
};
typedef int /*<<< orphan*/ client;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
int /*<<< orphan*/ bcopy(int /*<<< orphan*/, TYPE_1__ *, int /*<<< orphan*/);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
scalar_t__ gettimeofday(struct timeval *, struct timezone *);
int htons(int);
char *inet_ntoa(TYPE_1__);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ snprintf(char *, int, char *, int /*<<< orphan*/);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("usage: ./uclient <HA-ADDR> <HA-PORT>\n", argv[0]);
    return 0;
  }
  int sock;
  struct sockaddr_in uha, client;
  struct hostent *hp, *gethostbyname();
  char buf[1024];
  char fmt[64], out[64];
  int rval, seqnum;
  int i, seqno, fa;
  char *addr;
  struct timeval rcvtime;
  struct timezone zone;
  struct tm *tm;
  sock = socket(AF_INET, SOCK_DGRAM, 0);
  if (sock < 0) {
    perror("Opening datagram socket");
    exit(1);
  }
  client.sin_family = AF_INET;
  client.sin_addr.s_addr = INADDR_ANY;
  client.sin_port = 0;
  if (bind(sock, (struct sockaddr *)&client, sizeof(client)) < 0) {
    perror("binding socket name");
    exit(1);
  }
  uha.sin_family = AF_INET;
  hp = gethostbyname(argv[1]);
  if (hp == 0) {
    printf("%s: unknown host\n", argv[1]);
    exit(2);
  }
  bcopy(hp->h_addr, &uha.sin_addr, hp->h_length);
  uha.sin_port = htons(atoi(argv[2]));
  seqnum = 0;
  for (i = 0; i < 60; i++) {
    seqnum++;
    sprintf(buf, "%d %d %d", seqnum, 0, atoi(argv[2]));
    if ((rval = sendto(sock, buf, sizeof(buf), 0, (struct sockaddr *)&uha,
                       sizeof(uha))) < 0) {
      perror("writing on datagram socket");
    } else {
      if (gettimeofday(&rcvtime, &zone) < 0) {
        perror("getting time");
        exit(1);
      }
      if ((tm = localtime(&rcvtime.tv_sec)) != NULL) {
        strftime(fmt, sizeof fmt, "%H:%M:%S", tm);
        snprintf(out, sizeof out, fmt, rcvtime.tv_usec);
      }
      addr = inet_ntoa(uha.sin_addr);
      printf("Sequence Number = %2d Time = %s Dest %s:%d\n", seqnum, out, addr,
             htons(uha.sin_port));
      sleep(1);
    }
  }
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x520,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1264 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    154c <main+0x32c>
mov    0x2d7d(%rip),%rax
mov    (%rax),%rdi
mov    0x2d63(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12a1 <main+0x81>
lea    0xd94(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    12f3 <main+0xd3>
lea    0xd5a(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2cee(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x0,%al
call   10b0 <gethostbyname@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    133f <main+0x11f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   1120 <exit@plt>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
lea    -0x28(%rbp),%rsi
add    $0x4,%rsi
mov    -0x40(%rbp),%rax
mov    (%rax),%edx
call   10c0 <bcopy@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x4c8(%rbp)
movl   $0x0,-0x4cc(%rbp)
cmpl   $0x3c,-0x4cc(%rbp)
jge    153d <main+0x31d>
mov    -0x4c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c8(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x508(%rbp)
mov    -0x4c8(%rbp),%eax
mov    %eax,-0x4fc(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1100 <atoi@plt>
mov    -0x508(%rbp),%rdi
mov    -0x4fc(%rbp),%edx
mov    %eax,%r8d
lea    0xc86(%rip),%rsi
xor    %ecx,%ecx
call   1110 <sprintf@plt>
mov    -0x14(%rbp),%edi
lea    -0x440(%rbp),%rsi
lea    -0x28(%rbp),%r8
mov    $0x400,%edx
xor    %ecx,%ecx
mov    $0x10,%r9d
call   1090 <sendto@plt>
mov    %eax,-0x4c4(%rbp)
cmp    $0x0,%eax
jge    1425 <main+0x205>
lea    0xc52(%rip),%rdi
call   10f0 <perror@plt>
jmp    1524 <main+0x304>
lea    -0x4e8(%rbp),%rdi
lea    -0x4f0(%rbp),%rsi
call   1080 <gettimeofday@plt>
cmp    $0x0,%rax
jge    1458 <main+0x238>
lea    0xc3f(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
lea    -0x4e8(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x4f8(%rbp)
cmp    $0x0,%rax
je     14b6 <main+0x296>
lea    -0x480(%rbp),%rdi
mov    -0x4f8(%rbp),%rcx
mov    $0x40,%esi
lea    0xc02(%rip),%rdx
call   10e0 <strftime@plt>
lea    -0x4c0(%rbp),%rdi
lea    -0x480(%rbp),%rdx
mov    -0x4e8(%rbp),%ecx
mov    $0x40,%esi
call   1070 <snprintf@plt>
mov    -0x24(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x4e0(%rbp)
mov    -0x4c8(%rbp),%eax
mov    %eax,-0x51c(%rbp)
lea    -0x4c0(%rbp),%rax
mov    %rax,-0x518(%rbp)
mov    -0x4e0(%rbp),%rax
mov    %rax,-0x510(%rbp)
mov    -0x28(%rbp),%edi
call   1050 <htons@plt>
mov    -0x51c(%rbp),%esi
mov    -0x518(%rbp),%rdx
mov    -0x510(%rbp),%rcx
mov    %eax,%r8d
lea    0xb8b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1130 <sleep@plt>
jmp    1529 <main+0x309>
mov    -0x4cc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4cc(%rbp)
jmp    1384 <main+0x164>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x520,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4b8,%rsp
cmp    $0x1,%edi
jg     1257 <main+0x27>
lea    0xe57(%rip),%rdi
call   1040 <puts@plt>
jmp    140a <main+0x1da>
mov    %rsi,%rbp
mov    0x2d87(%rip),%rbx
mov    (%rbx),%rdi
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
test   %eax,%eax
js     1434 <main+0x204>
mov    %eax,%r13d
mov    (%rbx),%rax
mov    %rax,0x28(%rsp)
mov    0x2d52(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x24(%rsp)
movl   $0x0,0x20(%rsp)
lea    0x20(%rsp),%rsi
mov    %r13d,%edi
mov    $0x10,%edx
call   10e0 <bind@plt>
test   %rax,%rax
js     143d <main+0x20d>
mov    (%rbx),%rax
mov    %rax,0x10(%rsp)
mov    0x8(%rbp),%rdi
xor    %eax,%eax
call   10c0 <gethostbyname@plt>
test   %rax,%rax
je     1446 <main+0x216>
mov    (%rax),%edx
mov    0x4(%rax),%edi
lea    0xc(%rsp),%rsi
call   10d0 <bcopy@plt>
mov    0x10(%rbp),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,0x8(%rsp)
mov    $0x1,%ebx
lea    0xb0(%rsp),%r14
lea    0x30(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    0x10(%rbp),%rdi
call   1110 <atoi@plt>
mov    %r14,%rdi
lea    0xd1b(%rip),%rsi
mov    %ebx,%edx
xor    %ecx,%ecx
mov    %eax,%r8d
call   1120 <sprintf@plt>
mov    %r13d,%edi
mov    %r14,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
lea    0x8(%rsp),%r8
mov    $0x10,%r9d
call   10a0 <sendto@plt>
test   %eax,%eax
js     13f4 <main+0x1c4>
mov    %rsp,%rdi
lea    0x18(%rsp),%rsi
call   1090 <gettimeofday@plt>
test   %rax,%rax
js     141e <main+0x1ee>
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     13ae <main+0x17e>
mov    %rbp,%r15
lea    0x70(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x40,%esi
lea    0xcdf(%rip),%rdx
mov    %rax,%rcx
call   10f0 <strftime@plt>
mov    (%rsp),%ecx
mov    %r12,%rdi
mov    $0x40,%esi
mov    %rbp,%rdx
mov    %r15,%rbp
call   1080 <snprintf@plt>
mov    0xc(%rsp),%edi
call   1050 <inet_ntoa@plt>
mov    %rax,%r15
mov    0x8(%rsp),%edi
call   1060 <htons@plt>
lea    0xcae(%rip),%rdi
mov    %ebx,%esi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1140 <sleep@plt>
add    $0x1,%ebx
cmp    $0x3d,%ebx
jne    1310 <main+0xe0>
jmp    1402 <main+0x1d2>
lea    0xc4c(%rip),%rdi
call   1100 <perror@plt>
jmp    13e6 <main+0x1b6>
mov    %r13d,%edi
call   10b0 <close@plt>
xor    %eax,%eax
add    $0x4b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc3d(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
lea    0xbc5(%rip),%rdi
jmp    1425 <main+0x1f5>
lea    0xbd4(%rip),%rdi
jmp    1425 <main+0x1f5>
mov    0x8(%rbp),%rsi
lea    0xbdb(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x2,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_3__, i8* }
%struct.TYPE_3__ = type { i32 }
%struct.hostent = type { i32, i32 }
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
%struct.tm = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [38 x i8] c"usage: ./uclient <HA-ADDR> <HA-PORT>\0A\00"
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str.1 = [24 x i8] c"Opening datagram socket\00"
@INADDR_ANY = global i32 0
@.str.2 = [20 x i8] c"binding socket name\00"
@.str.3 = [18 x i8] c"%s: unknown host\0A\00"
@.str.4 = [9 x i8] c"%d %d %d\00"
@.str.5 = [27 x i8] c"writing on datagram socket\00"
@.str.6 = [13 x i8] c"getting time\00"
@.str.7 = [9 x i8] c"%H:%M:%S\00"
@.str.8 = [44 x i8] c"Sequence Number = %2d Time = %s Dest %s:%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.hostent*
%10 = alloca [1024 x i8]
%11 = alloca [64 x i8]
%12 = alloca [64 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca %struct.timeval
%20 = alloca %struct.timezone
%21 = alloca %struct.tm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 2
br i1 %23, label %24, label %29
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %27)
store i32 0, i32* %3
br label %141
29: ; preds = %2
%30 = load i8*, i8** @AF_INET
%31 = load i32, i32* @SOCK_DGRAM
%32 = call i32 @socket(i8* %30, i32 %31, i32 0)
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %29
%39 = load i8*, i8** @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i8* %39, i8** %40
%41 = load i32, i32* @INADDR_ANY
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%43 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %42, i32 0, i32 0
store i32 %41, i32* %43
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 0, i32* %44
%45 = load i32, i32* %6
%46 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%47 = call i64 @bind(i32 %45, %struct.sockaddr* %46, i32 16)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %38
%50 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %38
%53 = load i8*, i8** @AF_INET
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i8* %53, i8** %54
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call %struct.hostent* (i8*, ...) bitcast (%struct.hostent* (...)* @gethostbyname to %struct.hostent* (i8*, ...)*)(i8* %57)
store %struct.hostent* %58, %struct.hostent** %9
%59 = load %struct.hostent*, %struct.hostent** %9
%60 = icmp eq %struct.hostent* %59, null
br i1 %60, label %61, label %67
61: ; preds = %52
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %64)
%66 = call i32 @exit(i32 2)
unreachable
67: ; preds = %52
%68 = load %struct.hostent*, %struct.hostent** %9
%69 = getelementptr inbounds %struct.hostent, %struct.hostent* %68, i32 0, i32 1
%70 = load i32, i32* %69
%71 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%72 = load %struct.hostent*, %struct.hostent** %9
%73 = getelementptr inbounds %struct.hostent, %struct.hostent* %72, i32 0, i32 0
%74 = load i32, i32* %73
%75 = call i32 @bcopy(i32 %70, %struct.TYPE_3__* %71, i32 %74)
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 2
%78 = load i8*, i8** %77
%79 = call i32 @atoi(i8* %78)
%80 = call i32 @htons(i32 %79)
%81 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %80, i32* %81
store i32 0, i32* %14
store i32 0, i32* %15
br label %82
82: ; preds = %135, %67
%83 = load i32, i32* %15
%84 = icmp slt i32 %83, 60
br i1 %84, label %85, label %138
85: ; preds = %82
%86 = load i32, i32* %14
%87 = add nsw i32 %86, 1
store i32 %87, i32* %14
%88 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%89 = load i32, i32* %14
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 2
%92 = load i8*, i8** %91
%93 = call i32 @atoi(i8* %92)
%94 = call i32 @sprintf(i8* %88, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %89, i32 0, i32 %93)
%95 = load i32, i32* %6
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%97 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%98 = call i32 @sendto(i32 %95, i8* %96, i32 1024, i32 0, %struct.sockaddr* %97, i32 16)
store i32 %98, i32* %13
%99 = icmp slt i32 %98, 0
br i1 %99, label %100, label %102
100: ; preds = %85
%101 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %134
102: ; preds = %85
%103 = call i64 @gettimeofday(%struct.timeval* %19, %struct.timezone* %20)
%104 = icmp slt i64 %103, 0
br i1 %104, label %105, label %108
105: ; preds = %102
%106 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %102
%109 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%110 = call %struct.tm* @localtime(i32* %109)
store %struct.tm* %110, %struct.tm** %21
%111 = icmp ne %struct.tm* %110, null
br i1 %111, label %112, label %121
112: ; preds = %108
%113 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%114 = load %struct.tm*, %struct.tm** %21
%115 = call i32 @strftime(i8* %113, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), %struct.tm* %114)
%116 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%117 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%118 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 0
%119 = load i32, i32* %118
%120 = call i32 @snprintf(i8* %116, i32 64, i8* %117, i32 %119)
br label %121
121: ; preds = %112, %108
%122 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%123 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %122, i32 0, i32 0
%124 = load i32, i32* %123
%125 = call i8* @inet_ntoa(i32 %124)
store i8* %125, i8** %18
%126 = load i32, i32* %14
%127 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%128 = load i8*, i8** %18
%129 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
%130 = load i32, i32* %129
%131 = call i32 @htons(i32 %130)
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32 %126, i8* %127, i8* %128, i32 %131)
%133 = call i32 @sleep(i32 1)
br label %134
134: ; preds = %121, %100
br label %135
135: ; preds = %134
%136 = load i32, i32* %15
%137 = add nsw i32 %136, 1
store i32 %137, i32* %15
br label %82
138: ; preds = %82
%139 = load i32, i32* %6
%140 = call i32 @close(i32 %139)
store i32 0, i32* %3
br label %141
141: ; preds = %138, %24
%142 = load i32, i32* %3
ret i32 %142
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_3__, i8* }
%struct.TYPE_3__ = type { i32 }
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
%struct.sockaddr = type { i32 }
%struct.hostent = type { i32, i32 }
%struct.tm = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str.1 = [24 x i8] c"Opening datagram socket\00"
@INADDR_ANY = global i32 0
@.str.2 = [20 x i8] c"binding socket name\00"
@.str.3 = [18 x i8] c"%s: unknown host\0A\00"
@.str.4 = [9 x i8] c"%d %d %d\00"
@.str.5 = [27 x i8] c"writing on datagram socket\00"
@.str.6 = [13 x i8] c"getting time\00"
@.str.7 = [9 x i8] c"%H:%M:%S\00"
@.str.8 = [44 x i8] c"Sequence Number = %2d Time = %s Dest %s:%d\0A\00"
@str = [37 x i8] c"usage: ./uclient <HA-ADDR> <HA-PORT>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i8]
%6 = alloca [64 x i8]
%7 = alloca [64 x i8]
%8 = alloca %struct.timeval
%9 = alloca %struct.timezone
%10 = icmp slt i32 %0, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %101
13: ; preds = %2
%14 = bitcast %struct.sockaddr_in* %3 to i8*
%15 = bitcast %struct.sockaddr_in* %4 to i8*
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%19 = bitcast %struct.timeval* %8 to i8*
%20 = bitcast %struct.timezone* %9 to i8*
%21 = load i8*, i8** @AF_INET
%22 = load i32, i32* @SOCK_DGRAM
%23 = tail call i32 @socket(i8* %21, i32 %22, i32 0)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %13
%26 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %13
%29 = load i8*, i8** @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i8* %29, i8** %30
%31 = load i32, i32* @INADDR_ANY
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %31, i32* %32
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 0, i32* %33
%34 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%35 = call i64 @bind(i32 %23, %struct.sockaddr* %34, i32 16)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %28
%38 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %28
%41 = load i8*, i8** @AF_INET
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i8* %41, i8** %42
%43 = getelementptr inbounds i8*, i8** %1, i64 1
%44 = load i8*, i8** %43
%45 = call %struct.hostent* (i8*, ...) bitcast (%struct.hostent* (...)* @gethostbyname to %struct.hostent* (i8*, ...)*)(i8* %44)
%46 = icmp eq %struct.hostent* %45, null
br i1 %46, label %47, label %51
47: ; preds = %40
%48 = load i8*, i8** %43
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %48)
%50 = call i32 @exit(i32 2)
unreachable
51: ; preds = %40
%52 = getelementptr inbounds %struct.hostent, %struct.hostent* %45, i64 0, i32 1
%53 = load i32, i32* %52
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%55 = getelementptr inbounds %struct.hostent, %struct.hostent* %45, i64 0, i32 0
%56 = load i32, i32* %55
%57 = call i32 @bcopy(i32 %53, %struct.TYPE_3__* %54, i32 %56)
%58 = getelementptr inbounds i8*, i8** %1, i64 2
%59 = load i8*, i8** %58
%60 = call i32 @atoi(i8* %59)
%61 = call i32 @htons(i32 %60)
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %61, i32* %62
%63 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%64 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 1
%65 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i64 0, i32 0
%66 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %54, i64 0, i32 0
br label %67
67: ; preds = %51, %97
%68 = phi i32 [ 0, %51 ], [ %69, %97 ]
%69 = add nuw nsw i32 %68, 1
%70 = load i8*, i8** %58
%71 = call i32 @atoi(i8* %70)
%72 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %69, i32 0, i32 %71)
%73 = call i32 @sendto(i32 %23, i8* %16, i32 1024, i32 0, %struct.sockaddr* %63, i32 16)
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %67
%76 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %97
77: ; preds = %67
%78 = call i64 @gettimeofday(%struct.timeval* %8, %struct.timezone* %9)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %83
80: ; preds = %77
%81 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %77
%84 = call %struct.tm* @localtime(i32* %64)
%85 = icmp eq %struct.tm* %84, null
br i1 %85, label %90, label %86
86: ; preds = %83
%87 = call i32 @strftime(i8* %17, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), %struct.tm* %84)
%88 = load i32, i32* %65
%89 = call i32 @snprintf(i8* %18, i32 64, i8* %17, i32 %88)
br label %90
90: ; preds = %86, %83
%91 = load i32, i32* %66
%92 = call i8* @inet_ntoa(i32 %91)
%93 = load i32, i32* %62
%94 = call i32 @htons(i32 %93)
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0), i32 %69, i8* %18, i8* %92, i32 %94)
%96 = call i32 @sleep(i32 1)
br label %97
97: ; preds = %75, %90
%98 = icmp eq i32 %69, 60
br i1 %98, label %99, label %67
99: ; preds = %97
%100 = call i32 @close(i32 %23)
br label %101
101: ; preds = %99, %11
ret i32 0
}