#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 {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ servaddr;
typedef int /*<<< orphan*/ cliaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
char *asctime(struct tm *);
int /*<<< orphan*/ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int /*<<< orphan*/ sendto(int, char *, int /*<<< orphan*/, int /*<<< orphan*/,
                          struct sockaddr *, int);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int sockfd, n;
  struct sockaddr_in servaddr, cliaddr;
  socklen_t len;
  char mesg[1000], *msg;
  time_t rt;
  struct tm *ti;
  sockfd = socket(AF_INET, SOCK_DGRAM, 0);
  servaddr.sin_family = AF_INET;
  servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  servaddr.sin_port = htons(32000);
  bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
  len = sizeof(cliaddr);
  n = recvfrom(sockfd, mesg, 1000, 0, (struct sockaddr *)&cliaddr, &len);
  mesg[n] = 0;
  printf("Recived: %s\n", mesg);
  while (1) {
    time(&rt);
    ti = localtime(&rt);
    msg = asctime(ti);
    sendto(sockfd, msg, strlen(msg), 0, (struct sockaddr *)&cliaddr,
           sizeof(cliaddr));
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x8(%rbp)
mov    0x2df3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x14(%rbp)
mov    $0x7d00,%edi
call   1060 <htons@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
movl   $0xc,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x420(%rbp),%rsi
lea    -0x28(%rbp),%r8
mov    $0x3e8,%edx
xor    %ecx,%ecx
lea    -0x2c(%rbp),%r9
call   10b0 <recvfrom@plt>
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rsi
lea    0xd95(%rip),%rdi
call   1070 <printf@plt>
lea    -0x42c(%rbp),%rdi
call   10a0 <time@plt>
lea    -0x42c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x438(%rbp)
mov    -0x438(%rbp),%rdi
call   1050 <asctime@plt>
mov    %rax,-0x428(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x444(%rbp)
mov    -0x428(%rbp),%rax
mov    %rax,-0x440(%rbp)
mov    -0x428(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x444(%rbp),%edi
mov    -0x440(%rbp),%rsi
mov    %eax,%edx
lea    -0x28(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1090 <sendto@plt>
mov    $0x1,%edi
call   10d0 <sleep@plt>
jmp    1270 <main+0xb0>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    0x2e14(%rip),%rbx
mov    (%rbx),%edi
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,%r15d
mov    (%rbx),%eax
mov    %eax,0x18(%rsp)
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    $0x7d00,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r15d,%edi
mov    $0xc,%edx
call   10c0 <bind@plt>
movl   $0xc,0xc(%rsp)
lea    0x30(%rsp),%rbx
lea    0x20(%rsp),%r14
lea    0xc(%rsp),%r9
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x3e8,%edx
xor    %ecx,%ecx
mov    %r14,%r8
call   10b0 <recvfrom@plt>
cltq
movb   $0x0,0x30(%rsp,%rax,1)
lea    0xda5(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
lea    0x1c(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10a0 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
mov    %rax,%rdi
call   1050 <asctime@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1040 <strlen@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %r14,%r8
mov    $0xc,%r9d
call   1090 <sendto@plt>
mov    $0x1,%edi
call   10d0 <sleep@plt>
jmp    1270 <main+0xb0>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.tm = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@INADDR_ANY = global i32 0
@.str = [13 x i8] c"Recived: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca [1000 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca %struct.tm*
store i32 0, i32* %1
%11 = load i32, i32* @AF_INET
%12 = load i32, i32* @SOCK_DGRAM
%13 = call i32 @socket(i32 %11, i32 %12, i32 0)
store i32 %13, i32* %2
%14 = load i32, i32* @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 2
store i32 %14, i32* %15
%16 = load i32, i32* @INADDR_ANY
%17 = call i32 @htonl(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 1
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 0
store i32 %17, i32* %19
%20 = call i32 @htons(i32 32000)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i32 0, i32 0
store i32 %20, i32* %21
%22 = load i32, i32* %2
%23 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%24 = call i32 @bind(i32 %22, %struct.sockaddr* %23, i32 12)
store i32 12, i32* %6
%25 = load i32, i32* %2
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%27 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%28 = call i32 @recvfrom(i32 %25, i8* %26, i32 1000, i32 0, %struct.sockaddr* %27, i32* %6)
store i32 %28, i32* %3
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %30
store i8 0, i8* %31
%32 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %0, %34
%35 = call i32 @time(i32* %9)
%36 = call %struct.tm* @localtime(i32* %9)
store %struct.tm* %36, %struct.tm** %10
%37 = load %struct.tm*, %struct.tm** %10
%38 = call i8* @asctime(%struct.tm* %37)
store i8* %38, i8** %8
%39 = load i32, i32* %2
%40 = load i8*, i8** %8
%41 = load i8*, i8** %8
%42 = call i32 @strlen(i8* %41)
%43 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%44 = call i32 @sendto(i32 %39, i8* %40, i32 %42, i32 0, %struct.sockaddr* %43, i32 12)
%45 = call i32 @sleep(i32 1)
br label %34
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
%struct.tm = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@INADDR_ANY = global i32 0
@.str = [13 x i8] c"Recived: %s\0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.sockaddr_in
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = alloca i32
%6 = bitcast %struct.sockaddr_in* %1 to i8*
%7 = bitcast %struct.sockaddr_in* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%10 = bitcast i32* %5 to i8*
%11 = load i32, i32* @AF_INET
%12 = load i32, i32* @SOCK_DGRAM
%13 = tail call i32 @socket(i32 %11, i32 %12, i32 0)
%14 = load i32, i32* @AF_INET
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %14, i32* %15
%16 = load i32, i32* @INADDR_ANY
%17 = tail call i32 @htonl(i32 %16)
%18 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
store i32 %17, i32* %18
%19 = tail call i32 @htons(i32 32000)
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
store i32 %19, i32* %20
%21 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%22 = call i32 @bind(i32 %13, %struct.sockaddr* %21, i32 12)
store i32 12, i32* %3
%23 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%24 = call i32 @recvfrom(i32 %13, i8* %9, i32 1000, i32 0, %struct.sockaddr* %23, i32* %3)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 %25
store i8 0, i8* %26
%27 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %28
28: ; preds = %28, %0
%29 = call i32 @time(i32* %5)
%30 = call %struct.tm* @localtime(i32* %5)
%31 = call i8* @asctime(%struct.tm* %30)
%32 = call i32 @strlen(i8* %31)
%33 = call i32 @sendto(i32 %13, i8* %31, i32 %32, i32 0, %struct.sockaddr* %23, i32 12)
%34 = call i32 @sleep(i32 1)
br label %28
}