#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 uint32_t;
typedef scalar_t__ time_t;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strlen(char *);
scalar_t__ time(int /*<<< orphan*/ *);
void timestamp(int sockfd) {
  char buf[32];
  time_t current_time;
  current_time = time(NULL);
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "timestamp: %u", (uint32_t)current_time);
  send(sockfd, buf, strlen(buf), 0);
}


x86 assembly (clang, -O0):
<timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
lea    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    %eax,%edx
lea    0xe77(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x44(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestamp>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %edi,%r14d
xor    %edi,%edi
call   1060 <time@plt>
mov    %rax,%rbx
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
lea    0xe82(%rip),%rsi
mov    %rbp,%rdi
mov    %ebx,%edx
call   1070 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"timestamp: %u\00"
define void @timestamp(i32 %0) {
%2 = alloca i32
%3 = alloca [32 x i8]
%4 = alloca i64
store i32 %0, i32* %2
%5 = call i64 @time(i32* null)
store i64 %5, i64* %4
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 32)
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%9 = load i64, i64* %4
%10 = trunc i64 %9 to i32
%11 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %2
%13 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%14 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = call i32 @send(i32 %12, i8* %13, i32 %15, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"timestamp: %u\00"
define void @timestamp(i32 %0) {
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @time(i32* null)
%5 = call i32 @memset(i8* %3, i32 0, i32 32)
%6 = trunc i64 %4 to i32
%7 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @strlen(i8* %3)
%9 = call i32 @send(i32 %0, i8* %3, i32 %8, i32 0)
ret void
}