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

/* Variables and functions */
int /*<<< orphan*/ localtime(char **);
int /*<<< orphan*/ printf(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
void timeval_print(struct timeval *tv) {
  char buffer[30];
  time_t curtime;
  printf("%ld.%06ld", tv->tv_sec, tv->tv_usec);
  curtime = tv->tv_sec;
  strftime(buffer, 30, "%m-%d-%Y  %T", localtime(&curtime));
  printf(" = %s.%06ld\n", buffer, tv->tv_usec);
}


x86 assembly (clang, -O0):
<timeval_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rsi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x38(%rbp),%rdi
call   1030 <localtime@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%ecx
mov    $0x1e,%esi
lea    0xe86(%rip),%rdx
call   1050 <strftime@plt>
lea    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timeval_print>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
mov    (%rdi),%rsi
mov    0x8(%rdi),%edx
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
mov    (%rbx),%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xea5(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x1e,%esi
mov    %eax,%ecx
call   1050 <strftime@plt>
mov    0x8(%rbx),%edx
lea    0xe94(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i8*, i32 }
@.str = [10 x i8] c"%ld.%06ld\00"
@.str.1 = [13 x i8] c"%m-%d-%Y %T\00"
@.str.2 = [13 x i8] c" = %s.%06ld\0A\00"
define void @timeval_print(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
%3 = alloca [30 x i8]
%4 = alloca i8*
store %struct.timeval* %0, %struct.timeval** %2
%5 = load %struct.timeval*, %struct.timeval** %2
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i32 0, i32 0
%7 = load i8*, i8** %6
%8 = load %struct.timeval*, %struct.timeval** %2
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%10 = load i32, i32* %9
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %10)
%12 = load %struct.timeval*, %struct.timeval** %2
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%14 = load i8*, i8** %13
store i8* %14, i8** %4
%15 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%16 = call i32 @localtime(i8** %4)
%17 = call i32 @strftime(i8* %15, i32 30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%19 = load %struct.timeval*, %struct.timeval** %2
%20 = getelementptr inbounds %struct.timeval, %struct.timeval* %19, i32 0, i32 1
%21 = load i32, i32* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %18, i32 %21)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i8*, i32 }
@.str = [10 x i8] c"%ld.%06ld\00"
@.str.1 = [13 x i8] c"%m-%d-%Y %T\00"
@.str.2 = [13 x i8] c" = %s.%06ld\0A\00"
define void @timeval_print(%struct.timeval* nocapture %0) {
%2 = alloca [30 x i8]
%3 = alloca i8*
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = bitcast i8** %3 to i8*
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%7 = load i8*, i8** %6
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%9 = load i32, i32* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %9)
%11 = load i8*, i8** %6
store i8* %11, i8** %3
%12 = call i32 @localtime(i8** %3)
%13 = call i32 @strftime(i8* %4, i32 30, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %8
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %4, i32 %14)
ret void
}