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

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ *boxTuple(int /*<<< orphan*/, int /*<<< orphan*/ *, int);
int clock_gettime(int /*<<< orphan*/, struct timespec *);
uint32_t *clockGetTime(uint32_t context_len, uint32_t *stackvar) {
  struct timespec t;
  int rc;
  uint32_t tuple_vals[2];
  rc = clock_gettime(CLOCK_MONOTONIC, &t);
  assert(rc == 0);
  tuple_vals[0] = t.tv_sec;
  tuple_vals[1] = t.tv_nsec;
  return boxTuple(context_len, tuple_vals, 2);
}


x86 assembly (clang, -O0):
<clockGetTime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x24(%rbp),%rsi
mov    $0x2,%edx
call   1050 <boxTuple@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clockGetTime>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    (%rsp),%rax
rol    $0x20,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
mov    $0x2,%edx
call   1050 <boxTuple@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@CLOCK_MONOTONIC = global i32 0
define i32* @clockGetTime(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca %struct.timespec
%6 = alloca i32
%7 = alloca [2 x i32]
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = load i32, i32* @CLOCK_MONOTONIC
%9 = call i32 @clock_gettime(i32 %8, %struct.timespec* %5)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%15 = load i32, i32* %14
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
store i32 %15, i32* %16
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
store i32 %18, i32* %19
%20 = load i32, i32* %3
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%22 = call i32* @boxTuple(i32 %20, i32* %21, i32 2)
ret i32* %22
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@CLOCK_MONOTONIC = global i32 0
define i32* @clockGetTime(i32 %0, i32* nocapture readnone %1) {
%3 = alloca %struct.timespec
%4 = alloca [2 x i32]
%5 = bitcast %struct.timespec* %3 to i8*
%6 = bitcast [2 x i32]* %4 to i8*
%7 = load i32, i32* @CLOCK_MONOTONIC
%8 = call i32 @clock_gettime(i32 %7, %struct.timespec* %3)
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
store i32 %13, i32* %14
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
store i32 %16, i32* %17
%18 = call i32* @boxTuple(i32 %0, i32* %14, i32 2)
ret i32* %18
}