#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 */
struct tm {
  int dummy;
};
struct timezone {
  int dummy;
};
struct timeval {
  int tv_usec;
  int /*<<< orphan*/ tv_sec;
};
typedef int /*<<< orphan*/ lbuf;

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *const);
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ snprintf(char *, int, char *, int /*<<< orphan*/, int);
const char *timestamp() {
  static char lbuf[100] = {'\0', '\0'};
  struct timeval now;
  struct timezone *const tz = NULL;
  gettimeofday(&now, tz);
  struct tm _tm;
  localtime_r(&now.tv_sec, &_tm);
  snprintf(lbuf, sizeof(lbuf) - 1, "gettimeofday  %02li.%09li", now.tv_sec,
           now.tv_usec * 1000);
  return lbuf;
}


x86 assembly (clang, -O0):
<timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x10(%rbp)
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    -0x8(%rbp),%rdi
add    $0x4,%rdi
lea    -0x18(%rbp),%rsi
call   1030 <localtime_r@plt>
mov    -0x4(%rbp),%ecx
imul   $0x3e8,-0x8(%rbp),%r8d
lea    0x2ee0(%rip),%rdi
mov    $0x63,%esi
lea    0xe84(%rip),%rdx
call   1040 <snprintf@plt>
lea    0x2ec8(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestamp>:
push   %rbx
sub    $0x10,%rsp
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0x4(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <localtime_r@plt>
mov    0x4(%rsp),%ecx
imul   $0x3e8,(%rsp),%r8d
lea    0x2eef(%rip),%rbx
lea    0xe98(%rip),%rdx
mov    %rbx,%rdi
mov    $0x63,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
%struct.tm = type { i32 }
@timestamp.lbuf = internal global [100 x i8] zeroinitializer
@.str = [26 x i8] c"gettimeofday %02li.%09li\00"
define i8* @timestamp() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone*
%3 = alloca %struct.tm
store %struct.timezone* null, %struct.timezone** %2
%4 = call i32 @gettimeofday(%struct.timeval* %1, %struct.timezone* null)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%6 = call i32 @localtime_r(i32* %5, %struct.tm* %3)
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, 1000
%12 = call i32 @snprintf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @timestamp.lbuf, i64 0, i64 0), i32 99, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11)
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @timestamp.lbuf, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i32 }
%struct.timezone = type { i32 }
@timestamp.lbuf = internal global [100 x i8] zeroinitializer
@.str = [26 x i8] c"gettimeofday %02li.%09li\00"
define i8* @timestamp() {
%1 = alloca %struct.timeval
%2 = alloca %struct.tm
%3 = bitcast %struct.timeval* %1 to i8*
%4 = call i32 @gettimeofday(%struct.timeval* %1, %struct.timezone* null)
%5 = bitcast %struct.tm* %2 to i8*
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%7 = call i32 @localtime_r(i32* %6, %struct.tm* %2)
%8 = load i32, i32* %6
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%10 = load i32, i32* %9
%11 = mul nsw i32 %10, 1000
%12 = call i32 @snprintf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @timestamp.lbuf, i64 0, i64 0), i32 99, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11)
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @timestamp.lbuf, i64 0, i64 0)
}