#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
scalar_t__ clock_getres(int /*<<< orphan*/, struct timespec *);
scalar_t__ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ errx(int, char *);
void test_clock_gettime() {
  struct timespec res;
  if (clock_getres(CLOCK_MONOTONIC, &res)) {
    errx(1, "clock_getres");
  }
  if (clock_gettime(CLOCK_MONOTONIC, &res)) {
    errx(1, "clock_gettime");
  }
}


x86 assembly (clang, -O0):
<test_clock_gettime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1050 <clock_getres@plt>
cmp    $0x0,%rax
je     1165 <test_clock_gettime+0x35>
mov    $0x1,%edi
lea    0xea0(%rip),%rsi
call   1040 <errx@plt>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
call   1030 <clock_gettime@plt>
cmp    $0x0,%rax
je     1192 <test_clock_gettime+0x62>
mov    $0x1,%edi
lea    0xe80(%rip),%rsi
call   1040 <errx@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_clock_gettime>:
push   %rbx
sub    $0x10,%rsp
mov    0x2eac(%rip),%rbx
mov    (%rbx),%edi
lea    0x8(%rsp),%rsi
call   1050 <clock_getres@plt>
test   %rax,%rax
je     115e <test_clock_gettime+0x2e>
lea    0xeac(%rip),%rsi
mov    $0x1,%edi
call   1040 <errx@plt>
mov    (%rbx),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
test   %rax,%rax
je     1180 <test_clock_gettime+0x50>
lea    0xe97(%rip),%rsi
mov    $0x1,%edi
call   1040 <errx@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@CLOCK_MONOTONIC = global i32 0
@.str = [13 x i8] c"clock_getres\00"
@.str.1 = [14 x i8] c"clock_gettime\00"
define void @test_clock_gettime() {
%1 = alloca %struct.timespec
%2 = load i32, i32* @CLOCK_MONOTONIC
%3 = call i64 @clock_getres(i32 %2, %struct.timespec* %1)
%4 = icmp ne i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @errx(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = load i32, i32* @CLOCK_MONOTONIC
%9 = call i64 @clock_gettime(i32 %8, %struct.timespec* %1)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @errx(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@CLOCK_MONOTONIC = global i32 0
@.str = [13 x i8] c"clock_getres\00"
@.str.1 = [14 x i8] c"clock_gettime\00"
define void @test_clock_gettime() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = load i32, i32* @CLOCK_MONOTONIC
%4 = call i64 @clock_getres(i32 %3, %struct.timespec* %1)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @errx(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
%9 = load i32, i32* @CLOCK_MONOTONIC
%10 = call i64 @clock_gettime(i32 %9, %struct.timespec* %1)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @errx(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %8
ret void
}