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

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
void print_time() {
  struct timeval tv;
  struct tm *ptm;
  char time_string[40];
  gettimeofday(&tv, NULL);
  ptm = localtime(&tv.tv_sec);
  strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", ptm);
  printf("%s.%06ld\n", time_string, tv.tv_usec);
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x28,%esi
lea    0xe86(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rbx
sub    $0x40,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe9e(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x28,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
mov    0x8(%rsp),%edx
lea    0xe90(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [10 x i8] c"%s.%06ld\0A\00"
define void @print_time() {
%1 = alloca %struct.timeval
%2 = alloca %struct.tm*
%3 = alloca [40 x i8]
%4 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%5 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%6 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %6, %struct.tm** %2
%7 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%8 = load %struct.tm*, %struct.tm** %2
%9 = call i32 @strftime(i8* %7, i32 40, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%10 = getelementptr inbounds [40 x i8], [40 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 %12)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d %H:%M:%S\00"
@.str.1 = [10 x i8] c"%s.%06ld\0A\00"
define void @print_time() {
%1 = alloca %struct.timeval
%2 = alloca [40 x i8]
%3 = bitcast %struct.timeval* %1 to i8*
%4 = getelementptr inbounds [40 x i8], [40 x i8]* %2, i64 0, i64 0
%5 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%7 = call %struct.tm* @localtime(i32* %6)
%8 = call i32 @strftime(i8* %4, i32 40, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %7)
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 %10)
ret void
}