#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 dummy;
};
struct timespec {
  int tv_nsec;
  scalar_t__ tv_sec;
};

/* 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*/ SYS_clock_getres;
int /*<<< orphan*/ SYS_clock_gettime;
int /*<<< orphan*/ SYS_clock_nanosleep;
int /*<<< orphan*/ SYS_clock_settime;
int /*<<< orphan*/ SYS_gettimeofday;
int TIMER_ABSTIME;
int /*<<< orphan*/ settimeofday(struct timeval *, int /*<<< orphan*/ *);
int syscall(int /*<<< orphan*/, int /*<<< orphan*/, ...);
int main() {
  int t;
  struct timeval tv;
  struct timespec ts;
  time_t tt;
  t = syscall(SYS_gettimeofday, &tv, NULL);
  settimeofday(&tv, NULL);
  syscall(SYS_clock_gettime, CLOCK_REALTIME, &ts);
  syscall(SYS_clock_settime, CLOCK_REALTIME, &ts);
  syscall(SYS_clock_getres, CLOCK_REALTIME, &ts);
  syscall(SYS_clock_gettime, CLOCK_MONOTONIC, &ts);
  syscall(SYS_clock_settime, CLOCK_MONOTONIC, &ts);
  syscall(SYS_clock_getres, CLOCK_MONOTONIC, &ts);
  syscall(SYS_clock_gettime, CLOCK_PROCESS_CPUTIME_ID, &ts);
  syscall(SYS_clock_settime, CLOCK_PROCESS_CPUTIME_ID, &ts);
  syscall(SYS_clock_getres, CLOCK_PROCESS_CPUTIME_ID, &ts);
  syscall(SYS_clock_gettime, CLOCK_THREAD_CPUTIME_ID, &ts);
  syscall(SYS_clock_settime, CLOCK_THREAD_CPUTIME_ID, &ts);
  syscall(SYS_clock_getres, CLOCK_THREAD_CPUTIME_ID, &ts);
  syscall(SYS_clock_gettime, CLOCK_REALTIME, &ts);
  ts.tv_sec++;
  syscall(SYS_clock_nanosleep, CLOCK_REALTIME, TIMER_ABSTIME, &ts);
  ts.tv_sec = 0;
  ts.tv_nsec = 10000;
  syscall(SYS_clock_nanosleep, CLOCK_REALTIME, 0x0, &ts);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rax
mov    %eax,%esi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    %eax,-0x8(%rbp)
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <settimeofday@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    0x2e00(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    0x2de3(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
mov    0x2db9(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%edi
mov    0x2d6a(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
mov    0x2d4d(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
mov    0x2d30(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    0x2d34(%rip),%rax
mov    (%rax),%edi
mov    0x2cdb(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1030 <syscall@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
mov    0x2cb2(%rip),%rax
mov    (%rax),%esi
mov    0x2cd1(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x0,%al
call   1030 <syscall@plt>
movq   $0x0,-0x18(%rbp)
movl   $0x2710,-0x20(%rbp)
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
mov    0x2c7d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
lea    -0x20(%rbp),%rcx
mov    $0x0,%al
call   1030 <syscall@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0x10(%rsp),%rbx
mov    %ebx,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <settimeofday@plt>
mov    0x2e98(%rip),%r15
mov    (%r15),%edi
mov    0x2e3e(%rip),%r14
mov    (%r14),%esi
mov    %rsp,%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2e3f(%rip),%r12
mov    (%r12),%edi
mov    (%r14),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x2e57(%rip),%r13
mov    0x0(%r13),%edi
mov    (%r14),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    (%r15),%edi
mov    0x2e14(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    (%r12),%edi
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x0(%r13),%edi
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    (%r15),%edi
mov    0x2deb(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    (%r12),%edi
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x0(%r13),%edi
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    (%r15),%edi
mov    0x2dba(%rip),%rbp
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    (%r12),%edi
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    0x0(%r13),%edi
mov    0x0(%rbp),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
mov    (%r15),%edi
mov    (%r14),%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <syscall@plt>
addq   $0x1,0x8(%rsp)
mov    0x2d3e(%rip),%rbp
mov    0x0(%rbp),%edi
mov    (%r14),%esi
mov    0x2d51(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <syscall@plt>
movq   $0x0,0x8(%rsp)
movl   $0x2710,(%rsp)
mov    0x0(%rbp),%edi
mov    (%r14),%esi
xor    %edx,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1030 <syscall@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
%struct.timespec = type { i32, i64 }
@SYS_gettimeofday = global i32 0
@SYS_clock_gettime = global i32 0
@CLOCK_REALTIME = global i32 0
@SYS_clock_settime = global i32 0
@SYS_clock_getres = global i32 0
@CLOCK_MONOTONIC = global i32 0
@CLOCK_PROCESS_CPUTIME_ID = global i32 0
@CLOCK_THREAD_CPUTIME_ID = global i32 0
@SYS_clock_nanosleep = global i32 0
@TIMER_ABSTIME = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.timeval
%4 = alloca %struct.timespec
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @SYS_gettimeofday
%7 = ptrtoint %struct.timeval* %3 to i32
%8 = call i32 (i32, i32, ...) @syscall(i32 %6, i32 %7, i8* null)
store i32 %8, i32* %2
%9 = call i32 @settimeofday(%struct.timeval* %3, i32* null)
%10 = load i32, i32* @SYS_clock_gettime
%11 = load i32, i32* @CLOCK_REALTIME
%12 = call i32 (i32, i32, ...) @syscall(i32 %10, i32 %11, %struct.timespec* %4)
%13 = load i32, i32* @SYS_clock_settime
%14 = load i32, i32* @CLOCK_REALTIME
%15 = call i32 (i32, i32, ...) @syscall(i32 %13, i32 %14, %struct.timespec* %4)
%16 = load i32, i32* @SYS_clock_getres
%17 = load i32, i32* @CLOCK_REALTIME
%18 = call i32 (i32, i32, ...) @syscall(i32 %16, i32 %17, %struct.timespec* %4)
%19 = load i32, i32* @SYS_clock_gettime
%20 = load i32, i32* @CLOCK_MONOTONIC
%21 = call i32 (i32, i32, ...) @syscall(i32 %19, i32 %20, %struct.timespec* %4)
%22 = load i32, i32* @SYS_clock_settime
%23 = load i32, i32* @CLOCK_MONOTONIC
%24 = call i32 (i32, i32, ...) @syscall(i32 %22, i32 %23, %struct.timespec* %4)
%25 = load i32, i32* @SYS_clock_getres
%26 = load i32, i32* @CLOCK_MONOTONIC
%27 = call i32 (i32, i32, ...) @syscall(i32 %25, i32 %26, %struct.timespec* %4)
%28 = load i32, i32* @SYS_clock_gettime
%29 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%30 = call i32 (i32, i32, ...) @syscall(i32 %28, i32 %29, %struct.timespec* %4)
%31 = load i32, i32* @SYS_clock_settime
%32 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%33 = call i32 (i32, i32, ...) @syscall(i32 %31, i32 %32, %struct.timespec* %4)
%34 = load i32, i32* @SYS_clock_getres
%35 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%36 = call i32 (i32, i32, ...) @syscall(i32 %34, i32 %35, %struct.timespec* %4)
%37 = load i32, i32* @SYS_clock_gettime
%38 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%39 = call i32 (i32, i32, ...) @syscall(i32 %37, i32 %38, %struct.timespec* %4)
%40 = load i32, i32* @SYS_clock_settime
%41 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%42 = call i32 (i32, i32, ...) @syscall(i32 %40, i32 %41, %struct.timespec* %4)
%43 = load i32, i32* @SYS_clock_getres
%44 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%45 = call i32 (i32, i32, ...) @syscall(i32 %43, i32 %44, %struct.timespec* %4)
%46 = load i32, i32* @SYS_clock_gettime
%47 = load i32, i32* @CLOCK_REALTIME
%48 = call i32 (i32, i32, ...) @syscall(i32 %46, i32 %47, %struct.timespec* %4)
%49 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%50 = load i64, i64* %49
%51 = add nsw i64 %50, 1
store i64 %51, i64* %49
%52 = load i32, i32* @SYS_clock_nanosleep
%53 = load i32, i32* @CLOCK_REALTIME
%54 = load i32, i32* @TIMER_ABSTIME
%55 = call i32 (i32, i32, ...) @syscall(i32 %52, i32 %53, i32 %54, %struct.timespec* %4)
%56 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
store i64 0, i64* %56
%57 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
store i32 10000, i32* %57
%58 = load i32, i32* @SYS_clock_nanosleep
%59 = load i32, i32* @CLOCK_REALTIME
%60 = call i32 (i32, i32, ...) @syscall(i32 %58, i32 %59, i32 0, %struct.timespec* %4)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
%struct.timespec = type { i32, i64 }
@SYS_gettimeofday = global i32 0
@SYS_clock_gettime = global i32 0
@CLOCK_REALTIME = global i32 0
@SYS_clock_settime = global i32 0
@SYS_clock_getres = global i32 0
@CLOCK_MONOTONIC = global i32 0
@CLOCK_PROCESS_CPUTIME_ID = global i32 0
@CLOCK_THREAD_CPUTIME_ID = global i32 0
@SYS_clock_nanosleep = global i32 0
@TIMER_ABSTIME = global i32 0
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timespec
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timespec* %2 to i8*
%5 = load i32, i32* @SYS_gettimeofday
%6 = ptrtoint %struct.timeval* %1 to i64
%7 = trunc i64 %6 to i32
%8 = call i32 (i32, i32, ...) @syscall(i32 %5, i32 %7, i8* null)
%9 = call i32 @settimeofday(%struct.timeval* %1, i32* null)
%10 = load i32, i32* @SYS_clock_gettime
%11 = load i32, i32* @CLOCK_REALTIME
%12 = call i32 (i32, i32, ...) @syscall(i32 %10, i32 %11, %struct.timespec* %2)
%13 = load i32, i32* @SYS_clock_settime
%14 = load i32, i32* @CLOCK_REALTIME
%15 = call i32 (i32, i32, ...) @syscall(i32 %13, i32 %14, %struct.timespec* %2)
%16 = load i32, i32* @SYS_clock_getres
%17 = load i32, i32* @CLOCK_REALTIME
%18 = call i32 (i32, i32, ...) @syscall(i32 %16, i32 %17, %struct.timespec* %2)
%19 = load i32, i32* @SYS_clock_gettime
%20 = load i32, i32* @CLOCK_MONOTONIC
%21 = call i32 (i32, i32, ...) @syscall(i32 %19, i32 %20, %struct.timespec* %2)
%22 = load i32, i32* @SYS_clock_settime
%23 = load i32, i32* @CLOCK_MONOTONIC
%24 = call i32 (i32, i32, ...) @syscall(i32 %22, i32 %23, %struct.timespec* %2)
%25 = load i32, i32* @SYS_clock_getres
%26 = load i32, i32* @CLOCK_MONOTONIC
%27 = call i32 (i32, i32, ...) @syscall(i32 %25, i32 %26, %struct.timespec* %2)
%28 = load i32, i32* @SYS_clock_gettime
%29 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%30 = call i32 (i32, i32, ...) @syscall(i32 %28, i32 %29, %struct.timespec* %2)
%31 = load i32, i32* @SYS_clock_settime
%32 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%33 = call i32 (i32, i32, ...) @syscall(i32 %31, i32 %32, %struct.timespec* %2)
%34 = load i32, i32* @SYS_clock_getres
%35 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%36 = call i32 (i32, i32, ...) @syscall(i32 %34, i32 %35, %struct.timespec* %2)
%37 = load i32, i32* @SYS_clock_gettime
%38 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%39 = call i32 (i32, i32, ...) @syscall(i32 %37, i32 %38, %struct.timespec* %2)
%40 = load i32, i32* @SYS_clock_settime
%41 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%42 = call i32 (i32, i32, ...) @syscall(i32 %40, i32 %41, %struct.timespec* %2)
%43 = load i32, i32* @SYS_clock_getres
%44 = load i32, i32* @CLOCK_THREAD_CPUTIME_ID
%45 = call i32 (i32, i32, ...) @syscall(i32 %43, i32 %44, %struct.timespec* %2)
%46 = load i32, i32* @SYS_clock_gettime
%47 = load i32, i32* @CLOCK_REALTIME
%48 = call i32 (i32, i32, ...) @syscall(i32 %46, i32 %47, %struct.timespec* %2)
%49 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%50 = load i64, i64* %49
%51 = add nsw i64 %50, 1
store i64 %51, i64* %49
%52 = load i32, i32* @SYS_clock_nanosleep
%53 = load i32, i32* @CLOCK_REALTIME
%54 = load i32, i32* @TIMER_ABSTIME
%55 = call i32 (i32, i32, ...) @syscall(i32 %52, i32 %53, i32 %54, %struct.timespec* %2)
store i64 0, i64* %49
%56 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store i32 10000, i32* %56
%57 = load i32, i32* @SYS_clock_nanosleep
%58 = load i32, i32* @CLOCK_REALTIME
%59 = call i32 (i32, i32, ...) @syscall(i32 %57, i32 %58, i32 0, %struct.timespec* %2)
ret i32 0
}