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

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
void print_timestamp(struct timeval *tv) {
  time_t t2 = (time_t)tv->tv_sec;
  uint32_t milliseconds = (uint32_t)(tv->tv_usec / 1);
  struct tm *tm_info;
  tm_info = localtime(&t2);
  char b1[200];
  char b2[100];
  char b3[100];
  sprintf(b2, "%u", milliseconds);
  strftime(b1, 50, "%Y-%m-%d %H:%M:%S.", tm_info);
  strftime(b3, 10, " (%z)", tm_info);
  strcat(b1, b2);
  strcat(b1, b3);
  printf("%s ", b1);
}


x86 assembly (clang, -O0):
<print_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    $0x1,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
lea    -0x150(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe68(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x32,%esi
lea    0xe4f(%rip),%rdx
call   1050 <strftime@plt>
lea    -0x1c0(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0xa,%esi
lea    0xe46(%rip),%rdx
call   1050 <strftime@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x150(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe13(%rip),%rdi
call   1040 <printf@plt>
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_timestamp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1b8,%rsp
mov    0x4(%rdi),%eax
mov    %eax,0xc(%rsp)
mov    (%rdi),%ebp
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
lea    0xe86(%rip),%rsi
lea    0x80(%rsp),%r15
mov    %r15,%rdi
mov    %ebp,%edx
call   1070 <sprintf@plt>
lea    0xe70(%rip),%rdx
lea    0xf0(%rsp),%r14
mov    %r14,%rdi
mov    $0x32,%esi
mov    %rbx,%rcx
call   1050 <strftime@plt>
lea    0xe64(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xa,%esi
mov    %rbx,%rcx
call   1050 <strftime@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <strcat@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1060 <strcat@plt>
lea    0xe38(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
add    $0x1b8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i32 }
@.str = [3 x i8] c"%u\00"
@.str.1 = [19 x i8] c"%Y-%m-%d %H:%M:%S.\00"
@.str.2 = [6 x i8] c" (%z)\00"
@.str.3 = [4 x i8] c"%s \00"
define void @print_timestamp(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.tm*
%6 = alloca [200 x i8]
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
store %struct.timeval* %0, %struct.timeval** %2
%9 = load %struct.timeval*, %struct.timeval** %2
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %9, i32 0, i32 1
%11 = load i32, i32* %10
store i32 %11, i32* %3
%12 = load %struct.timeval*, %struct.timeval** %2
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = sdiv i32 %14, 1
store i32 %15, i32* %4
%16 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %16, %struct.tm** %5
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%18 = load i32, i32* %4
%19 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%21 = load %struct.tm*, %struct.tm** %5
%22 = call i32 @strftime(i8* %20, i32 50, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%24 = load %struct.tm*, %struct.tm** %5
%25 = call i32 @strftime(i8* %23, i32 10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %24)
%26 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%28 = call i32 @strcat(i8* %26, i8* %27)
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%31 = call i32 @strcat(i8* %29, i8* %30)
%32 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %32)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i32 }
@.str = [3 x i8] c"%u\00"
@.str.1 = [19 x i8] c"%Y-%m-%d %H:%M:%S.\00"
@.str.2 = [6 x i8] c" (%z)\00"
@.str.3 = [4 x i8] c"%s \00"
define void @print_timestamp(%struct.timeval* nocapture %0) {
%2 = alloca i32
%3 = alloca [200 x i8]
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 1
%8 = load i32, i32* %7
store i32 %8, i32* %2
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%10 = load i32, i32* %9
%11 = call %struct.tm* @localtime(i32* %2)
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%15 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
%16 = call i32 @strftime(i8* %12, i32 50, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %11)
%17 = call i32 @strftime(i8* %14, i32 10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %11)
%18 = call i32 @strcat(i8* %12, i8* %13)
%19 = call i32 @strcat(i8* %12, i8* %14)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %12)
ret void
}