#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_PROCESS_CPUTIME_ID;
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ CLOCK_THREAD_CPUTIME_ID;
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_getres, CLOCK_PROCESS_CPUTIME_ID,
                   "clock_getres on process CPU-time clock failed",
                   "Process CPU-time clock resolution");
  errs += TimeTest(clock_getres, CLOCK_THREAD_CPUTIME_ID,
                   "clock_getres on thread CPU-time clock failed",
                   "Thread CPU-time 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");
  errs += TimeTest(clock_gettime, CLOCK_PROCESS_CPUTIME_ID,
                   "clock_gettime on process CPU-time clock failed",
                   "Process CPU-time clock value");
  errs += TimeTest(clock_gettime, CLOCK_THREAD_CPUTIME_ID,
                   "clock_gettime on thread CPU-time clock failed",
                   "Thread CPU-time 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    0x2e7c(%rip),%rax
mov    (%rax),%edi
mov    0x2e7b(%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    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    0x2e59(%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    0x2e2f(%rip),%rax
mov    (%rax),%esi
lea    0xec8(%rip),%rdx
lea    0xeef(%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    0xee6(%rip),%rdx
lea    0xf0c(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2da4(%rip),%rax
mov    (%rax),%edi
mov    0x2db3(%rip),%rax
mov    (%rax),%esi
lea    0xf02(%rip),%rdx
lea    0xf22(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
mov    0x2d91(%rip),%rax
mov    (%rax),%esi
lea    0xf0c(%rip),%rdx
lea    0xf2d(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
lea    0xf18(%rip),%rdx
lea    0xf40(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
lea    0xf32(%rip),%rdx
lea    0xf59(%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   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <ShowCurrentDefinitions@plt>
mov    0x2e87(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2e85(%rip),%r13
mov    0x0(%r13),%esi
lea    0xeb2(%rip),%rdx
lea    0xed1(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%r14
mov    0x0(%rbp),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
lea    0xed0(%rip),%rdx
lea    0xef0(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%r15
add    %r14d,%r15d
mov    0x0(%rbp),%edi
mov    0x2e54(%rip),%r12
mov    (%r12),%esi
lea    0xeeb(%rip),%rdx
lea    0xf12(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rbx
add    %r15d,%ebx
mov    0x0(%rbp),%edi
mov    0x2e35(%rip),%r15
mov    (%r15),%esi
lea    0xf15(%rip),%rdx
lea    0xf3b(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%r14
add    %ebx,%r14d
mov    0x2dda(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x0(%r13),%esi
lea    0xf3c(%rip),%rdx
lea    0xf5c(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rbx
add    %r14d,%ebx
mov    0x0(%rbp),%edi
mov    0x2dd8(%rip),%rax
mov    (%rax),%esi
lea    0xf53(%rip),%rdx
lea    0xf74(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%r14
add    %ebx,%r14d
mov    0x0(%rbp),%edi
mov    (%r12),%esi
lea    0xf71(%rip),%rdx
lea    0xf99(%rip),%rcx
call   1040 <TimeTest@plt>
mov    %rax,%rbx
add    %r14d,%ebx
mov    0x0(%rbp),%edi
mov    (%r15),%esi
lea    0xf9e(%rip),%rdx
lea    0xfc5(%rip),%rcx
call   1040 <TimeTest@plt>
add    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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_PROCESS_CPUTIME_ID = global i32 0
@.str.4 = [46 x i8] c"clock_getres on process CPU-time clock failed\00"
@.str.5 = [34 x i8] c"Process CPU-time clock resolution\00"
@CLOCK_THREAD_CPUTIME_ID = global i32 0
@.str.6 = [45 x i8] c"clock_getres on thread CPU-time clock failed\00"
@.str.7 = [33 x i8] c"Thread CPU-time clock resolution\00"
@clock_gettime = global i32 0
@.str.8 = [39 x i8] c"clock_gettime on realtime clock failed\00"
@.str.9 = [21 x i8] c"Realtime clock value\00"
@.str.10 = [40 x i8] c"clock_gettime on monotonic clock failed\00"
@.str.11 = [22 x i8] c"Monotonic clock value\00"
@.str.12 = [47 x i8] c"clock_gettime on process CPU-time clock failed\00"
@.str.13 = [29 x i8] c"Process CPU-time clock value\00"
@.str.14 = [46 x i8] c"clock_gettime on thread CPU-time clock failed\00"
@.str.15 = [28 x i8] c"Thread CPU-time 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_getres
%19 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%20 = call i64 @TimeTest(i32 %18, i32 %19, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 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_getres
%26 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%27 = call i64 @TimeTest(i32 %25, i32 %26, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 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* @clock_gettime
%33 = load i32, i32* @CLOCK_REALTIME
%34 = call i64 @TimeTest(i32 %32, i32 %33, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = add nsw i64 %36, %34
%38 = trunc i64 %37 to i32
store i32 %38, i32* %2
%39 = load i32, i32* @clock_gettime
%40 = load i32, i32* @CLOCK_MONOTONIC
%41 = call i64 @TimeTest(i32 %39, i32 %40, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = add nsw i64 %43, %41
%45 = trunc i64 %44 to i32
store i32 %45, i32* %2
%46 = load i32, i32* @clock_gettime
%47 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%48 = call i64 @TimeTest(i32 %46, i32 %47, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%49 = load i32, i32* %2
%50 = sext i32 %49 to i64
%51 = add nsw i64 %50, %48
%52 = trunc i64 %51 to i32
store i32 %52, i32* %2
%53 = load i32, i32* @clock_gettime
%54 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%55 = call i64 @TimeTest(i32 %53, i32 %54, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0))
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = add nsw i64 %57, %55
%59 = trunc i64 %58 to i32
store i32 %59, i32* %2
%60 = load i32, i32* %2
ret i32 %60
}

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_PROCESS_CPUTIME_ID = global i32 0
@.str.4 = [46 x i8] c"clock_getres on process CPU-time clock failed\00"
@.str.5 = [34 x i8] c"Process CPU-time clock resolution\00"
@CLOCK_THREAD_CPUTIME_ID = global i32 0
@.str.6 = [45 x i8] c"clock_getres on thread CPU-time clock failed\00"
@.str.7 = [33 x i8] c"Thread CPU-time clock resolution\00"
@clock_gettime = global i32 0
@.str.8 = [39 x i8] c"clock_gettime on realtime clock failed\00"
@.str.9 = [21 x i8] c"Realtime clock value\00"
@.str.10 = [40 x i8] c"clock_gettime on monotonic clock failed\00"
@.str.11 = [22 x i8] c"Monotonic clock value\00"
@.str.12 = [47 x i8] c"clock_gettime on process CPU-time clock failed\00"
@.str.13 = [29 x i8] c"Process CPU-time clock value\00"
@.str.14 = [46 x i8] c"clock_gettime on thread CPU-time clock failed\00"
@.str.15 = [28 x i8] c"Thread CPU-time 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_getres
%10 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%11 = tail call i64 @TimeTest(i32 %9, i32 %10, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%12 = add i64 %8, %11
%13 = load i32, i32* @clock_getres
%14 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%15 = tail call i64 @TimeTest(i32 %13, i32 %14, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%16 = add i64 %12, %15
%17 = load i32, i32* @clock_gettime
%18 = load i32, i32* @CLOCK_REALTIME
%19 = tail call i64 @TimeTest(i32 %17, i32 %18, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%20 = add i64 %16, %19
%21 = load i32, i32* @clock_gettime
%22 = load i32, i32* @CLOCK_MONOTONIC
%23 = tail call i64 @TimeTest(i32 %21, i32 %22, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
%24 = add i64 %20, %23
%25 = load i32, i32* @clock_gettime
%26 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%27 = tail call i64 @TimeTest(i32 %25, i32 %26, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%28 = add i64 %24, %27
%29 = load i32, i32* @clock_gettime
%30 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%31 = tail call i64 @TimeTest(i32 %29, i32 %30, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.15, i64 0, i64 0))
%32 = add i64 %28, %31
%33 = trunc i64 %32 to i32
ret i32 %33
}