#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 dummy;
};
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;
  int /*<<< orphan*/ ai_flags;
};
typedef int /*<<< orphan*/ src_addr;
typedef int socklen_t;
typedef int /*<<< orphan*/ hints;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_NUMERICHOST;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int NI_MAXHOST;
int NI_MAXSERV;
int NI_NUMERICHOST;
int NI_NUMERICSERV;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ bind(int, struct sockaddr *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ getnameinfo(struct sockaddr *, int, char *, int, char *, int,
                               int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/ scanf(char *, char *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char **argv) {
  struct addrinfo *result = NULL;
  struct addrinfo hints;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = AI_NUMERICHOST;
  int rc = getaddrinfo(argv[1], argv[2], &hints, &result);
  int udp_socket = socket(result->ai_family, result->ai_socktype, 0);
  bind(udp_socket, (struct sockaddr *)result->ai_addr, result->ai_addrlen);
  freeaddrinfo(result);
  struct sockaddr_storage src_addr;
  socklen_t addrlen = sizeof(src_addr);
  char buf[2];
  while (1) {
    fd_set set;
    FD_ZERO(&set);
    FD_SET(udp_socket, &set);
    FD_SET(0, &set);
    int fds = select(udp_socket + 1, &set, NULL, NULL, NULL);
    time_t act = time(0);
    struct tm *buf_hora;
    buf_hora = localtime(&act);
    if (FD_ISSET(udp_socket, &set)) {
      int bytes = recvfrom(udp_socket, buf, 1, 0, (struct sockaddr *)&src_addr,
                           &addrlen);
      buf[1] = '\0';
      char host[NI_MAXHOST];
      char serv[NI_MAXSERV];
      getnameinfo((struct sockaddr *)&src_addr, addrlen, host, NI_MAXHOST, serv,
                  NI_MAXSERV, NI_NUMERICHOST | NI_NUMERICSERV);
      printf("I received %i bytes from %s:%s\n", bytes, host, serv);
    } else {
      scanf("%s", buf);
    }
    if (buf[0] == 't') {
      char s[10];
      strftime(s, 10, "%T", buf_hora);
      s[9] = '\0';
      if (FD_ISSET(udp_socket, &set))
        sendto(udp_socket, s, 9, 0, (struct sockaddr *)&src_addr, addrlen);
      else
        printf("%s\n", s);
    } else if (buf[0] == 'd') {
      char s[11];
      strftime(s, 11, "%F", buf_hora);
      s[10] = '\0';
      if (FD_ISSET(udp_socket, &set))
        sendto(udp_socket, s, 11, 0, (struct sockaddr *)&src_addr, addrlen);
      else
        printf("%s\n", s);
    } else if (buf[0] != 'q') {
      printf("Invalid comand %s\n", buf);
      if (FD_ISSET(udp_socket, &set))
        sendto(udp_socket, buf, 2, 0, (struct sockaddr *)&src_addr, addrlen);
    }
    if (buf[0] == 'q') {
      printf("Exiting \n");
      break;
    }
  }
  close(udp_socket);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1110 <getaddrinfo@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   10f0 <bind@plt>
mov    -0x18(%rbp),%rdi
call   1130 <freeaddrinfo@plt>
movl   $0x4,-0x4c(%rbp)
lea    -0x54(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
mov    -0x40(%rbp),%edi
lea    -0x54(%rbp),%rsi
call   1120 <FD_SET@plt>
xor    %edi,%edi
lea    -0x54(%rbp),%rsi
call   1120 <FD_SET@plt>
mov    -0x40(%rbp),%edi
add    $0x1,%edi
lea    -0x54(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10c0 <select@plt>
mov    %eax,-0x58(%rbp)
xor    %edi,%edi
call   10a0 <time@plt>
mov    %eax,-0x5c(%rbp)
lea    -0x5c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x68(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x54(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1421 <main+0x201>
mov    -0x40(%rbp),%edi
lea    -0x4e(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
lea    -0x48(%rbp),%r8
lea    -0x4c(%rbp),%r9
call   10d0 <recvfrom@plt>
mov    %eax,-0x6c(%rbp)
movb   $0x0,-0x4d(%rbp)
mov    0x2c4a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0xb0(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x80(%rbp)
mov    0x2c43(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r8
sub    %rcx,%r8
mov    %r8,-0xa8(%rbp)
mov    %r8,%rsp
mov    %rax,-0x88(%rbp)
lea    -0x48(%rbp),%rdi
mov    -0x4c(%rbp),%esi
mov    0x2be9(%rip),%rax
mov    (%rax),%ecx
mov    0x2c08(%rip),%rax
mov    (%rax),%r9d
mov    0x2bde(%rip),%rax
mov    (%rax),%eax
mov    0x2c05(%rip),%r10
or     (%r10),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1090 <getnameinfo@plt>
mov    -0xb0(%rbp),%rdx
mov    -0xa8(%rbp),%rcx
add    $0x10,%rsp
mov    -0x6c(%rbp),%esi
lea    0xbf2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x78(%rbp),%rax
mov    %rax,%rsp
jmp    1431 <main+0x211>
lea    -0x4e(%rbp),%rsi
lea    0xbf4(%rip),%rdi
call   10e0 <scanf@plt>
movsbl -0x4e(%rbp),%eax
cmp    $0x74,%eax
jne    14b4 <main+0x294>
lea    -0x92(%rbp),%rdi
mov    -0x68(%rbp),%rcx
mov    $0xa,%esi
lea    0xbce(%rip),%rdx
call   1100 <strftime@plt>
movb   $0x0,-0x89(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x54(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     149a <main+0x27a>
mov    -0x40(%rbp),%edi
lea    -0x92(%rbp),%rsi
lea    -0x48(%rbp),%r8
mov    -0x4c(%rbp),%r9d
mov    $0x9,%edx
xor    %ecx,%ecx
call   1070 <sendto@plt>
jmp    14af <main+0x28f>
lea    -0x92(%rbp),%rsi
lea    0xb90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1596 <main+0x376>
movsbl -0x4e(%rbp),%eax
cmp    $0x64,%eax
jne    1537 <main+0x317>
lea    -0x9d(%rbp),%rdi
mov    -0x68(%rbp),%rcx
mov    $0xb,%esi
lea    0xb4e(%rip),%rdx
call   1100 <strftime@plt>
movb   $0x0,-0x93(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x54(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     151d <main+0x2fd>
mov    -0x40(%rbp),%edi
lea    -0x9d(%rbp),%rsi
lea    -0x48(%rbp),%r8
mov    -0x4c(%rbp),%r9d
mov    $0xb,%edx
xor    %ecx,%ecx
call   1070 <sendto@plt>
jmp    1532 <main+0x312>
lea    -0x9d(%rbp),%rsi
lea    0xb0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1591 <main+0x371>
movsbl -0x4e(%rbp),%eax
cmp    $0x71,%eax
je     158c <main+0x36c>
lea    -0x4e(%rbp),%rsi
lea    0xada(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%edi
lea    -0x54(%rbp),%rsi
call   1040 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1587 <main+0x367>
mov    -0x40(%rbp),%edi
lea    -0x4e(%rbp),%rsi
lea    -0x48(%rbp),%r8
mov    -0x4c(%rbp),%r9d
mov    $0x2,%edx
xor    %ecx,%ecx
call   1070 <sendto@plt>
jmp    158c <main+0x36c>
jmp    1591 <main+0x371>
jmp    1596 <main+0x376>
movsbl -0x4e(%rbp),%eax
cmp    $0x71,%eax
jne    15b6 <main+0x396>
lea    0xa92(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15bb <main+0x39b>
jmp    12d3 <main+0xb3>
mov    -0x40(%rbp),%edi
call   1080 <close@plt>
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    $0x78,%rsp
mov    %rsi,%rbx
movq   $0x0,-0x48(%rbp)
lea    -0x98(%rbp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    0x2d50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x88(%rbp)
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x80(%rbp)
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
lea    -0x48(%rbp),%rcx
mov    %r14,%rdx
call   1120 <getaddrinfo@plt>
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%esi
mov    0x14(%rax),%edi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%r14d
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edx
mov    %r14d,%edi
call   1100 <bind@plt>
mov    -0x48(%rbp),%rdi
call   1140 <freeaddrinfo@plt>
movl   $0x4,-0x30(%rbp)
mov    %r14d,%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
lea    -0x74(%rbp),%rbx
lea    -0x5b(%rbp),%r13
mov    %r14d,-0x3c(%rbp)
jmp    1347 <main+0x117>
nopl   (%rax)
mov    %r13,%rdi
mov    $0xb,%esi
lea    0xd27(%rip),%rdx
mov    %r12,%rcx
call   1110 <strftime@plt>
movb   $0x0,-0x51(%rbp)
mov    -0x3c(%rbp),%r14d
mov    %r14d,%edi
mov    %rbx,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1510 <main+0x2e0>
mov    -0x30(%rbp),%r9d
mov    %r14d,%edi
mov    %r13,%rsi
mov    $0xb,%edx
xor    %ecx,%ecx
lea    -0x38(%rbp),%r8
call   1080 <sendto@plt>
cmpb   $0x71,-0x2a(%rbp)
je     151d <main+0x2ed>
mov    %rbx,%rdi
call   10c0 <FD_ZERO@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
call   1130 <FD_SET@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1130 <FD_SET@plt>
mov    -0x4c(%rbp),%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10d0 <select@plt>
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,-0x50(%rbp)
lea    -0x50(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,%r12
mov    %r14d,%edi
mov    %rbx,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1460 <main+0x230>
mov    %r14d,%edi
lea    -0x2a(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
lea    -0x38(%rbp),%r8
lea    -0x30(%rbp),%r9
call   10e0 <recvfrom@plt>
mov    %r12,-0x70(%rbp)
mov    %eax,%r12d
mov    %rsp,-0x68(%rbp)
movb   $0x0,-0x29(%rbp)
mov    0x2bdf(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    0x2bed(%rip),%rax
mov    (%rax),%r9d
mov    %rsp,%r15
mov    %r9,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x30(%rbp),%esi
mov    (%rcx),%ecx
mov    0x2bda(%rip),%rax
mov    (%rax),%eax
mov    0x2ba1(%rip),%rdx
or     (%rdx),%eax
sub    $0x8,%rsp
lea    -0x38(%rbp),%rdi
mov    %r14,%rdx
mov    %r15,%r8
push   %rax
call   10a0 <getnameinfo@plt>
add    $0x10,%rsp
lea    0xbc8(%rip),%rdi
mov    %r12d,%esi
mov    -0x70(%rbp),%r12
mov    %r14,%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
mov    -0x68(%rbp),%rsp
jmp    1470 <main+0x240>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xbb9(%rip),%rdi
lea    -0x2a(%rbp),%rsi
call   10f0 <scanf@plt>
movzbl -0x2a(%rbp),%eax
cmp    $0x64,%al
je     12f0 <main+0xc0>
cmp    $0x74,%al
mov    -0x3c(%rbp),%r14d
je     14d0 <main+0x2a0>
cmp    $0x71,%al
je     151d <main+0x2ed>
lea    0xb96(%rip),%rdi
lea    -0x2a(%rbp),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     133d <main+0x10d>
mov    -0x30(%rbp),%r9d
mov    %r14d,%edi
lea    -0x2a(%rbp),%rsi
mov    $0x2,%edx
jmp    1332 <main+0x102>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0xa,%esi
lea    0xb44(%rip),%rdx
mov    %r12,%rcx
call   1110 <strftime@plt>
movb   $0x0,-0x52(%rbp)
mov    %r14d,%edi
mov    %rbx,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1510 <main+0x2e0>
mov    -0x30(%rbp),%r9d
mov    %r14d,%edi
mov    %r13,%rsi
mov    $0x9,%edx
jmp    1332 <main+0x102>
nop
mov    %r13,%rdi
call   1040 <puts@plt>
jmp    133d <main+0x10d>
lea    0xb18(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   1090 <close@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i64, i32, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.tm = type { i32 }
%struct.sockaddr = type { i32 }
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_NUMERICHOST = global i32 0
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str = [32 x i8] c"I received %i bytes from %s:%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%T\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [3 x i8] c"%F\00"
@.str.5 = [19 x i8] c"Invalid comand %s\0A\00"
@.str.6 = [10 x i8] c"Exiting \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 i32
%9 = alloca i32
%10 = alloca %struct.sockaddr_storage
%11 = alloca i32
%12 = alloca [2 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca %struct.tm*
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i64
%21 = alloca [10 x i8]
%22 = alloca [11 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store %struct.addrinfo* null, %struct.addrinfo** %6
%23 = call i32 @memset(%struct.addrinfo* %7, i32 0, i32 32)
%24 = load i32, i32* @AF_UNSPEC
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 3
store i32 %24, i32* %25
%26 = load i32, i32* @SOCK_DGRAM
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 2
store i32 %26, i32* %27
%28 = load i32, i32* @AI_NUMERICHOST
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %7, i32 0, i32 4
store i32 %28, i32* %29
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @getaddrinfo(i8* %32, i8* %35, %struct.addrinfo* %7, %struct.addrinfo** %6)
store i32 %36, i32* %8
%37 = load %struct.addrinfo*, %struct.addrinfo** %6
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i32 0, i32 3
%39 = load i32, i32* %38
%40 = load %struct.addrinfo*, %struct.addrinfo** %6
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i32 0, i32 2
%42 = load i32, i32* %41
%43 = call i32 @socket(i32 %39, i32 %42, i32 0)
store i32 %43, i32* %9
%44 = load i32, i32* %9
%45 = load %struct.addrinfo*, %struct.addrinfo** %6
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i32 0, i32 1
%47 = load i64, i64* %46
%48 = inttoptr i64 %47 to %struct.sockaddr*
%49 = load %struct.addrinfo*, %struct.addrinfo** %6
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %49, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i32 @bind(i32 %44, %struct.sockaddr* %48, i32 %51)
%53 = load %struct.addrinfo*, %struct.addrinfo** %6
%54 = call i32 @freeaddrinfo(%struct.addrinfo* %53)
store i32 4, i32* %11
br label %55
55: ; preds = %2, %168
%56 = call i32 @FD_ZERO(i32* %13)
%57 = load i32, i32* %9
%58 = call i32 @FD_SET(i32 %57, i32* %13)
%59 = call i32 @FD_SET(i32 0, i32* %13)
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
%62 = call i32 @select(i32 %61, i32* %13, i32* null, i32* null, i32* null)
store i32 %62, i32* %14
%63 = call i32 @time(i32 0)
store i32 %63, i32* %15
%64 = call %struct.tm* @localtime(i32* %15)
store %struct.tm* %64, %struct.tm** %16
%65 = load i32, i32* %9
%66 = call i64 @FD_ISSET(i32 %65, i32* %13)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %92
68: ; preds = %55
%69 = load i32, i32* %9
%70 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%71 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr*
%72 = call i32 @recvfrom(i32 %69, i8* %70, i32 1, i32 0, %struct.sockaddr* %71, i32* %11)
store i32 %72, i32* %17
%73 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 1
store i8 0, i8* %73
%74 = load i32, i32* @NI_MAXHOST
%75 = zext i32 %74 to i64
%76 = call i8* @llvm.stacksave()
store i8* %76, i8** %18
%77 = alloca i8, i64 %75
store i64 %75, i64* %19
%78 = load i32, i32* @NI_MAXSERV
%79 = zext i32 %78 to i64
%80 = alloca i8, i64 %79
store i64 %79, i64* %20
%81 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr*
%82 = load i32, i32* %11
%83 = load i32, i32* @NI_MAXHOST
%84 = load i32, i32* @NI_MAXSERV
%85 = load i32, i32* @NI_NUMERICHOST
%86 = load i32, i32* @NI_NUMERICSERV
%87 = or i32 %85, %86
%88 = call i32 @getnameinfo(%struct.sockaddr* %81, i32 %82, i8* %77, i32 %83, i8* %80, i32 %84, i32 %87)
%89 = load i32, i32* %17
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %89, i8* %77, i8* %80)
%91 = load i8*, i8** %18
br label %95
92: ; preds = %55
%93 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%94 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %93)
br label %95
95: ; preds = %92, %68
%96 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 116
br i1 %99, label %100, label %118
100: ; preds = %95
%101 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 0
%102 = load %struct.tm*, %struct.tm** %16
%103 = call i32 @strftime(i8* %101, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %102)
%104 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 9
store i8 0, i8* %104
%105 = load i32, i32* %9
%106 = call i64 @FD_ISSET(i32 %105, i32* %13)
%107 = icmp ne i64 %106, 0
br i1 %107, label %108, label %114
108: ; preds = %100
%109 = load i32, i32* %9
%110 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 0
%111 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr*
%112 = load i32, i32* %11
%113 = call i32 @sendto(i32 %109, i8* %110, i32 9, i32 0, %struct.sockaddr* %111, i32 %112)
br label %117
114: ; preds = %100
%115 = getelementptr inbounds [10 x i8], [10 x i8]* %21, i64 0, i64 0
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %115)
br label %117
117: ; preds = %114, %108
br label %161
118: ; preds = %95
%119 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%120 = load i8, i8* %119
%121 = sext i8 %120 to i32
%122 = icmp eq i32 %121, 100
br i1 %122, label %123, label %141
123: ; preds = %118
%124 = getelementptr inbounds [11 x i8], [11 x i8]* %22, i64 0, i64 0
%125 = load %struct.tm*, %struct.tm** %16
%126 = call i32 @strftime(i8* %124, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %125)
%127 = getelementptr inbounds [11 x i8], [11 x i8]* %22, i64 0, i64 10
store i8 0, i8* %127
%128 = load i32, i32* %9
%129 = call i64 @FD_ISSET(i32 %128, i32* %13)
%130 = icmp ne i64 %129, 0
br i1 %130, label %131, label %137
131: ; preds = %123
%132 = load i32, i32* %9
%133 = getelementptr inbounds [11 x i8], [11 x i8]* %22, i64 0, i64 0
%134 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr*
%135 = load i32, i32* %11
%136 = call i32 @sendto(i32 %132, i8* %133, i32 11, i32 0, %struct.sockaddr* %134, i32 %135)
br label %140
137: ; preds = %123
%138 = getelementptr inbounds [11 x i8], [11 x i8]* %22, i64 0, i64 0
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %138)
br label %140
140: ; preds = %137, %131
br label %160
141: ; preds = %118
%142 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%143 = load i8, i8* %142
%144 = sext i8 %143 to i32
%145 = icmp ne i32 %144, 113
br i1 %145, label %146, label %159
146: ; preds = %141
%147 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %147)
%149 = load i32, i32* %9
%150 = call i64 @FD_ISSET(i32 %149, i32* %13)
%151 = icmp ne i64 %150, 0
br i1 %151, label %152, label %158
152: ; preds = %146
%153 = load i32, i32* %9
%154 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%155 = bitcast %struct.sockaddr_storage* %10 to %struct.sockaddr*
%156 = load i32, i32* %11
%157 = call i32 @sendto(i32 %153, i8* %154, i32 2, i32 0, %struct.sockaddr* %155, i32 %156)
br label %158
158: ; preds = %152, %146
br label %159
159: ; preds = %158, %141
br label %160
160: ; preds = %159, %140
br label %161
161: ; preds = %160, %117
%162 = getelementptr inbounds [2 x i8], [2 x i8]* %12, i64 0, i64 0
%163 = load i8, i8* %162
%164 = sext i8 %163 to i32
%165 = icmp eq i32 %164, 113
br i1 %165, label %166, label %168
166: ; preds = %161
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
br label %169
168: ; preds = %161
br label %55
169: ; preds = %166
%170 = load i32, i32* %9
%171 = call i32 @close(i32 %170)
%172 = load i32, i32* %3
ret i32 %172
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i64, i32, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
%struct.tm = type { i32 }
@AF_UNSPEC = global i32 0
@SOCK_DGRAM = global i32 0
@AI_NUMERICHOST = global i32 0
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@.str = [32 x i8] c"I received %i bytes from %s:%s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [3 x i8] c"%T\00"
@.str.4 = [3 x i8] c"%F\00"
@.str.5 = [19 x i8] c"Invalid comand %s\0A\00"
@str = [9 x i8] c"Exiting \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo*
%4 = alloca %struct.addrinfo
%5 = alloca %struct.sockaddr_storage
%6 = alloca i32
%7 = alloca [2 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca [10 x i8]
%11 = alloca [11 x i8]
%12 = bitcast %struct.addrinfo** %3 to i8*
store %struct.addrinfo* null, %struct.addrinfo** %3
%13 = bitcast %struct.addrinfo* %4 to i8*
%14 = call i32 @memset(%struct.addrinfo* %4, i32 0, i32 32)
%15 = load i32, i32* @AF_UNSPEC
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 3
store i32 %15, i32* %16
%17 = load i32, i32* @SOCK_DGRAM
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 2
store i32 %17, i32* %18
%19 = load i32, i32* @AI_NUMERICHOST
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %19, i32* %20
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @getaddrinfo(i8* %22, i8* %24, %struct.addrinfo* %4, %struct.addrinfo** %3)
%26 = load %struct.addrinfo*, %struct.addrinfo** %3
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i64 0, i32 3
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %26, i64 0, i32 2
%30 = load i32, i32* %29
%31 = call i32 @socket(i32 %28, i32 %30, i32 0)
%32 = load %struct.addrinfo*, %struct.addrinfo** %3
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 1
%34 = load i64, i64* %33
%35 = inttoptr i64 %34 to %struct.sockaddr*
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 0
%37 = load i32, i32* %36
%38 = call i32 @bind(i32 %31, %struct.sockaddr* %35, i32 %37)
%39 = load %struct.addrinfo*, %struct.addrinfo** %3
%40 = call i32 @freeaddrinfo(%struct.addrinfo* %39)
%41 = bitcast %struct.sockaddr_storage* %5 to i8*
%42 = bitcast i32* %6 to i8*
store i32 4, i32* %6
%43 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 0
%44 = bitcast i32* %8 to i8*
%45 = add nsw i32 %31, 1
%46 = bitcast i32* %9 to i8*
%47 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
%48 = getelementptr inbounds [2 x i8], [2 x i8]* %7, i64 0, i64 1
%49 = getelementptr inbounds [11 x i8], [11 x i8]* %11, i64 0, i64 0
%50 = getelementptr inbounds [11 x i8], [11 x i8]* %11, i64 0, i64 10
%51 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%52 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 9
br label %53
53: ; preds = %112, %2
%54 = call i32 @FD_ZERO(i32* %8)
%55 = call i32 @FD_SET(i32 %31, i32* %8)
%56 = call i32 @FD_SET(i32 0, i32* %8)
%57 = call i32 @select(i32 %45, i32* %8, i32* null, i32* null, i32* null)
%58 = call i32 @time(i32 0)
store i32 %58, i32* %9
%59 = call %struct.tm* @localtime(i32* %9)
%60 = call i64 @FD_ISSET(i32 %31, i32* %8)
%61 = icmp eq i64 %60, 0
br i1 %61, label %78, label %62
62: ; preds = %53
%63 = call i32 @recvfrom(i32 %31, i8* %43, i32 1, i32 0, %struct.sockaddr* %47, i32* %6)
store i8 0, i8* %48
%64 = load i32, i32* @NI_MAXHOST
%65 = zext i32 %64 to i64
%66 = call i8* @llvm.stacksave()
%67 = alloca i8, i64 %65
%68 = load i32, i32* @NI_MAXSERV
%69 = zext i32 %68 to i64
%70 = alloca i8, i64 %69
%71 = load i32, i32* %6
%72 = load i32, i32* @NI_MAXHOST
%73 = load i32, i32* @NI_NUMERICHOST
%74 = load i32, i32* @NI_NUMERICSERV
%75 = or i32 %74, %73
%76 = call i32 @getnameinfo(%struct.sockaddr* %47, i32 %71, i8* %67, i32 %72, i8* %70, i32 %68, i32 %75)
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %63, i8* %67, i8* %70)
br label %80
78: ; preds = %53
%79 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %43)
br label %80
80: ; preds = %78, %62
%81 = load i8, i8* %43
switch i8 %81, label %102 [
i8 116, label %82
i8 100, label %92
i8 113, label %113
]
82: ; preds = %80
%83 = call i32 @strftime(i8* %51, i32 10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %59)
store i8 0, i8* %52
%84 = call i64 @FD_ISSET(i32 %31, i32* %8)
%85 = icmp eq i64 %84, 0
br i1 %85, label %89, label %86
86: ; preds = %82
%87 = load i32, i32* %6
%88 = call i32 @sendto(i32 %31, i8* %51, i32 9, i32 0, %struct.sockaddr* %47, i32 %87)
br label %91
89: ; preds = %82
%90 = call i32 @puts(i8* %51)
br label %91
91: ; preds = %89, %86
br label %109
92: ; preds = %80
%93 = call i32 @strftime(i8* %49, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %59)
store i8 0, i8* %50
%94 = call i64 @FD_ISSET(i32 %31, i32* %8)
%95 = icmp eq i64 %94, 0
br i1 %95, label %99, label %96
96: ; preds = %92
%97 = load i32, i32* %6
%98 = call i32 @sendto(i32 %31, i8* %49, i32 11, i32 0, %struct.sockaddr* %47, i32 %97)
br label %101
99: ; preds = %92
%100 = call i32 @puts(i8* %49)
br label %101
101: ; preds = %99, %96
br label %109
102: ; preds = %80
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %43)
%104 = call i64 @FD_ISSET(i32 %31, i32* %8)
%105 = icmp eq i64 %104, 0
br i1 %105, label %109, label %106
106: ; preds = %102
%107 = load i32, i32* %6
%108 = call i32 @sendto(i32 %31, i8* %43, i32 2, i32 0, %struct.sockaddr* %47, i32 %107)
br label %109
109: ; preds = %101, %102, %106, %91
%110 = load i8, i8* %43
%111 = icmp eq i8 %110, 113
br i1 %111, label %113, label %112
112: ; preds = %109
br label %53
113: ; preds = %80, %109
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%115 = call i32 @close(i32 %31)
ret i32 0
}