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

/* Type definitions */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  void *sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ dir_pi_udp;
typedef int /*<<< orphan*/ dir_pi_tcp;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
void *htons(int);
scalar_t__ inet_aton(char *, TYPE_1__ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int recvfrom(int, char *, int, int /*<<< orphan*/, int /*<<< orphan*/ *,
             int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int input_sock, output_sock, i, aux = -1, maxR = 1024 - 2;
  struct sockaddr_in dir_pi_udp, dir_pi_tcp;
  char buf[1024];
  char *b = &buf[16];
  if ((input_sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    perror("Error creating the input_socket");
    return 1;
  }
  memset(&dir_pi_udp, 0, sizeof(dir_pi_udp));
  dir_pi_udp.sin_family = AF_INET;
  dir_pi_udp.sin_addr.s_addr = htonl(INADDR_ANY);
  dir_pi_udp.sin_port = htons(514);
  if (bind(input_sock, (struct sockaddr *)&dir_pi_udp, sizeof(dir_pi_udp)) <
      0) {
    perror("Error assigning an address input_socket");
    close(input_sock);
    return 1;
  }
  if ((output_sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("Error creating the output_sock");
    close(output_sock);
    return 1;
  }
  memset(&dir_pi_tcp, 0, sizeof(dir_pi_tcp));
  dir_pi_tcp.sin_family = AF_INET;
  dir_pi_tcp.sin_port = htons(7777);
  if (inet_aton("51.255.62.40", &dir_pi_tcp.sin_addr) <= 0) {
    fprintf(stderr, "Error in VM's IP: %s\n", argv[1]);
    close(input_sock);
    close(output_sock);
    return 1;
  }
  while (aux < 0) {
    aux = connect(output_sock, (struct sockaddr *)&dir_pi_tcp,
                  sizeof(dir_pi_tcp));
    if (aux < 0) {
      perror("Error connecting with the VM");
      sleep(1);
    }
  }
  printf("Connected with the VM\n");
  while (1) {
    if ((aux = recvfrom(input_sock, b, maxR, 0, NULL, NULL)) < 0) {
      perror("Error receiving data");
      close(input_sock);
      return 1;
    }
    time_t timer;
    struct tm *tm_info;
    time(&timer);
    char date[16];
    tm_info = localtime(&timer);
    strftime(date, 16, "%b %e %H:%M:%S", tm_info);
    buf[15] = ' ';
    aux += 16;
    for (i = 0; i < 15; i++) {
      buf[i] = date[i];
    }
    buf[aux - 1] = '#';
    buf[aux] = '\n';
    buf[aux + 1] = '\0';
    if (write(output_sock, buf, aux + 1) < aux + 1) {
      perror("Error sending data");
      close(output_sock);
      return 1;
    }
  }
  close(input_sock);
  close(output_sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x20(%rbp)
movl   $0x3fe,-0x24(%rbp)
lea    -0x460(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x468(%rbp)
mov    0x2d98(%rip),%rax
mov    (%rax),%rdi
mov    0x2d7e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1287 <main+0x77>
lea    0xd8a(%rip),%rdi
call   1100 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1557 <main+0x347>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x40(%rbp)
mov    $0x202,%edi
call   1050 <htons@plt>
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x18,%edx
call   10e0 <bind@plt>
cmp    $0x0,%rax
jge    12ff <main+0xef>
lea    0xd3a(%rip),%rdi
call   1100 <perror@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1557 <main+0x347>
mov    0x2ce2(%rip),%rax
mov    (%rax),%rdi
mov    0x2cb0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1345 <main+0x135>
lea    0xd1c(%rip),%rdi
call   1100 <perror@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1557 <main+0x347>
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2c8c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    $0x1e61,%edi
call   1050 <htons@plt>
mov    %rax,-0x50(%rbp)
lea    -0x58(%rbp),%rsi
lea    0xceb(%rip),%rdi
call   10c0 <inet_aton@plt>
cmp    $0x0,%rax
jg     13c4 <main+0x1b4>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcd1(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1557 <main+0x347>
jmp    13c9 <main+0x1b9>
cmpl   $0x0,-0x20(%rbp)
jge    140c <main+0x1fc>
mov    -0x18(%rbp),%edi
lea    -0x58(%rbp),%rsi
mov    $0x18,%edx
call   1110 <connect@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1407 <main+0x1f7>
lea    0xc92(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <sleep@plt>
jmp    13c9 <main+0x1b9>
lea    0xc94(%rip),%rdi
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x468(%rbp),%rsi
mov    -0x24(%rbp),%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%r8
call   10d0 <recvfrom@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    1460 <main+0x250>
lea    0xc77(%rip),%rdi
call   1100 <perror@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1557 <main+0x347>
lea    -0x46c(%rbp),%rdi
call   10b0 <time@plt>
lea    -0x46c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x478(%rbp)
lea    -0x490(%rbp),%rdi
mov    -0x478(%rbp),%rcx
mov    $0x10,%esi
lea    0xc3a(%rip),%rdx
call   10f0 <strftime@plt>
movb   $0x20,-0x451(%rbp)
mov    -0x20(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf,-0x1c(%rbp)
jge    14e3 <main+0x2d3>
movslq -0x1c(%rbp),%rax
mov    -0x490(%rbp,%rax,1),%cl
movslq -0x1c(%rbp),%rax
mov    %cl,-0x460(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    14b5 <main+0x2a5>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x23,-0x460(%rbp,%rax,1)
23
movslq -0x20(%rbp),%rax
movb   $0xa,-0x460(%rbp,%rax,1)
0a
mov    -0x20(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x460(%rbp,%rax,1)
mov    -0x18(%rbp),%edi
lea    -0x460(%rbp),%rsi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
call   1040 <write@plt>
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1552 <main+0x342>
lea    0xba9(%rip),%rdi
call   1100 <perror@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    1557 <main+0x347>
jmp    1418 <main+0x208>
mov    -0x4(%rbp),%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x458,%rsp
mov    %rsi,%r14
mov    0x2dbd(%rip),%rbp
mov    0x0(%rbp),%rdi
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
js     1340 <main+0x130>
mov    %eax,%r15d
lea    0x38(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x48(%rsp)
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,0x38(%rsp)
mov    $0x202,%edi
call   1060 <htons@plt>
mov    %rax,0x40(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x18,%edx
call   10e0 <bind@plt>
test   %rax,%rax
js     134e <main+0x13e>
mov    0x0(%rbp),%rdi
mov    0x2d14(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%r13d
test   %eax,%eax
js     135a <main+0x14a>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x0(%rbp),%rax
mov    %rax,0x18(%rsp)
mov    $0x1e61,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0xd74(%rip),%rdi
mov    %rbx,%rsi
call   10c0 <inet_aton@plt>
test   %rax,%rax
jg     1366 <main+0x156>
mov    0x2cc1(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xd60(%rip),%rsi
call   10a0 <fprintf@plt>
mov    %r15d,%edi
call   1090 <close@plt>
mov    %r13d,%edi
call   1090 <close@plt>
mov    $0x1,%eax
add    $0x458,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcb9(%rip),%rdi
call   1100 <perror@plt>
jmp    1329 <main+0x119>
lea    0xccb(%rip),%rdi
jmp    1493 <main+0x283>
lea    0xce7(%rip),%rdi
jmp    14a7 <main+0x297>
lea    0x8(%rsp),%rsi
mov    %r13d,%edi
mov    $0x18,%edx
call   1110 <connect@plt>
test   %eax,%eax
jns    13b6 <main+0x1a6>
lea    0xd07(%rip),%r14
lea    0x8(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1120 <sleep@plt>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x18,%edx
call   1110 <connect@plt>
test   %eax,%eax
js     1390 <main+0x180>
lea    0xd21(%rip),%rdi
call   1040 <puts@plt>
mov    %r15d,%edi
lea    0x60(%rsp),%rsi
mov    $0x3fe,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10d0 <recvfrom@plt>
test   %eax,%eax
js     148c <main+0x27c>
mov    %eax,%r12d
lea    0x4(%rsp),%rbx
lea    0x50(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10b0 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0x20(%rsp),%rdi
mov    $0x10,%esi
lea    0xc9b(%rip),%rdx
mov    %rax,%rcx
call   10f0 <strftime@plt>
movb   $0x20,0x5f(%rsp)
mov    0x20(%rsp),%rax
mov    0x27(%rsp),%rcx
mov    %rax,0x50(%rsp)
mov    %rcx,0x57(%rsp)
mov    %r12d,%ebp
movw   $0xa23,0xf(%rbp,%r14,1)
0a
movb   $0x0,0x61(%rsp,%rbp,1)
add    $0x11,%rbp
mov    %r13d,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1050 <write@plt>
cmp    %ebp,%eax
jl     14a0 <main+0x290>
mov    %r15d,%edi
lea    0x60(%rsp),%rsi
mov    $0x3fe,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   10d0 <recvfrom@plt>
mov    %eax,%r12d
test   %eax,%eax
jns    1400 <main+0x1f0>
lea    0xc14(%rip),%rdi
call   1100 <perror@plt>
mov    %r15d,%edi
jmp    1324 <main+0x114>
lea    0xc24(%rip),%rdi
call   1100 <perror@plt>
jmp    1321 <main+0x111>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.tm = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str = [32 x i8] c"Error creating the input_socket\00"
@INADDR_ANY = global i32 0
@.str.1 = [40 x i8] c"Error assigning an address input_socket\00"
@SOCK_STREAM = global i32 0
@.str.2 = [31 x i8] c"Error creating the output_sock\00"
@.str.3 = [13 x i8] c"51.255.62.40\00"
@stderr = global i32 0
@.str.4 = [22 x i8] c"Error in VM's IP: %s\0A\00"
@.str.5 = [29 x i8] c"Error connecting with the VM\00"
@.str.6 = [23 x i8] c"Connected with the VM\0A\00"
@.str.7 = [21 x i8] c"Error receiving data\00"
@.str.8 = [15 x i8] c"%b %e %H:%M:%S\00"
@.str.9 = [19 x i8] c"Error sending data\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.sockaddr_in
%12 = alloca %struct.sockaddr_in
%13 = alloca [1024 x i8]
%14 = alloca i8*
%15 = alloca i32
%16 = alloca %struct.tm*
%17 = alloca [16 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %9
store i32 1022, i32* %10
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 16
store i8* %18, i8** %14
%19 = load i8*, i8** @AF_INET
%20 = load i32, i32* @SOCK_DGRAM
%21 = call i32 @socket(i8* %19, i32 %20, i32 0)
store i32 %21, i32* %6
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %2
%24 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %145
25: ; preds = %2
%26 = call i32 @memset(%struct.sockaddr_in* %11, i32 0, i32 24)
%27 = load i8*, i8** @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i8* %27, i8** %28
%29 = load i32, i32* @INADDR_ANY
%30 = call i32 @htonl(i32 %29)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%32 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %31, i32 0, i32 0
store i32 %30, i32* %32
%33 = call i8* @htons(i32 514)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i8* %33, i8** %34
%35 = load i32, i32* %6
%36 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%37 = call i64 @bind(i32 %35, %struct.sockaddr* %36, i32 24)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %25
%40 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%41 = load i32, i32* %6
%42 = call i32 @close(i32 %41)
store i32 1, i32* %3
br label %145
43: ; preds = %25
%44 = load i8*, i8** @AF_INET
%45 = load i32, i32* @SOCK_STREAM
%46 = call i32 @socket(i8* %44, i32 %45, i32 0)
store i32 %46, i32* %7
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %43
%49 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%50 = load i32, i32* %7
%51 = call i32 @close(i32 %50)
store i32 1, i32* %3
br label %145
52: ; preds = %43
%53 = call i32 @memset(%struct.sockaddr_in* %12, i32 0, i32 24)
%54 = load i8*, i8** @AF_INET
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
store i8* %54, i8** %55
%56 = call i8* @htons(i32 7777)
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
store i8* %56, i8** %57
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%59 = call i64 @inet_aton(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %struct.TYPE_2__* %58)
%60 = icmp sle i64 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %52
%62 = load i32, i32* @stderr
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 1
%65 = load i8*, i8** %64
%66 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %65)
%67 = load i32, i32* %6
%68 = call i32 @close(i32 %67)
%69 = load i32, i32* %7
%70 = call i32 @close(i32 %69)
store i32 1, i32* %3
br label %145
71: ; preds = %52
br label %72
72: ; preds = %84, %71
%73 = load i32, i32* %9
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %85
75: ; preds = %72
%76 = load i32, i32* %7
%77 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%78 = call i32 @connect(i32 %76, %struct.sockaddr* %77, i32 24)
store i32 %78, i32* %9
%79 = load i32, i32* %9
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %84
81: ; preds = %75
%82 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%83 = call i32 @sleep(i32 1)
br label %84
84: ; preds = %81, %75
br label %72
85: ; preds = %72
%86 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %87
87: ; preds = %85, %144
%88 = load i32, i32* %6
%89 = load i8*, i8** %14
%90 = load i32, i32* %10
%91 = call i32 @recvfrom(i32 %88, i8* %89, i32 %90, i32 0, i32* null, i32* null)
store i32 %91, i32* %9
%92 = icmp slt i32 %91, 0
br i1 %92, label %93, label %97
93: ; preds = %87
%94 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%95 = load i32, i32* %6
%96 = call i32 @close(i32 %95)
store i32 1, i32* %3
br label %145
97: ; preds = %87
%98 = call i32 @time(i32* %15)
%99 = call %struct.tm* @localtime(i32* %15)
store %struct.tm* %99, %struct.tm** %16
%100 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 0
%101 = load %struct.tm*, %struct.tm** %16
%102 = call i32 @strftime(i8* %100, i32 16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), %struct.tm* %101)
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 15
store i8 32, i8* %103
%104 = load i32, i32* %9
%105 = add nsw i32 %104, 16
store i32 %105, i32* %9
store i32 0, i32* %8
br label %106
106: ; preds = %117, %97
%107 = load i32, i32* %8
%108 = icmp slt i32 %107, 15
br i1 %108, label %109, label %120
109: ; preds = %106
%110 = load i32, i32* %8
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [16 x i8], [16 x i8]* %17, i64 0, i64 %111
%113 = load i8, i8* %112
%114 = load i32, i32* %8
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %115
store i8 %113, i8* %116
br label %117
117: ; preds = %109
%118 = load i32, i32* %8
%119 = add nsw i32 %118, 1
store i32 %119, i32* %8
br label %106
120: ; preds = %106
%121 = load i32, i32* %9
%122 = sub nsw i32 %121, 1
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %123
store i8 35, i8* %124
%125 = load i32, i32* %9
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %126
store i8 10, i8* %127
%128 = load i32, i32* %9
%129 = add nsw i32 %128, 1
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 %130
store i8 0, i8* %131
%132 = load i32, i32* %7
%133 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%134 = load i32, i32* %9
%135 = add nsw i32 %134, 1
%136 = call i32 @write(i32 %132, i8* %133, i32 %135)
%137 = load i32, i32* %9
%138 = add nsw i32 %137, 1
%139 = icmp slt i32 %136, %138
br i1 %139, label %140, label %144
140: ; preds = %120
%141 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%142 = load i32, i32* %7
%143 = call i32 @close(i32 %142)
store i32 1, i32* %3
br label %145
144: ; preds = %120
br label %87
145: ; preds = %140, %93, %61, %48, %39, %23
%146 = load i32, i32* %3
ret i32 %146
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
%struct.tm = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@.str = [32 x i8] c"Error creating the input_socket\00"
@INADDR_ANY = global i32 0
@.str.1 = [40 x i8] c"Error assigning an address input_socket\00"
@SOCK_STREAM = global i32 0
@.str.2 = [31 x i8] c"Error creating the output_sock\00"
@.str.3 = [13 x i8] c"51.255.62.40\00"
@stderr = global i32 0
@.str.4 = [22 x i8] c"Error in VM's IP: %s\0A\00"
@.str.5 = [29 x i8] c"Error connecting with the VM\00"
@.str.7 = [21 x i8] c"Error receiving data\00"
@.str.8 = [15 x i8] c"%b %e %H:%M:%S\00"
@.str.9 = [19 x i8] c"Error sending data\00"
@str = [22 x i8] c"Connected with the VM\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 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = alloca i32
%8 = alloca [16 x i8]
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%10 = bitcast %struct.sockaddr_in* %3 to i8*
%11 = bitcast %struct.sockaddr_in* %4 to i8*
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 16
%14 = load i8*, i8** @AF_INET
%15 = load i32, i32* @SOCK_DGRAM
%16 = tail call i32 @socket(i8* %14, i32 %15, i32 0)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %101
20: ; preds = %2
%21 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 24)
%22 = load i8*, i8** @AF_INET
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i8* %22, i8** %23
%24 = load i32, i32* @INADDR_ANY
%25 = call i32 @htonl(i32 %24)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %25, i32* %26
%27 = call i8* @htons(i32 514)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i8* %27, i8** %28
%29 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%30 = call i64 @bind(i32 %16, %struct.sockaddr* %29, i32 24)
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %20
%33 = call i32 @perror(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @close(i32 %16)
br label %101
35: ; preds = %20
%36 = load i8*, i8** @AF_INET
%37 = load i32, i32* @SOCK_STREAM
%38 = call i32 @socket(i8* %36, i32 %37, i32 0)
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @close(i32 %38)
br label %101
43: ; preds = %35
%44 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 24)
%45 = load i8*, i8** @AF_INET
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i8* %45, i8** %46
%47 = call i8* @htons(i32 7777)
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i8* %47, i8** %48
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%50 = call i64 @inet_aton(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), %struct.TYPE_2__* %49)
%51 = icmp slt i64 %50, 1
br i1 %51, label %56, label %52
52: ; preds = %43
%53 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%54 = call i32 @connect(i32 %38, %struct.sockaddr* %53, i32 24)
%55 = icmp slt i32 %54, 0
br i1 %55, label %63, label %68
56: ; preds = %43
%57 = load i32, i32* @stderr
%58 = getelementptr inbounds i8*, i8** %1, i64 1
%59 = load i8*, i8** %58
%60 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %59)
%61 = call i32 @close(i32 %16)
%62 = call i32 @close(i32 %38)
br label %101
63: ; preds = %52, %63
%64 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
%65 = call i32 @sleep(i32 1)
%66 = call i32 @connect(i32 %38, %struct.sockaddr* %53, i32 24)
%67 = icmp slt i32 %66, 0
br i1 %67, label %63, label %68
68: ; preds = %63, %52
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%70 = call i32 @recvfrom(i32 %16, i8* %13, i32 1022, i32 0, i32* null, i32* null)
%71 = icmp slt i32 %70, 0
br i1 %71, label %76, label %72
72: ; preds = %68
%73 = bitcast i32* %7 to i8*
%74 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 15
br label %79
76: ; preds = %98, %68
%77 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%78 = call i32 @close(i32 %16)
br label %101
79: ; preds = %72, %98
%80 = phi i32 [ %70, %72 ], [ %99, %98 ]
%81 = call i32 @time(i32* %7)
%82 = call %struct.tm* @localtime(i32* %7)
%83 = call i32 @strftime(i8* %74, i32 16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), %struct.tm* %82)
store i8 32, i8* %75
%84 = add nuw nsw i32 %80, 16
%85 = add nuw nsw i32 %80, 15
%86 = zext i32 %85 to i64
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %86
store i8 35, i8* %87
%88 = zext i32 %84 to i64
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %88
store i8 10, i8* %89
%90 = add nuw nsw i32 %80, 17
%91 = zext i32 %90 to i64
%92 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %91
store i8 0, i8* %92
%93 = call i32 @write(i32 %38, i8* %12, i32 %90)
%94 = icmp slt i32 %93, %90
br i1 %94, label %95, label %98
95: ; preds = %79
%96 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
%97 = call i32 @close(i32 %38)
br label %101
98: ; preds = %79
%99 = call i32 @recvfrom(i32 %16, i8* %13, i32 1022, i32 0, i32* null, i32* null)
%100 = icmp slt i32 %99, 0
br i1 %100, label %76, label %79
101: ; preds = %95, %76, %56, %40, %32, %18
ret i32 1
}