#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_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
scalar_t__ clock_getres(int /*<<< orphan*/, struct timespec *);
int check_timer(void) {
  struct timespec ts;
  if (clock_getres(CLOCK_MONOTONIC, &ts))
    return 1;
  return (ts.tv_sec != 0 || ts.tv_nsec != 1);
}


x86 assembly (clang, -O0):
<check_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_getres@plt>
cmp    $0x0,%rax
je     1140 <check_timer+0x30>
movl   $0x1,-0x4(%rbp)
jmp    1165 <check_timer+0x55>
mov    $0x1,%al
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
jne    115a <check_timer+0x4a>
cmpl   $0x1,-0x10(%rbp)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_timer>:
sub    $0x18,%rsp
mov    0x2ecd(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_getres@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1139 <check_timer+0x29>
add    $0x18,%rsp
ret
cmpq   $0x0,0x8(%rsp)
setne  %al
cmpl   $0x1,0x10(%rsp)
setne  %cl
or     %al,%cl
movzbl %cl,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i32 }
@CLOCK_MONOTONIC = global i32 0
define i32 @check_timer() {
%1 = alloca i32
%2 = alloca %struct.timespec
%3 = load i32, i32* @CLOCK_MONOTONIC
%4 = call i64 @clock_getres(i32 %3, %struct.timespec* %2)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 1, i32* %1
br label %18
7: ; preds = %0
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%9 = load i64, i64* %8
%10 = icmp ne i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
%13 = load i32, i32* %12
%14 = icmp ne i32 %13, 1
br label %15
15: ; preds = %11, %7
%16 = phi i1 [ true, %7 ], [ %14, %11 ]
%17 = zext i1 %16 to i32
store i32 %17, i32* %1
br label %18
18: ; preds = %15, %6
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
%struct.timespec = type { i64, i32 }
@CLOCK_MONOTONIC = global i32 0
define i32 @check_timer() {
%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 %6, label %15
6: ; preds = %0
%7 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp ne i64 %8, 0
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%11 = load i32, i32* %10
%12 = icmp ne i32 %11, 1
%13 = select i1 %9, i1 true, i1 %12
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %0, %6
%16 = phi i32 [ %14, %6 ], [ 1, %0 ]
ret i32 %16
}