#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_min;
  int tm_sec;
  int tm_mday;
  int /*<<< orphan*/ tm_mon;
  int /*<<< orphan*/ tm_year;
  int /*<<< orphan*/ tm_hour;
};
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 int socklen_t;
typedef int /*<<< orphan*/ cli;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ AI_PASSIVE;
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*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ getaddrinfo(char *, char *, struct addrinfo *,
                               struct addrinfo **);
int /*<<< orphan*/ getnameinfo(struct sockaddr *, int, char *, int, char *, int,
                               int /*<<< orphan*/);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void main(int args, char *argv[]) {
  struct addrinfo hints, *res;
  struct sockaddr_storage cli;
  char sbuf[81], rbuf[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 stop = 0;
  while (!stop) {
    socklen_t clen = sizeof(cli);
    int c = recvfrom(sd, rbuf, 1, 0, (struct sockaddr *)&cli, &clen);
    getnameinfo((struct sockaddr *)&cli, clen, host, NI_MAXHOST, serv,
                NI_MAXSERV, NI_NUMERICHOST);
    printf("Message recieved from %s::%s\n", host, serv);
    printf("Length: %d Bytes\tMsg:%s\n", c, rbuf);
    time_t ti = time(NULL);
    struct tm *timeData = gmtime(&ti);
    switch (rbuf[0]) {
    case 't':
      sprintf(sbuf, "Hour:\t%02d:%02d:%02d", timeData->tm_hour + 2,
              timeData->tm_min, timeData->tm_sec);
      break;
    case 'd':
      sprintf(sbuf, "Year:20%02d\tMonth:%02d\tDay:%02d",
              timeData->tm_year - 100, timeData->tm_mon + 1, timeData->tm_mday);
      break;
    case 'q':
      sprintf(sbuf, "Goodbye client");
      stop = 1;
      break;
    }
    c = strlen(sbuf);
    sbuf[c] = '\n';
    sbuf[c + 1] = '\0';
    sendto(sd, sbuf, c + 1, 0, (struct sockaddr *)&cli, clen);
  }
  close(sd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x108(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x148(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x110(%rbp)
mov    0x2dba(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x140(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x118(%rbp)
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2d6f(%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   10d0 <getaddrinfo@plt>
mov    -0x40(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x40(%rbp),%rax
mov    0x10(%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x11c(%rbp)
mov    -0x11c(%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   10e0 <freeaddrinfo@plt>
movl   $0x0,-0x120(%rbp)
cmpl   $0x0,-0x120(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12eb <main+0x11b>
jmp    1526 <main+0x356>
movl   $0x4,-0x124(%rbp)
mov    -0x11c(%rbp),%edi
lea    -0x100(%rbp),%rsi
mov    %rsi,-0x160(%rbp)
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %ecx,-0x150(%rbp)
lea    -0x48(%rbp),%r8
mov    %r8,-0x168(%rbp)
lea    -0x124(%rbp),%r9
call   1090 <recvfrom@plt>
mov    -0x168(%rbp),%rdi
mov    -0x148(%rbp),%rdx
mov    -0x140(%rbp),%r8
mov    %eax,-0x128(%rbp)
mov    -0x124(%rbp),%esi
mov    0x2c63(%rip),%rax
mov    (%rax),%ecx
mov    0x2c7a(%rip),%rax
mov    (%rax),%r9d
mov    0x2c58(%rip),%rax
mov    (%rax),%r10d
sub    $0x10,%rsp
mov    %rsp,%rax
mov    %r10d,(%rax)
call   1070 <getnameinfo@plt>
mov    -0x148(%rbp),%rsi
mov    -0x140(%rbp),%rdx
add    $0x10,%rsp
mov    -0x150(%rbp),%eax
lea    0xc67(%rip),%rdi
mov    %al,-0x151(%rbp)
call   1040 <printf@plt>
mov    -0x160(%rbp),%rdx
mov    -0x151(%rbp),%al
mov    -0x128(%rbp),%esi
lea    0xc60(%rip),%rdi
call   1040 <printf@plt>
mov    -0x150(%rbp),%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x12c(%rbp)
lea    -0x12c(%rbp),%rdi
call   10b0 <gmtime@plt>
mov    %rax,-0x138(%rbp)
movsbl -0x100(%rbp),%eax
mov    %eax,-0x14c(%rbp)
sub    $0x64,%eax
je     1467 <main+0x297>
jmp    1404 <main+0x234>
mov    -0x14c(%rbp),%eax
sub    $0x71,%eax
je     14a6 <main+0x2d6>
jmp    1418 <main+0x248>
mov    -0x14c(%rbp),%eax
sub    $0x74,%eax
jne    14c5 <main+0x2f5>
jmp    142c <main+0x25c>
lea    -0xa0(%rbp),%rdi
mov    -0x138(%rbp),%rax
mov    0x14(%rax),%edx
add    $0x2,%edx
mov    -0x138(%rbp),%rax
mov    (%rax),%ecx
mov    -0x138(%rbp),%rax
mov    0x4(%rax),%r8d
lea    0xbdc(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
jmp    14c5 <main+0x2f5>
lea    -0xa0(%rbp),%rdi
mov    -0x138(%rbp),%rax
mov    0x10(%rax),%edx
sub    $0x64,%edx
mov    -0x138(%rbp),%rax
mov    0xc(%rax),%ecx
add    $0x1,%ecx
mov    -0x138(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0xbb2(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
jmp    14c5 <main+0x2f5>
lea    -0xa0(%rbp),%rdi
lea    0xbb8(%rip),%rsi
mov    $0x0,%al
call   10c0 <sprintf@plt>
movl   $0x1,-0x120(%rbp)
lea    -0xa0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x128(%rbp)
movslq -0x128(%rbp),%rax
movb   $0xa,-0xa0(%rbp,%rax,1)
0a
mov    -0x128(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0xa0(%rbp,%rax,1)
mov    -0x11c(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    -0x128(%rbp),%edx
add    $0x1,%edx
lea    -0x48(%rbp),%r8
mov    -0x124(%rbp),%r9d
xor    %ecx,%ecx
call   1050 <sendto@plt>
jmp    12d2 <main+0x102>
mov    -0x11c(%rbp),%edi
call   1060 <close@plt>
mov    -0x108(%rbp),%rax
mov    %rax,%rsp
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    $0x118,%rsp
mov    %rsp,-0x48(%rbp)
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2da9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
movq   $0x0,-0x70(%rbp)
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rsi
lea    -0x88(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10d0 <getaddrinfo@plt>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%esi
mov    0x14(%rax),%edi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,%r14d
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edx
mov    %r14d,%edi
call   10a0 <bind@plt>
mov    -0x38(%rbp),%rdi
call   10e0 <freeaddrinfo@plt>
lea    -0x60(%rbp),%r12
mov    %r14d,-0x2c(%rbp)
mov    -0x50(%rbp),%r13
jmp    1314 <main+0x144>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rax),%edx
add    $0xffffff9c,%edx
mov    0x8(%rax),%r8d
mov    0xc(%rax),%ecx
add    $0x1,%ecx
lea    -0xe0(%rbp),%rbx
mov    %rbx,%rdi
lea    0xd7b(%rip),%rsi
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    %r14,%r12
mov    -0x2c(%rbp),%r14d
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdx
movw   $0xa,-0xe0(%rbp,%rdx,1)
add    $0x1,%edx
mov    -0x30(%rbp),%r9d
mov    %r14d,%edi
mov    %rbx,%rsi
xor    %ecx,%ecx
mov    %r12,%r8
call   1050 <sendto@plt>
test   %r15b,%r15b
je     1448 <main+0x278>
movl   $0x4,-0x30(%rbp)
mov    %r14d,%edi
lea    -0x140(%rbp),%rbx
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    %r12,%r8
lea    -0x30(%rbp),%r9
call   1090 <recvfrom@plt>
mov    %r12,%rdi
mov    %eax,%r12d
mov    -0x30(%rbp),%esi
mov    0x2c6d(%rip),%rax
mov    (%rax),%ecx
mov    0x2c84(%rip),%rax
mov    (%rax),%r9d
mov    0x2c62(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    %rdi,%r14
mov    -0x58(%rbp),%r15
mov    %r15,%rdx
mov    %r13,%r8
push   %rax
call   1070 <getnameinfo@plt>
add    $0x10,%rsp
lea    0xc7e(%rip),%rdi
mov    %r15,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc88(%rip),%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x3c(%rbp),%rdi
call   10b0 <gmtime@plt>
movsbl -0x140(%rbp),%ecx
mov    $0x1,%r15b
cmp    $0x64,%ecx
je     12b0 <main+0xe0>
cmp    $0x71,%ecx
je     1410 <main+0x240>
cmp    $0x74,%ecx
mov    %r14,%r12
lea    -0xe0(%rbp),%rbx
jne    12db <main+0x10b>
mov    0x14(%rax),%edx
add    $0x2,%edx
mov    (%rax),%ecx
mov    0x4(%rax),%r8d
mov    %rbx,%rdi
lea    0xc40(%rip),%rsi
xor    %eax,%eax
call   10c0 <sprintf@plt>
mov    -0x2c(%rbp),%r14d
jmp    12df <main+0x10f>
nopw   0x0(%rax,%rax,1)
movabs $0x746e65696c6320,%rax
mov    %rax,-0xd9(%rbp)
movabs $0x20657962646f6f47,%rax
79 65 20
mov    %rax,-0xe0(%rbp)
xor    %r15d,%r15d
mov    %r14,%r12
mov    -0x2c(%rbp),%r14d
lea    -0xe0(%rbp),%rbx
jmp    12df <main+0x10f>
mov    %r14d,%edi
call   1060 <close@plt>
mov    -0x48(%rbp),%rsp
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, 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
@NI_NUMERICHOST = global i32 0
@.str = [30 x i8] c"Message recieved from %s::%s\0A\00"
@.str.1 = [25 x i8] c"Length: %d Bytes\09Msg:%s\0A\00"
@.str.2 = [21 x i8] c"Hour:\09%02d:%02d:%02d\00"
@.str.3 = [32 x i8] c"Year:20%02d\09Month:%02d\09Day:%02d\00"
@.str.4 = [15 x i8] c"Goodbye client\00"
define void @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.addrinfo
%6 = alloca %struct.addrinfo*
%7 = alloca %struct.sockaddr_storage
%8 = alloca [81 x i8]
%9 = alloca [81 x i8]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.tm*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%19 = load i32, i32* @NI_MAXHOST
%20 = zext i32 %19 to i64
%21 = call i8* @llvm.stacksave()
store i8* %21, i8** %10
%22 = alloca i8, i64 %20
store i64 %20, i64* %11
%23 = load i32, i32* @NI_MAXSERV
%24 = zext i32 %23 to i64
%25 = alloca i8, i64 %24
store i64 %24, i64* %12
%26 = load i32, i32* @AI_PASSIVE
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i32 0, i32 5
store i32 %26, i32* %27
%28 = load i32, i32* @AF_UNSPEC
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i32 0, i32 3
store i32 %28, i32* %29
%30 = load i32, i32* @SOCK_DGRAM
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i32 0, i32 2
store i32 %30, i32* %31
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i32 0, i32 4
store i64 0, i64* %32
%33 = load i8**, i8*** %4
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = load i8**, i8*** %4
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 @getaddrinfo(i8* %35, i8* %38, %struct.addrinfo* %5, %struct.addrinfo** %6)
%40 = load %struct.addrinfo*, %struct.addrinfo** %6
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i32 0, i32 3
%42 = load i32, i32* %41
%43 = load %struct.addrinfo*, %struct.addrinfo** %6
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i32 0, i32 2
%45 = load i32, i32* %44
%46 = call i32 @socket(i32 %42, i32 %45, i32 0)
store i32 %46, i32* %13
%47 = load i32, i32* %13
%48 = load %struct.addrinfo*, %struct.addrinfo** %6
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %48, i32 0, i32 1
%50 = load i64, i64* %49
%51 = inttoptr i64 %50 to %struct.sockaddr*
%52 = load %struct.addrinfo*, %struct.addrinfo** %6
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i32 0, i32 0
%54 = load i32, i32* %53
%55 = call i32 @bind(i32 %47, %struct.sockaddr* %51, i32 %54)
%56 = load %struct.addrinfo*, %struct.addrinfo** %6
%57 = call i32 @freeaddrinfo(%struct.addrinfo* %56)
store i32 0, i32* %14
br label %58
58: ; preds = %112, %2
%59 = load i32, i32* %14
%60 = icmp ne i32 %59, 0
%61 = xor i1 %60, true
br i1 %61, label %62, label %129
62: ; preds = %58
store i32 4, i32* %15
%63 = load i32, i32* %13
%64 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%65 = bitcast %struct.sockaddr_storage* %7 to %struct.sockaddr*
%66 = call i32 @recvfrom(i32 %63, i8* %64, i32 1, i32 0, %struct.sockaddr* %65, i32* %15)
store i32 %66, i32* %16
%67 = bitcast %struct.sockaddr_storage* %7 to %struct.sockaddr*
%68 = load i32, i32* %15
%69 = load i32, i32* @NI_MAXHOST
%70 = load i32, i32* @NI_MAXSERV
%71 = load i32, i32* @NI_NUMERICHOST
%72 = call i32 @getnameinfo(%struct.sockaddr* %67, i32 %68, i8* %22, i32 %69, i8* %25, i32 %70, i32 %71)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %22, i8* %25)
%74 = load i32, i32* %16
%75 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %74, i8* %75)
%77 = call i32 @time(i32* null)
store i32 %77, i32* %17
%78 = call %struct.tm* @gmtime(i32* %17)
store %struct.tm* %78, %struct.tm** %18
%79 = getelementptr inbounds [81 x i8], [81 x i8]* %9, i64 0, i64 0
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
switch i32 %81, label %112 [
i32 116, label %82
i32 100, label %95
i32 113, label %109
]
82: ; preds = %62
%83 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%84 = load %struct.tm*, %struct.tm** %18
%85 = getelementptr inbounds %struct.tm, %struct.tm* %84, i32 0, i32 5
%86 = load i32, i32* %85
%87 = add nsw i32 %86, 2
%88 = load %struct.tm*, %struct.tm** %18
%89 = getelementptr inbounds %struct.tm, %struct.tm* %88, i32 0, i32 0
%90 = load i32, i32* %89
%91 = load %struct.tm*, %struct.tm** %18
%92 = getelementptr inbounds %struct.tm, %struct.tm* %91, i32 0, i32 1
%93 = load i32, i32* %92
%94 = call i32 (i8*, i8*, ...) @sprintf(i8* %83, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %87, i32 %90, i32 %93)
br label %112
95: ; preds = %62
%96 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%97 = load %struct.tm*, %struct.tm** %18
%98 = getelementptr inbounds %struct.tm, %struct.tm* %97, i32 0, i32 4
%99 = load i32, i32* %98
%100 = sub nsw i32 %99, 100
%101 = load %struct.tm*, %struct.tm** %18
%102 = getelementptr inbounds %struct.tm, %struct.tm* %101, i32 0, i32 3
%103 = load i32, i32* %102
%104 = add nsw i32 %103, 1
%105 = load %struct.tm*, %struct.tm** %18
%106 = getelementptr inbounds %struct.tm, %struct.tm* %105, i32 0, i32 2
%107 = load i32, i32* %106
%108 = call i32 (i8*, i8*, ...) @sprintf(i8* %96, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %100, i32 %104, i32 %107)
br label %112
109: ; preds = %62
%110 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%111 = call i32 (i8*, i8*, ...) @sprintf(i8* %110, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %14
br label %112
112: ; preds = %62, %109, %95, %82
%113 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%114 = call i32 @strlen(i8* %113)
store i32 %114, i32* %16
%115 = load i32, i32* %16
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 %116
store i8 10, i8* %117
%118 = load i32, i32* %16
%119 = add nsw i32 %118, 1
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 %120
store i8 0, i8* %121
%122 = load i32, i32* %13
%123 = getelementptr inbounds [81 x i8], [81 x i8]* %8, i64 0, i64 0
%124 = load i32, i32* %16
%125 = add nsw i32 %124, 1
%126 = bitcast %struct.sockaddr_storage* %7 to %struct.sockaddr*
%127 = load i32, i32* %15
%128 = call i32 @sendto(i32 %122, i8* %123, i32 %125, i32 0, %struct.sockaddr* %126, i32 %127)
br label %58
129: ; preds = %58
%130 = load i32, i32* %13
%131 = call i32 @close(i32 %130)
%132 = load i8*, i8** %10
ret void
}

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
@NI_NUMERICHOST = global i32 0
@.str = [30 x i8] c"Message recieved from %s::%s\0A\00"
@.str.1 = [25 x i8] c"Length: %d Bytes\09Msg:%s\0A\00"
@.str.2 = [21 x i8] c"Hour:\09%02d:%02d:%02d\00"
@.str.3 = [32 x i8] c"Year:20%02d\09Month:%02d\09Day:%02d\00"
@.str.4 = [15 x i8] c"Goodbye client\00"
define void @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 [81 x i8]
%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 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%15 = load i32, i32* @NI_MAXHOST
%16 = zext i32 %15 to i64
%17 = tail call i8* @llvm.stacksave()
%18 = alloca i8, i64 %16
%19 = load i32, i32* @NI_MAXSERV
%20 = zext i32 %19 to i64
%21 = alloca i8, i64 %20
%22 = load i32, i32* @AI_PASSIVE
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 5
store i32 %22, i32* %23
%24 = load i32, i32* @AF_UNSPEC
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %24, i32* %25
%26 = load i32, i32* @SOCK_DGRAM
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 2
store i32 %26, i32* %27
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i64 0, i64* %28
%29 = getelementptr inbounds i8*, i8** %1, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds i8*, i8** %1, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @getaddrinfo(i8* %30, i8* %32, %struct.addrinfo* %3, %struct.addrinfo** %4)
%34 = load %struct.addrinfo*, %struct.addrinfo** %4
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 3
%36 = load i32, i32* %35
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %34, i64 0, i32 2
%38 = load i32, i32* %37
%39 = call i32 @socket(i32 %36, i32 %38, i32 0)
%40 = load %struct.addrinfo*, %struct.addrinfo** %4
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 1
%42 = load i64, i64* %41
%43 = inttoptr i64 %42 to %struct.sockaddr*
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 0
%45 = load i32, i32* %44
%46 = call i32 @bind(i32 %39, %struct.sockaddr* %43, i32 %45)
%47 = load %struct.addrinfo*, %struct.addrinfo** %4
%48 = call i32 @freeaddrinfo(%struct.addrinfo* %47)
%49 = bitcast i32* %8 to i8*
%50 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
%51 = bitcast i32* %9 to i8*
br label %52
52: ; preds = %2, %85
store i32 4, i32* %8
%53 = call i32 @recvfrom(i32 %39, i8* %14, i32 1, i32 0, %struct.sockaddr* %50, i32* %8)
%54 = load i32, i32* %8
%55 = load i32, i32* @NI_MAXHOST
%56 = load i32, i32* @NI_MAXSERV
%57 = load i32, i32* @NI_NUMERICHOST
%58 = call i32 @getnameinfo(%struct.sockaddr* %50, i32 %54, i8* %18, i32 %55, i8* %21, i32 %56, i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %21)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %53, i8* %14)
%61 = call i32 @time(i32* null)
store i32 %61, i32* %9
%62 = call %struct.tm* @gmtime(i32* %9)
%63 = load i8, i8* %14
%64 = sext i8 %63 to i32
switch i32 %64, label %85 [
i32 116, label %65
i32 100, label %74
i32 113, label %84
]
65: ; preds = %52
%66 = getelementptr inbounds %struct.tm, %struct.tm* %62, i64 0, i32 5
%67 = load i32, i32* %66
%68 = add nsw i32 %67, 2
%69 = getelementptr inbounds %struct.tm, %struct.tm* %62, i64 0, i32 0
%70 = load i32, i32* %69
%71 = getelementptr inbounds %struct.tm, %struct.tm* %62, i64 0, i32 1
%72 = load i32, i32* %71
%73 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %68, i32 %70, i32 %72)
br label %85
74: ; preds = %52
%75 = getelementptr inbounds %struct.tm, %struct.tm* %62, i64 0, i32 4
%76 = load i32, i32* %75
%77 = add nsw i32 %76, -100
%78 = getelementptr inbounds %struct.tm, %struct.tm* %62, i64 0, i32 3
%79 = load i32, i32* %78
%80 = add nsw i32 %79, 1
%81 = getelementptr inbounds %struct.tm, %struct.tm* %62, i64 0, i32 2
%82 = load i32, i32* %81
%83 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %77, i32 %80, i32 %82)
br label %85
84: ; preds = %52
br label %85
85: ; preds = %52, %84, %74, %65
%86 = phi i1 [ true, %52 ], [ false, %84 ], [ true, %74 ], [ true, %65 ]
%87 = call i32 @strlen(i8* %13)
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 %88
store i8 10, i8* %89
%90 = add nsw i32 %87, 1
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [81 x i8], [81 x i8]* %6, i64 0, i64 %91
store i8 0, i8* %92
%93 = load i32, i32* %8
%94 = call i32 @sendto(i32 %39, i8* %13, i32 %90, i32 0, %struct.sockaddr* %50, i32 %93)
br i1 %86, label %52, label %95
95: ; preds = %85
%96 = call i32 @close(i32 %39)
ret void
}