#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*/ time_t;
struct tm {
  int tm_hour;
  int tm_min;
  int tm_sec;
  int tm_year;
  int tm_mon;
  int tm_mday;
};
struct sockaddr_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_flags;
};
typedef size_t socklen_t;
typedef int /*<<< orphan*/ cli;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ EXIT_FAILURE;
int NI_MAXHOST;
int NI_MAXSERV;
int /*<<< orphan*/ NI_NUMERICHOST;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ bind(int, struct sockaddr *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ getaddrinfo(char *, char *, struct addrinfo *,
                               struct addrinfo **);
int getnameinfo(struct sockaddr *, size_t, char *, int, char *, int,
                int /*<<< orphan*/);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, size_t *);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, size_t);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int args, char *argv[]) {
  struct addrinfo hints, *res;
  struct sockaddr_storage cli;
  char buff[81], host[NI_MAXHOST], serv[NI_MAXSERV];
  hints.ai_flags = AI_PASSIVE;
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_protocol = 0;
  getaddrinfo(argv[1], argv[2], &hints, &res);
  int sd = socket(res->ai_family, res->ai_socktype, 0);
  bind(sd, (struct sockaddr *)res->ai_addr, res->ai_addrlen);
  freeaddrinfo(res);
  int quit = 0;
  printf("start listening");
  while (!quit) {
    socklen_t clen = sizeof(cli);
    int c = recvfrom(sd, buff, 1, 0, (struct sockaddr *)&cli, &clen);
    if (c == -1) {
      perror("recvfrom");
      exit(EXIT_FAILURE);
    }
    c = getnameinfo((struct sockaddr *)&cli, clen, host, NI_MAXHOST, serv,
                    NI_MAXSERV, NI_NUMERICHOST);
    if (c) {
      perror("getnameinfo");
      exit(EXIT_FAILURE);
    }
    printf("host:%s port:%s msg:%s\n", host, serv, buff);
    if (buff[0] == 't') {
      printf("time requested");
      time_t tiemp = time(NULL);
      struct tm *stm = gmtime(&tiemp);
      sprintf(buff, "H:%d M:%d S:%d\n", stm->tm_hour, stm->tm_min, stm->tm_sec);
      c = 14;
    } else if (buff[0] == 'd') {
      printf("date requested");
      time_t tiemp = time(NULL);
      struct tm *stm = gmtime(&tiemp);
      sprintf(buff, "Year:%d Month:%d Day:%d\n", stm->tm_year, stm->tm_mon,
              stm->tm_mday);
      c = 23;
    } else if (buff[0] == 'q') {
      printf("quit requested");
      strcpy(buff, "Goodbye");
      c = 7;
      quit = 1;
    }
    buff[clen] = '\0';
    printf("%s\n", buff);
    printf("%d clen\n", clen);
    sendto(sd, buff, c, 0, (struct sockaddr *)&cli, clen);
  }
  close(sd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xf8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xb0(%rbp)
mov    0x2d93(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xf0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xb8(%rbp)
mov    0x2d78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   10f0 <getaddrinfo@plt>
mov    -0x40(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0xbc(%rbp)
mov    -0xbc(%rbp),%edi
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x40(%rbp),%rax
mov    (%rax),%edx
call   10a0 <bind@plt>
mov    -0x40(%rbp),%rdi
call   1100 <freeaddrinfo@plt>
movl   $0x0,-0xc0(%rbp)
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0xc0(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1320 <main+0x130>
jmp    15c4 <main+0x3d4>
movq   $0x4,-0xc8(%rbp)
mov    -0xbc(%rbp),%edi
lea    -0xa0(%rbp),%rsi
lea    -0x48(%rbp),%r8
mov    $0x1,%edx
xor    %ecx,%ecx
lea    -0xc8(%rbp),%r9
call   1090 <recvfrom@plt>
mov    %eax,-0xcc(%rbp)
cmpl   $0xffffffff,-0xcc(%rbp)
jne    137c <main+0x18c>
lea    0xca7(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0xf0(%rbp),%r8
mov    -0xf8(%rbp),%rdx
lea    -0x48(%rbp),%rdi
mov    -0xc8(%rbp),%rsi
mov    0x2c14(%rip),%rax
mov    (%rax),%ecx
mov    0x2c33(%rip),%rax
mov    (%rax),%r9d
mov    0x2c11(%rip),%rax
mov    (%rax),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1070 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,-0xcc(%rbp)
cmpl   $0x0,-0xcc(%rbp)
je     13ee <main+0x1fe>
lea    0xc3e(%rip),%rdi
call   10b0 <perror@plt>
mov    0x2bd1(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0xf0(%rbp),%rdx
mov    -0xf8(%rbp),%rsi
lea    -0xa0(%rbp),%rcx
lea    0xc1b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0xa0(%rbp),%eax
cmp    $0x74,%eax
jne    1491 <main+0x2a1>
lea    0xc15(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0xd0(%rbp)
lea    -0xd0(%rbp),%rdi
call   10c0 <gmtime@plt>
mov    %rax,-0xd8(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0xd8(%rbp),%rax
mov    (%rax),%edx
mov    -0xd8(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0xd8(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0xbcf(%rip),%rsi
call   10d0 <sprintf@plt>
movl   $0xe,-0xcc(%rbp)
jmp    1561 <main+0x371>
movsbl -0xa0(%rbp),%eax
cmp    $0x64,%eax
jne    1512 <main+0x322>
lea    0xbb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0xdc(%rbp)
lea    -0xdc(%rbp),%rdi
call   10c0 <gmtime@plt>
mov    %rax,-0xe8(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0xe8(%rbp),%rax
mov    0xc(%rax),%edx
mov    -0xe8(%rbp),%rax
mov    0x10(%rax),%ecx
mov    -0xe8(%rbp),%rax
mov    0x14(%rax),%r8d
lea    0xb6d(%rip),%rsi
call   10d0 <sprintf@plt>
movl   $0x17,-0xcc(%rbp)
jmp    155c <main+0x36c>
movsbl -0xa0(%rbp),%eax
cmp    $0x71,%eax
jne    1557 <main+0x367>
lea    0xb5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa0(%rbp),%rdi
lea    0xb55(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x7,-0xcc(%rbp)
movl   $0x1,-0xc0(%rbp)
jmp    155c <main+0x36c>
jmp    1561 <main+0x371>
mov    -0xc8(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
lea    -0xa0(%rbp),%rsi
lea    0xabb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc8(%rbp),%rsi
lea    0xb08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xbc(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    -0xcc(%rbp),%edx
lea    -0x48(%rbp),%r8
mov    -0xc8(%rbp),%r9
xor    %ecx,%ecx
call   1050 <sendto@plt>
jmp    1307 <main+0x117>
mov    -0xbc(%rbp),%edi
call   1060 <close@plt>
mov    -0xa8(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rsp,-0x48(%rbp)
mov    0x2d91(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x2d95(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2d65(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
movq   $0x0,-0x58(%rbp)
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
lea    -0x70(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1100 <getaddrinfo@plt>
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%esi
mov    0x14(%rax),%edi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%r15d
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edx
mov    %r15d,%edi
call   10b0 <bind@plt>
mov    -0x40(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
lea    0xd3d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movq   $0x4,-0x30(%rbp)
lea    -0xd0(%rbp),%rsi
lea    -0x38(%rbp),%r8
lea    -0x30(%rbp),%r9
mov    %r15d,%edi
mov    $0x1,%edx
xor    %ecx,%ecx
call   10a0 <recvfrom@plt>
cmp    $0xffffffff,%eax
je     1555 <main+0x355>
lea    -0x38(%rbp),%r12
lea    -0xd0(%rbp),%r13
jmp    13b2 <main+0x1b2>
nopl   0x0(%rax)
lea    0xd26(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,-0x34(%rbp)
lea    -0x34(%rbp),%rdi
call   10d0 <gmtime@plt>
mov    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
mov    %r13,%rdi
lea    0xd08(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x30(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
mov    %r13,%rdi
call   1040 <puts@plt>
mov    -0x30(%rbp),%rsi
lea    0xd33(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x30(%rbp),%r9
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0xe,%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   1060 <sendto@plt>
movq   $0x4,-0x30(%rbp)
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %r12,%r8
lea    -0x30(%rbp),%r9
call   10a0 <recvfrom@plt>
cmp    $0xffffffff,%eax
je     1555 <main+0x355>
mov    -0x30(%rbp),%rsi
mov    0x2bf3(%rip),%rax
mov    (%rax),%ecx
mov    0x2c12(%rip),%rax
mov    (%rax),%r9d
mov    0x2bf0(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    %r12,%rdi
mov    %r14,%rdx
mov    %rbx,%r8
push   %rax
call   1080 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
jne    155e <main+0x35e>
lea    0xc2d(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
movzbl -0xd0(%rbp),%eax
cmp    $0x64,%al
je     1460 <main+0x260>
cmp    $0x74,%al
je     1310 <main+0x110>
cmp    $0x71,%al
je     14d4 <main+0x2d4>
mov    -0x30(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
mov    %r13,%rdi
call   1040 <puts@plt>
mov    -0x30(%rbp),%rsi
lea    0xc59(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x30(%rbp),%r9
mov    %r15d,%edi
mov    %r13,%rsi
xor    %edx,%edx
jmp    137e <main+0x17e>
nopw   0x0(%rax,%rax,1)
lea    0xbf5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,-0x34(%rbp)
lea    -0x34(%rbp),%rdi
call   10d0 <gmtime@plt>
mov    0xc(%rax),%edx
mov    0x10(%rax),%ecx
mov    0x14(%rax),%r8d
mov    %r13,%rdi
lea    0xbd6(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x30(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
mov    %r13,%rdi
call   1040 <puts@plt>
mov    -0x30(%rbp),%rsi
lea    0xbe2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x30(%rbp),%r9
mov    %r15d,%edi
mov    %r13,%rsi
mov    $0x17,%edx
jmp    137e <main+0x17e>
lea    0xba9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xbaa(%rip),%rsi
lea    -0xd0(%rbp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rax
movb   $0x0,-0xd0(%rbp,%rax,1)
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    -0x30(%rbp),%rsi
lea    0xb84(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x30(%rbp),%r9
lea    -0x38(%rbp),%r8
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x7,%edx
xor    %ecx,%ecx
call   1060 <sendto@plt>
mov    %r15d,%edi
call   1070 <close@plt>
mov    -0x48(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xab4(%rip),%rdi
jmp    1565 <main+0x365>
lea    0xab4(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2a47(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i64, i32, i32, i64, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
%struct.sockaddr = type { i32 }
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@AI_PASSIVE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [16 x i8] c"start listening\00"
@.str.1 = [9 x i8] c"recvfrom\00"
@EXIT_FAILURE = global i32 0
@NI_NUMERICHOST = global i32 0
@.str.2 = [12 x i8] c"getnameinfo\00"
@.str.3 = [24 x i8] c"host:%s port:%s msg:%s\0A\00"
@.str.4 = [15 x i8] c"time requested\00"
@.str.5 = [16 x i8] c"H:%d M:%d S:%d\0A\00"
@.str.6 = [15 x i8] c"date requested\00"
@.str.7 = [25 x i8] c"Year:%d Month:%d Day:%d\0A\00"
@.str.8 = [15 x i8] c"quit requested\00"
@.str.9 = [8 x i8] c"Goodbye\00"
@.str.10 = [4 x i8] c"%s\0A\00"
@.str.11 = [9 x i8] c"%d clen\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.addrinfo
%7 = alloca %struct.addrinfo*
%8 = alloca %struct.sockaddr_storage
%9 = alloca [81 x i8]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.tm*
%19 = alloca i32
%20 = alloca %struct.tm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* @NI_MAXHOST
%22 = zext i32 %21 to i64
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %10
%24 = alloca i8, i64 %22
store i64 %22, i64* %11
%25 = load i32, i32* @NI_MAXSERV
%26 = zext i32 %25 to i64
%27 = alloca i8, i64 %26
store i64 %26, i64* %12
%28 = load i32, i32* @AI_PASSIVE
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 5
store i32 %28, i32* %29
%30 = load i32, i32* @AF_UNSPEC
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 3
store i32 %30, i32* %31
%32 = load i32, i32* @SOCK_DGRAM
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 2
store i32 %32, i32* %33
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 4
store i64 0, i64* %34
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @getaddrinfo(i8* %37, i8* %40, %struct.addrinfo* %6, %struct.addrinfo** %7)
%42 = load %struct.addrinfo*, %struct.addrinfo** %7
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i32 0, i32 3
%44 = load i32, i32* %43
%45 = load %struct.addrinfo*, %struct.addrinfo** %7
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i32 0, i32 2
%47 = load i32, i32* %46
%48 = call i32 @socket(i32 %44, i32 %47, i32 0)
store i32 %48, i32* %13
%49 = load i32, i32* %13
%50 = load %struct.addrinfo*, %struct.addrinfo** %7
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i32 0, i32 1
%52 = load i64, i64* %51
%53 = inttoptr i64 %52 to %struct.sockaddr*
%54 = load %struct.addrinfo*, %struct.addrinfo** %7
%55 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = call i32 @bind(i32 %49, %struct.sockaddr* %53, i32 %56)
%58 = load %struct.addrinfo*, %struct.addrinfo** %7
%59 = call i32 @freeaddrinfo(%struct.addrinfo* %58)
store i32 0, i32* %14
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %61
61: ; preds = %142, %2
%62 = load i32, i32* %14
%63 = icmp ne i32 %62, 0
%64 = xor i1 %63, true
br i1 %64, label %65, label %155
65: ; preds = %61
store i64 4, i64* %15
%66 = load i32, i32* %13
%67 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%68 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
%69 = call i32 @recvfrom(i32 %66, i8* %67, i32 1, i32 0, %struct.sockaddr* %68, i64* %15)
store i32 %69, i32* %16
%70 = load i32, i32* %16
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %76
72: ; preds = %65
%73 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %65
%77 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
%78 = load i64, i64* %15
%79 = load i32, i32* @NI_MAXHOST
%80 = load i32, i32* @NI_MAXSERV
%81 = load i32, i32* @NI_NUMERICHOST
%82 = call i32 @getnameinfo(%struct.sockaddr* %77, i64 %78, i8* %24, i32 %79, i8* %27, i32 %80, i32 %81)
store i32 %82, i32* %16
%83 = load i32, i32* %16
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %76
%86 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%87 = load i32, i32* @EXIT_FAILURE
%88 = call i32 @exit(i32 %87)
unreachable
89: ; preds = %76
%90 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %27, i8* %90)
%92 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 116
br i1 %95, label %96, label %111
96: ; preds = %89
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%98 = call i32 @time(i32* null)
store i32 %98, i32* %17
%99 = call %struct.tm* @gmtime(i32* %17)
store %struct.tm* %99, %struct.tm** %18
%100 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%101 = load %struct.tm*, %struct.tm** %18
%102 = getelementptr inbounds %struct.tm, %struct.tm* %101, i32 0, i32 0
%103 = load i32, i32* %102
%104 = load %struct.tm*, %struct.tm** %18
%105 = getelementptr inbounds %struct.tm, %struct.tm* %104, i32 0, i32 1
%106 = load i32, i32* %105
%107 = load %struct.tm*, %struct.tm** %18
%108 = getelementptr inbounds %struct.tm, %struct.tm* %107, i32 0, i32 2
%109 = load i32, i32* %108
%110 = call i32 @sprintf(i8* %100, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %103, i32 %106, i32 %109)
store i32 14, i32* %16
br label %142
111: ; preds = %89
%112 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = icmp eq i32 %114, 100
br i1 %115, label %116, label %131
116: ; preds = %111
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%118 = call i32 @time(i32* null)
store i32 %118, i32* %19
%119 = call %struct.tm* @gmtime(i32* %19)
store %struct.tm* %119, %struct.tm** %20
%120 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%121 = load %struct.tm*, %struct.tm** %20
%122 = getelementptr inbounds %struct.tm, %struct.tm* %121, i32 0, i32 3
%123 = load i32, i32* %122
%124 = load %struct.tm*, %struct.tm** %20
%125 = getelementptr inbounds %struct.tm, %struct.tm* %124, i32 0, i32 4
%126 = load i32, i32* %125
%127 = load %struct.tm*, %struct.tm** %20
%128 = getelementptr inbounds %struct.tm, %struct.tm* %127, i32 0, i32 5
%129 = load i32, i32* %128
%130 = call i32 @sprintf(i8* %120, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %123, i32 %126, i32 %129)
store i32 23, i32* %16
br label %141
131: ; preds = %111
%132 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp eq i32 %134, 113
br i1 %135, label %136, label %140
136: ; preds = %131
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%138 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%139 = call i32 @strcpy(i8* %138, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
store i32 7, i32* %16
store i32 1, i32* %14
br label %140
140: ; preds = %136, %131
br label %141
141: ; preds = %140, %116
br label %142
142: ; preds = %141, %96
%143 = load i64, i64* %15
%144 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 %143
store i8 0, i8* %144
%145 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %145)
%147 = load i64, i64* %15
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i64 %147)
%149 = load i32, i32* %13
%150 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%151 = load i32, i32* %16
%152 = bitcast %struct.sockaddr_storage* %8 to %struct.sockaddr*
%153 = load i64, i64* %15
%154 = call i32 @sendto(i32 %149, i8* %150, i32 %151, i32 0, %struct.sockaddr* %152, i64 %153)
br label %61
155: ; preds = %61
%156 = load i32, i32* %13
%157 = call i32 @close(i32 %156)
%158 = load i8*, i8** %10
%159 = load i32, i32* %3
ret i32 %159
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i64, i32, i32, i64, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@AI_PASSIVE = global i32 0
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [16 x i8] c"start listening\00"
@.str.1 = [9 x i8] c"recvfrom\00"
@EXIT_FAILURE = global i32 0
@NI_NUMERICHOST = global i32 0
@.str.2 = [12 x i8] c"getnameinfo\00"
@.str.3 = [24 x i8] c"host:%s port:%s msg:%s\0A\00"
@.str.4 = [15 x i8] c"time requested\00"
@.str.5 = [16 x i8] c"H:%d M:%d S:%d\0A\00"
@.str.6 = [15 x i8] c"date requested\00"
@.str.7 = [25 x i8] c"Year:%d Month:%d Day:%d\0A\00"
@.str.8 = [15 x i8] c"quit requested\00"
@.str.9 = [8 x i8] c"Goodbye\00"
@.str.11 = [9 x i8] c"%d clen\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca %struct.sockaddr_storage
%6 = alloca [81 x i8]
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = bitcast %struct.addrinfo* %3 to i8*
%11 = bitcast %struct.addrinfo** %4 to i8*
%12 = bitcast %struct.sockaddr_storage* %5 to i8*
%13 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 0
%14 = load i32, i32* @NI_MAXHOST
%15 = zext i32 %14 to i64
%16 = tail call i8* @llvm.stacksave()
%17 = alloca i8, i64 %15
%18 = load i32, i32* @NI_MAXSERV
%19 = zext i32 %18 to i64
%20 = alloca i8, i64 %19
%21 = load i32, i32* @AI_PASSIVE
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 5
store i32 %21, i32* %22
%23 = load i32, i32* @AF_UNSPEC
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %23, i32* %24
%25 = load i32, i32* @SOCK_DGRAM
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 2
store i32 %25, i32* %26
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i64 0, i64* %27
%28 = getelementptr inbounds i8*, i8** %1, i64 1
%29 = load i8*, i8** %28
%30 = getelementptr inbounds i8*, i8** %1, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @getaddrinfo(i8* %29, i8* %31, %struct.addrinfo* %3, %struct.addrinfo** %4)
%33 = load %struct.addrinfo*, %struct.addrinfo** %4
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %33, i64 0, i32 3
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %33, i64 0, i32 2
%37 = load i32, i32* %36
%38 = call i32 @socket(i32 %35, i32 %37, i32 0)
%39 = load %struct.addrinfo*, %struct.addrinfo** %4
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 1
%41 = load i64, i64* %40
%42 = inttoptr i64 %41 to %struct.sockaddr*
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %39, i64 0, i32 0
%44 = load i32, i32* %43
%45 = call i32 @bind(i32 %38, %struct.sockaddr* %42, i32 %44)
%46 = load %struct.addrinfo*, %struct.addrinfo** %4
%47 = call i32 @freeaddrinfo(%struct.addrinfo* %46)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%49 = bitcast i64* %7 to i8*
%50 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
%51 = bitcast i32* %9 to i8*
%52 = bitcast i32* %8 to i8*
store i64 4, i64* %7
%53 = call i32 @recvfrom(i32 %38, i8* %13, i32 1, i32 0, %struct.sockaddr* %50, i64* %7)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %59
55: ; preds = %91, %2
%56 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
%58 = call i32 @exit(i32 %57)
unreachable
59: ; preds = %2, %91
%60 = load i64, i64* %7
%61 = load i32, i32* @NI_MAXHOST
%62 = load i32, i32* @NI_MAXSERV
%63 = load i32, i32* @NI_NUMERICHOST
%64 = call i32 @getnameinfo(%struct.sockaddr* %50, i64 %60, i8* %17, i32 %61, i8* %20, i32 %62, i32 %63)
%65 = icmp eq i32 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %59
%67 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %59
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %17, i8* %20, i8* %13)
%72 = load i8, i8* %13
switch i8 %72, label %123 [
i8 116, label %73
i8 100, label %94
i8 113, label %112
]
73: ; preds = %70
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%75 = call i32 @time(i32* null)
store i32 %75, i32* %8
%76 = call %struct.tm* @gmtime(i32* %8)
%77 = getelementptr inbounds %struct.tm, %struct.tm* %76, i64 0, i32 0
%78 = load i32, i32* %77
%79 = getelementptr inbounds %struct.tm, %struct.tm* %76, i64 0, i32 1
%80 = load i32, i32* %79
%81 = getelementptr inbounds %struct.tm, %struct.tm* %76, i64 0, i32 2
%82 = load i32, i32* %81
%83 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %78, i32 %80, i32 %82)
%84 = load i64, i64* %7
%85 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 %84
store i8 0, i8* %85
%86 = call i32 @puts(i8* %13)
%87 = load i64, i64* %7
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i64 %87)
%89 = load i64, i64* %7
%90 = call i32 @sendto(i32 %38, i8* %13, i32 14, i32 0, %struct.sockaddr* %50, i64 %89)
br label %91
91: ; preds = %73, %94, %123
store i64 4, i64* %7
%92 = call i32 @recvfrom(i32 %38, i8* %13, i32 1, i32 0, %struct.sockaddr* %50, i64* %7)
%93 = icmp eq i32 %92, -1
br i1 %93, label %55, label %59
94: ; preds = %70
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%96 = call i32 @time(i32* null)
store i32 %96, i32* %9
%97 = call %struct.tm* @gmtime(i32* %9)
%98 = getelementptr inbounds %struct.tm, %struct.tm* %97, i64 0, i32 3
%99 = load i32, i32* %98
%100 = getelementptr inbounds %struct.tm, %struct.tm* %97, i64 0, i32 4
%101 = load i32, i32* %100
%102 = getelementptr inbounds %struct.tm, %struct.tm* %97, i64 0, i32 5
%103 = load i32, i32* %102
%104 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %99, i32 %101, i32 %103)
%105 = load i64, i64* %7
%106 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 %105
store i8 0, i8* %106
%107 = call i32 @puts(i8* %13)
%108 = load i64, i64* %7
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i64 %108)
%110 = load i64, i64* %7
%111 = call i32 @sendto(i32 %38, i8* %13, i32 23, i32 0, %struct.sockaddr* %50, i64 %110)
br label %91
112: ; preds = %70
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%114 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%115 = load i64, i64* %7
%116 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 %115
store i8 0, i8* %116
%117 = call i32 @puts(i8* %13)
%118 = load i64, i64* %7
%119 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i64 %118)
%120 = load i64, i64* %7
%121 = call i32 @sendto(i32 %38, i8* %13, i32 7, i32 0, %struct.sockaddr* %50, i64 %120)
%122 = call i32 @close(i32 %38)
ret i32 0
123: ; preds = %70
%124 = load i64, i64* %7
%125 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 %124
store i8 0, i8* %125
%126 = call i32 @puts(i8* %13)
%127 = load i64, i64* %7
%128 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0), i64 %127)
%129 = load i64, i64* %7
%130 = call i32 @sendto(i32 %38, i8* %13, i32 0, i32 0, %struct.sockaddr* %50, i64 %129)
br label %91
}