#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 */

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ ShowCurrentDefinitions();
scalar_t__ TimeTest(int /*<<< orphan*/, int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ clock_getres;
int /*<<< orphan*/ clock_gettime;
int main(void) {
  int errs = 0;
  ShowCurrentDefinitions();
  errs += TimeTest(clock_getres, CLOCK_REALTIME,
                   "clock_getres on realtime clock failed",
                   "Realtime clock resolution");
  errs += TimeTest(clock_getres, CLOCK_MONOTONIC,
                   "clock_getres on monotonic clock failed",
                   "Monotonic clock resolution");
  errs += TimeTest(clock_gettime, CLOCK_REALTIME,
                   "clock_gettime on realtime clock failed",
                   "Realtime clock value");
  errs += TimeTest(clock_gettime, CLOCK_MONOTONIC,
                   "clock_gettime on monotonic clock failed",
                   "Monotonic clock value");
  return errs;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <ShowCurrentDefinitions@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
lea    0xeaa(%rip),%rdx
lea    0xec9(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    0xeb8(%rip),%rdx
lea    0xed8(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    0x2e27(%rip),%rax
mov    (%rax),%esi
lea    0xec8(%rip),%rdx
lea    0xee8(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
lea    0xed2(%rip),%rdx
lea    0xef3(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
xor    %eax,%eax
call   1030 <ShowCurrentDefinitions@plt>
mov    0x2e99(%rip),%rbx
mov    (%rbx),%edi
mov    0x2e98(%rip),%r13
mov    0x0(%r13),%esi
lea    0xeb5(%rip),%rdx
lea    0xed4(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%r14
mov    (%rbx),%edi
mov    0x2e85(%rip),%r12
mov    (%r12),%esi
lea    0xed2(%rip),%rdx
lea    0xef2(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%r15
add    %r14d,%r15d
mov    0x2e39(%rip),%r14
mov    (%r14),%edi
mov    0x0(%r13),%esi
lea    0xeed(%rip),%rdx
lea    0xf0d(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rbx
add    %r15d,%ebx
mov    (%r14),%edi
mov    (%r12),%esi
lea    0xf09(%rip),%rdx
lea    0xf2a(%rip),%rcx
call   1040 <TimeTest@plt>
add    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@clock_getres = global i32 0
@CLOCK_REALTIME = global i32 0
@.str = [38 x i8] c"clock_getres on realtime clock failed\00"
@.str.1 = [26 x i8] c"Realtime clock resolution\00"
@CLOCK_MONOTONIC = global i32 0
@.str.2 = [39 x i8] c"clock_getres on monotonic clock failed\00"
@.str.3 = [27 x i8] c"Monotonic clock resolution\00"
@clock_gettime = global i32 0
@.str.4 = [39 x i8] c"clock_gettime on realtime clock failed\00"
@.str.5 = [21 x i8] c"Realtime clock value\00"
@.str.6 = [40 x i8] c"clock_gettime on monotonic clock failed\00"
@.str.7 = [22 x i8] c"Monotonic clock value\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 (...) @ShowCurrentDefinitions()
%4 = load i32, i32* @clock_getres
%5 = load i32, i32* @CLOCK_REALTIME
%6 = call i64 @TimeTest(i32 %4, i32 %5, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = add nsw i64 %8, %6
%10 = trunc i64 %9 to i32
store i32 %10, i32* %2
%11 = load i32, i32* @clock_getres
%12 = load i32, i32* @CLOCK_MONOTONIC
%13 = call i64 @TimeTest(i32 %11, i32 %12, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = add nsw i64 %15, %13
%17 = trunc i64 %16 to i32
store i32 %17, i32* %2
%18 = load i32, i32* @clock_gettime
%19 = load i32, i32* @CLOCK_REALTIME
%20 = call i64 @TimeTest(i32 %18, i32 %19, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = add nsw i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %2
%25 = load i32, i32* @clock_gettime
%26 = load i32, i32* @CLOCK_MONOTONIC
%27 = call i64 @TimeTest(i32 %25, i32 %26, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = add nsw i64 %29, %27
%31 = trunc i64 %30 to i32
store i32 %31, i32* %2
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@clock_getres = global i32 0
@CLOCK_REALTIME = global i32 0
@.str = [38 x i8] c"clock_getres on realtime clock failed\00"
@.str.1 = [26 x i8] c"Realtime clock resolution\00"
@CLOCK_MONOTONIC = global i32 0
@.str.2 = [39 x i8] c"clock_getres on monotonic clock failed\00"
@.str.3 = [27 x i8] c"Monotonic clock resolution\00"
@clock_gettime = global i32 0
@.str.4 = [39 x i8] c"clock_gettime on realtime clock failed\00"
@.str.5 = [21 x i8] c"Realtime clock value\00"
@.str.6 = [40 x i8] c"clock_gettime on monotonic clock failed\00"
@.str.7 = [22 x i8] c"Monotonic clock value\00"
define i32 @main() {
%1 = tail call i32 (...) @ShowCurrentDefinitions()
%2 = load i32, i32* @clock_getres
%3 = load i32, i32* @CLOCK_REALTIME
%4 = tail call i64 @TimeTest(i32 %2, i32 %3, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @clock_getres
%6 = load i32, i32* @CLOCK_MONOTONIC
%7 = tail call i64 @TimeTest(i32 %5, i32 %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%8 = add i64 %7, %4
%9 = load i32, i32* @clock_gettime
%10 = load i32, i32* @CLOCK_REALTIME
%11 = tail call i64 @TimeTest(i32 %9, i32 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%12 = add i64 %8, %11
%13 = load i32, i32* @clock_gettime
%14 = load i32, i32* @CLOCK_MONOTONIC
%15 = tail call i64 @TimeTest(i32 %13, i32 %14, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%16 = add i64 %12, %15
%17 = trunc i64 %16 to i32
ret i32 %17
}