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

/* Variables and functions */
int /*<<< orphan*/ CLOCK_PROCESS_CPUTIME_ID;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ printf(char *, scalar_t__, scalar_t__);
int main() {
  int n;
  struct timespec tStart, tEnd, diff;
  clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tStart);
  for (n = 0; n < 90000000; n++) {
  }
  clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &tEnd);
  if ((tEnd.tv_nsec - tStart.tv_nsec) < 0) {
    diff.tv_sec = tEnd.tv_sec - tStart.tv_sec - 1;
    diff.tv_nsec = 1000000000 + tEnd.tv_nsec - tStart.tv_nsec;
  } else {
    diff.tv_sec = tEnd.tv_sec - tStart.tv_sec;
    diff.tv_nsec = tEnd.tv_nsec - tStart.tv_nsec;
  }
  printf("%ld.%ld seconds\n", diff.tv_sec, diff.tv_nsec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_gettime@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x55d4a80,-0x8(%rbp)
jge    1168 <main+0x48>
jmp    115a <main+0x3a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1148 <main+0x28>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x28(%rbp),%rax
sub    -0x18(%rbp),%rax
cmp    $0x0,%rax
jge    11b3 <main+0x93>
mov    -0x20(%rbp),%rax
sub    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
add    $0x3b9aca00,%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    11cb <main+0xab>
mov    -0x20(%rbp),%rax
sub    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
mov    0x2ebc(%rip),%rbx
mov    (%rbx),%edi
lea    0x10(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
mov    (%rsp),%rax
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rcx
mov    0x18(%rsp),%rdi
mov    %rax,%rdx
sub    %rcx,%rdx
js     1162 <main+0x42>
sub    %rdi,%rsi
jmp    1174 <main+0x54>
not    %rdi
add    %rdi,%rsi
sub    %rcx,%rax
add    $0x3b9aca00,%rax
mov    %rax,%rdx
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@CLOCK_PROCESS_CPUTIME_ID = global i32 0
@.str = [17 x i8] c"%ld.%ld seconds\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
store i32 0, i32* %1
%6 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%7 = call i32 @clock_gettime(i32 %6, %struct.timespec* %3)
store i32 0, i32* %2
br label %8
8: ; preds = %12, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 90000000
br i1 %10, label %11, label %15
11: ; preds = %8
br label %12
12: ; preds = %11
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
br label %8
15: ; preds = %8
%16 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%17 = call i32 @clock_gettime(i32 %16, %struct.timespec* %4)
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%19 = load i64, i64* %18
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%21 = load i64, i64* %20
%22 = sub nsw i64 %19, %21
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %15
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%26 = load i64, i64* %25
%27 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
%28 = load i64, i64* %27
%29 = sub nsw i64 %26, %28
%30 = sub nsw i64 %29, 1
%31 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
store i64 %30, i64* %31
%32 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%33 = load i64, i64* %32
%34 = add nsw i64 1000000000, %33
%35 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%36 = load i64, i64* %35
%37 = sub nsw i64 %34, %36
%38 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
store i64 %37, i64* %38
br label %52
39: ; preds = %15
%40 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 1
%41 = load i64, i64* %40
%42 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
%43 = load i64, i64* %42
%44 = sub nsw i64 %41, %43
%45 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
store i64 %44, i64* %45
%46 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%47 = load i64, i64* %46
%48 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%49 = load i64, i64* %48
%50 = sub nsw i64 %47, %49
%51 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
store i64 %50, i64* %51
br label %52
52: ; preds = %39, %24
%53 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%54 = load i64, i64* %53
%55 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%56 = load i64, i64* %55
%57 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %54, i64 %56)
ret i32 0
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@CLOCK_PROCESS_CPUTIME_ID = global i32 0
@.str = [17 x i8] c"%ld.%ld seconds\0A\00"
define i32 @main() {
%1 = alloca %struct.timespec
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %1 to i8*
%4 = bitcast %struct.timespec* %2 to i8*
%5 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%6 = call i32 @clock_gettime(i32 %5, %struct.timespec* %1)
%7 = load i32, i32* @CLOCK_PROCESS_CPUTIME_ID
%8 = call i32 @clock_gettime(i32 %7, %struct.timespec* %2)
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%12 = load i64, i64* %11
%13 = sub nsw i64 %10, %12
%14 = icmp slt i64 %13, 0
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%16 = load i64, i64* %15
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%18 = load i64, i64* %17
br i1 %14, label %19, label %24
19: ; preds = %0
%20 = xor i64 %18, -1
%21 = add i64 %16, %20
%22 = add nsw i64 %10, 1000000000
%23 = sub i64 %22, %12
br label %26
24: ; preds = %0
%25 = sub nsw i64 %16, %18
br label %26
26: ; preds = %24, %19
%27 = phi i64 [ %21, %19 ], [ %25, %24 ]
%28 = phi i64 [ %23, %19 ], [ %13, %24 ]
%29 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i64 %27, i64 %28)
ret i32 0
}