#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 {
  int /*<<< orphan*/ tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_BOOTTIME;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int main(void) {
  int ret;
  struct timespec tp;
  ret = clock_gettime(CLOCK_BOOTTIME, &tp);
  if (ret) {
    perror("clock_gettime()");
    return EXIT_FAILURE;
  }
  printf("%ld.%ld\n", tp.tv_sec, tp.tv_nsec);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     117b <main+0x4b>
lea    0xe9b(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <main+0x69>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
test   %eax,%eax
jne    1164 <main+0x34>
mov    (%rsp),%edx
mov    0x4(%rsp),%esi
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
lea    0xe95(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e61(%rip),%rax
jmp    1160 <main+0x30>

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@CLOCK_BOOTTIME = global i32 0
@.str = [16 x i8] c"clock_gettime()\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%ld.%ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.timespec
store i32 0, i32* %1
%4 = load i32, i32* @CLOCK_BOOTTIME
%5 = call i32 @clock_gettime(i32 %4, %struct.timespec* %3)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
store i32 %10, i32* %1
br label %18
11: ; preds = %0
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
store i32 %17, i32* %1
br label %18
18: ; preds = %11, %8
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@CLOCK_BOOTTIME = global i32 0
@.str = [16 x i8] c"clock_gettime()\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%ld.%ld\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = load i32, i32* @CLOCK_BOOTTIME
%4 = call i32 @clock_gettime(i32 %3, %struct.timespec* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %14
8: ; preds = %0
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12)
br label %14
14: ; preds = %8, %6
%15 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_SUCCESS, %8 ]
%16 = load i32, i32* %15
ret i32 %16
}