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

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ TFD_NONBLOCK;
int timerfd_create(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ timerfd_settime(int, int /*<<< orphan*/, struct itimerspec *,
                           int /*<<< orphan*/ *);
int main(void) {
  struct itimerspec new_value;
  int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
  if (fd < 0) {
    return 1;
  }
  if (timerfd_settime(fd, 0, &new_value, NULL) != 0) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%edi
mov    0x2e99(%rip),%rax
mov    (%rax),%esi
call   1030 <timerfd_create@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    115f <main+0x3f>
movl   $0x1,-0x4(%rbp)
jmp    118e <main+0x6e>
mov    -0xc(%rbp),%edi
xor    %esi,%esi
lea    -0x8(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <timerfd_settime@plt>
cmp    $0x0,%rax
je     1187 <main+0x67>
movl   $0x1,-0x4(%rbp)
jmp    118e <main+0x6e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%edi
mov    0x2ea7(%rip),%rax
mov    (%rax),%esi
call   1030 <timerfd_create@plt>
test   %eax,%eax
js     1157 <main+0x37>
mov    %rsp,%rdx
mov    %eax,%edi
xor    %esi,%esi
xor    %ecx,%ecx
call   1040 <timerfd_settime@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.itimerspec = type { i32 }
@CLOCK_MONOTONIC = global i32 0
@TFD_NONBLOCK = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.itimerspec
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @CLOCK_MONOTONIC
%5 = load i32, i32* @TFD_NONBLOCK
%6 = call i32 @timerfd_create(i32 %4, i32 %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %1
br label %16
10: ; preds = %0
%11 = load i32, i32* %3
%12 = call i64 @timerfd_settime(i32 %11, i32 0, %struct.itimerspec* %2, i32* null)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %1
br label %16
15: ; preds = %10
store i32 0, i32* %1
br label %16
16: ; preds = %15, %14, %9
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
%struct.itimerspec = type { i32 }
@CLOCK_MONOTONIC = global i32 0
@TFD_NONBLOCK = global i32 0
define i32 @main() {
%1 = alloca %struct.itimerspec
%2 = bitcast %struct.itimerspec* %1 to i8*
%3 = load i32, i32* @CLOCK_MONOTONIC
%4 = load i32, i32* @TFD_NONBLOCK
%5 = tail call i32 @timerfd_create(i32 %3, i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = call i64 @timerfd_settime(i32 %5, i32 0, %struct.itimerspec* %1, i32* null)
%9 = icmp ne i64 %8, 0
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %7, %0
%12 = phi i32 [ 1, %0 ], [ %10, %7 ]
ret i32 %12
}