#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 timezone {
  int tz_minuteswest;
  int tz_dsttime;
};
struct timeval {
  int tv_sec;
  int tv_usec;
};
struct timespec {
  int tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
int /*<<< orphan*/ printf(char *, int);
int main(int argc, const char *argv[]) {
  struct timeval tv;
  struct timezone tz;
  struct timespec ts;
  gettimeofday(&tv, &tz);
  printf("tv_sec:%lu\n", tv.tv_sec);
  printf("tv_usec:%lu\n", tv.tv_usec);
  printf("tz_minuteswest:%u\n", tz.tz_minuteswest);
  printf("tz_dsttime:%u\n", tz.tz_dsttime);
  clock_gettime(CLOCK_MONOTONIC, &ts);
  printf("tv_sec:%lu\n", ts.tv_sec);
  printf("tv_usec:%lu\n", ts.tv_nsec / 1000);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <gettimeofday@plt>
mov    -0x18(%rbp),%esi
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%esi
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <gettimeofday@plt>
mov    0x10(%rsp),%esi
lea    0xeaf(%rip),%rbx
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xea8(%rip),%r14
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
mov    (%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
movslq 0x4(%rsp),%rax
imul   $0x10624dd3,%rax,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
sar    $0x26,%rsi
add    %eax,%esi
mov    %r14,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32, i32 }
%struct.timespec = type { i32, i32 }
@.str = [12 x i8] c"tv_sec:%lu\0A\00"
@.str.1 = [13 x i8] c"tv_usec:%lu\0A\00"
@.str.2 = [19 x i8] c"tz_minuteswest:%u\0A\00"
@.str.3 = [15 x i8] c"tz_dsttime:%u\0A\00"
@CLOCK_MONOTONIC = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timezone
%8 = alloca %struct.timespec
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @gettimeofday(%struct.timeval* %6, %struct.timezone* %7)
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds %struct.timezone, %struct.timezone* %7, i32 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds %struct.timezone, %struct.timezone* %7, i32 0, i32 1
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @CLOCK_MONOTONIC
%23 = call i32 @clock_gettime(i32 %22, %struct.timespec* %8)
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 1
%28 = load i32, i32* %27
%29 = sdiv i32 %28, 1000
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %29)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32, i32 }
%struct.timespec = type { i32, i32 }
@.str = [12 x i8] c"tv_sec:%lu\0A\00"
@.str.1 = [13 x i8] c"tv_usec:%lu\0A\00"
@.str.2 = [19 x i8] c"tz_minuteswest:%u\0A\00"
@.str.3 = [15 x i8] c"tz_dsttime:%u\0A\00"
@CLOCK_MONOTONIC = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timezone
%5 = alloca %struct.timespec
%6 = bitcast %struct.timeval* %3 to i8*
%7 = bitcast %struct.timezone* %4 to i8*
%8 = bitcast %struct.timespec* %5 to i8*
%9 = call i32 @gettimeofday(%struct.timeval* %3, %struct.timezone* %4)
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 1
%14 = load i32, i32* %13
%15 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds %struct.timezone, %struct.timezone* %4, i64 0, i32 0
%17 = load i32, i32* %16
%18 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds %struct.timezone, %struct.timezone* %4, i64 0, i32 1
%20 = load i32, i32* %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* @CLOCK_MONOTONIC
%23 = call i32 @clock_gettime(i32 %22, %struct.timespec* %5)
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%28 = load i32, i32* %27
%29 = sdiv i32 %28, 1000
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %29)
ret i32 0
}