#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 tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};
struct timeval {
  int tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int, int, int,
                            int);
char *print_time(void) {
  struct tm *timeinfo;
  struct timeval tv;
  char *buf = NULL;
  gettimeofday(&tv, NULL);
  timeinfo = localtime(&tv.tv_sec);
  buf = (char *)calloc(23 + 1, sizeof(char));
  snprintf(buf, 23 + 1, "%02d.%02d.%02d %02d:%02d:%02d:%03ld",
           timeinfo->tm_year % 100, timeinfo->tm_mon + 1, timeinfo->tm_mday,
           timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec,
           tv.tv_usec / 1000);
  return (buf);
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x38,%rsp
movq   $0x0,-0x20(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    $0x18,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%r8d
add    $0x1,%r8d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ebx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r11d
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%r10d
mov    -0x18(%rbp),%eax
mov    $0x3e8,%esi
cltd
idiv   %esi
mov    $0x18,%esi
lea    0xe28(%rip),%rdx
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1040 <snprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %r14
push   %rbx
push   %rax
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    $0x18,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,%r14
movslq (%rbx),%rcx
imul   $0x51eb851f,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x25,%rax
add    %edx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ecx
mov    0x4(%rbx),%r8d
mov    0x8(%rbx),%r9d
add    $0x1,%r8d
mov    0xc(%rbx),%r10d
mov    0x10(%rbx),%r11d
mov    0x14(%rbx),%ebx
movslq (%rsp),%rdx
imul   $0x10624dd3,%rdx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
lea    0xe41(%rip),%rdx
mov    %r14,%rdi
mov    $0x18,%esi
push   %rax
push   %rbx
push   %r11
push   %r10
call   1040 <snprintf@plt>
add    $0x20,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
%struct.timeval = type { i32, i32 }
@.str = [36 x i8] c"%02d.%02d.%02d %02d:%02d:%02d:%03ld\00"
define i8* @print_time() {
%1 = alloca %struct.tm*
%2 = alloca %struct.timeval
%3 = alloca i8*
store i8* null, i8** %3
%4 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%6 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %6, %struct.tm** %1
%7 = call i64 @calloc(i32 24, i32 1)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %3
%9 = load i8*, i8** %3
%10 = load %struct.tm*, %struct.tm** %1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = srem i32 %12, 100
%14 = load %struct.tm*, %struct.tm** %1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
%18 = load %struct.tm*, %struct.tm** %1
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 2
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %1
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 3
%23 = load i32, i32* %22
%24 = load %struct.tm*, %struct.tm** %1
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 4
%26 = load i32, i32* %25
%27 = load %struct.tm*, %struct.tm** %1
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 5
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%31 = load i32, i32* %30
%32 = sdiv i32 %31, 1000
%33 = call i32 @snprintf(i8* %9, i32 24, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %17, i32 %20, i32 %23, i32 %26, i32 %29, i32 %32)
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [36 x i8] c"%02d.%02d.%02d %02d:%02d:%02d:%03ld\00"
define i8* @print_time() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%5 = call %struct.tm* @localtime(i32* %4)
%6 = call i64 @calloc(i32 24, i32 1)
%7 = inttoptr i64 %6 to i8*
%8 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%9 = load i32, i32* %8
%10 = srem i32 %9, 100
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
%14 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%23 = load i32, i32* %22
%24 = sdiv i32 %23, 1000
%25 = call i32 @snprintf(i8* %7, i32 24, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %13, i32 %15, i32 %17, i32 %19, i32 %21, i32 %24)
ret i8* %7
}