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

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  struct timespec real_tp, real_tp2;
  struct timeval tv, tv2;
  clock_gettime(CLOCK_REALTIME, &real_tp);
  clock_gettime(CLOCK_REALTIME, &real_tp2);
  gettimeofday(&tv, NULL);
  gettimeofday(&tv2, NULL);
  printf("CLOCK_REALTIME = {%ld, %ld}\n", real_tp.tv_sec, real_tp.tv_nsec);
  printf("CLOCK_REALTIME = {%ld, %ld}\n", real_tp2.tv_sec, real_tp2.tv_nsec);
  printf("gettimdofday = {%ld, %ld}\n", tv.tv_sec, tv.tv_usec);
  printf("gettimdofday = {%ld, %ld}\n", tv2.tv_sec, tv2.tv_usec);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
call   1030 <clock_gettime@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0x2ea4(%rip),%rbx
mov    (%rbx),%edi
lea    0x18(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    (%rbx),%edi
lea    0x10(%rsp),%rsi
call   1030 <clock_gettime@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    0x18(%rsp),%edx
mov    0x1c(%rsp),%esi
lea    0xe87(%rip),%rbx
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x10(%rsp),%edx
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%esi
lea    0xe7d(%rip),%rbx
mov    %rbx,%rdi
call   1040 <printf@plt>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
%struct.timeval = type { i32, i32 }
@CLOCK_REALTIME = global i32 0
@.str = [29 x i8] c"CLOCK_REALTIME = {%ld, %ld}\0A\00"
@.str.1 = [27 x i8] c"gettimdofday = {%ld, %ld}\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i32, i32* @CLOCK_REALTIME
%10 = call i32 @clock_gettime(i32 %9, %struct.timespec* %5)
%11 = load i32, i32* @CLOCK_REALTIME
%12 = call i32 @clock_gettime(i32 %11, %struct.timespec* %6)
%13 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%14 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %18)
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%23 = load i32, i32* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %23)
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %28)
%30 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%31 = load i32, i32* %30
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%33 = load i32, i32* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %33)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
%struct.timeval = type { i32, i32 }
@CLOCK_REALTIME = global i32 0
@.str = [29 x i8] c"CLOCK_REALTIME = {%ld, %ld}\0A\00"
@.str.1 = [27 x i8] c"gettimdofday = {%ld, %ld}\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca %struct.timeval
%6 = alloca %struct.timeval
%7 = bitcast %struct.timespec* %3 to i8*
%8 = bitcast %struct.timespec* %4 to i8*
%9 = bitcast %struct.timeval* %5 to i8*
%10 = bitcast %struct.timeval* %6 to i8*
%11 = load i32, i32* @CLOCK_REALTIME
%12 = call i32 @clock_gettime(i32 %11, %struct.timespec* %3)
%13 = load i32, i32* @CLOCK_REALTIME
%14 = call i32 @clock_gettime(i32 %13, %struct.timespec* %4)
%15 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%16 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %20)
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%25 = load i32, i32* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %25)
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 1
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %5, i64 0, i32 0
%30 = load i32, i32* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %30)
%32 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 0
%35 = load i32, i32* %34
%36 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %35)
ret i32 0
}