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

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main(int argc, char **argv) {
  time_t now = time(0);
  printf("time: %s", ctime(&now));
  struct timeval tv = {0, 0};
  gettimeofday(&tv, 0);
  printf("gettimeofday: %s", ctime(&tv.tv_sec));
  struct timespec ts = {0, 0};
  clock_gettime(CLOCK_REALTIME, &ts);
  printf("clock_gettime: %s", ctime(&ts.tv_sec));
  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)
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
lea    -0x20(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe3a(%rip),%rdi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1030 <clock_gettime@plt>
lea    -0x30(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe11(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1040 <ctime@plt>
lea    0xea9(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
movl   $0x0,0x28(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    %rbx,%rdi
call   1040 <ctime@plt>
lea    0xe58(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
movl   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <clock_gettime@plt>
mov    %rbx,%rdi
call   1040 <ctime@plt>
lea    0xe2b(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32, i32 }
%struct.timespec = type { i32, i32, i32 }
@.str = [9 x i8] c"time: %s\00"
@.str.1 = [17 x i8] c"gettimeofday: %s\00"
@CLOCK_REALTIME = global i32 0
@.str.2 = [18 x i8] c"clock_gettime: %s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.timeval
%8 = alloca %struct.timespec
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @time(i32 0)
store i32 %9, i32* %6
%10 = call i8* @ctime(i32* %6)
%11 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = bitcast %struct.timeval* %7 to i8*
%13 = call i32 @gettimeofday(%struct.timeval* %7, i32 0)
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%15 = call i8* @ctime(i32* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = bitcast %struct.timespec* %8 to i8*
%18 = load i32, i32* @CLOCK_REALTIME
%19 = call i32 @clock_gettime(i32 %18, %struct.timespec* %8)
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 0
%21 = call i8* @ctime(i32* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %21)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32, i32 }
%struct.timespec = type { i32, i32, i32 }
@.str = [9 x i8] c"time: %s\00"
@.str.1 = [17 x i8] c"gettimeofday: %s\00"
@CLOCK_REALTIME = global i32 0
@.str.2 = [18 x i8] c"clock_gettime: %s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca %struct.timeval
%5 = alloca %struct.timespec
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @time(i32 0)
store i32 %7, i32* %3
%8 = call i8* @ctime(i32* %3)
%9 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = bitcast %struct.timeval* %4 to i8*
%11 = call i32 @gettimeofday(%struct.timeval* %4, i32 0)
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%13 = call i8* @ctime(i32* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = bitcast %struct.timespec* %5 to i8*
%16 = load i32, i32* @CLOCK_REALTIME
%17 = call i32 @clock_gettime(i32 %16, %struct.timespec* %5)
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%19 = call i8* @ctime(i32* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %19)
ret i32 0
}