#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef void *time_t;
struct TYPE_4__ {
  long tv_nsec;
  void *tv_sec;
};
struct TYPE_3__ {
  long tv_nsec;
  void *tv_sec;
};
struct itimerspec {
  TYPE_2__ it_interval;
  TYPE_1__ it_value;
};

/* Variables and functions */
int timerfd_settime(int, int /*<<< orphan*/, struct itimerspec *,
                    int /*<<< orphan*/ *);
int ftimerfd_start(int fd, long long nsesc, long long alter) {
  struct itimerspec new_value;
  new_value.it_value.tv_sec = (time_t)(nsesc / (1000000000l));
  new_value.it_value.tv_nsec = (long int)(nsesc % (1000000000l));
  new_value.it_interval.tv_sec = (time_t)(alter / (1000000000l));
  new_value.it_interval.tv_nsec = (long int)(alter % (1000000000l));
  if (timerfd_settime(fd, 0, &new_value, NULL) == -1) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<ftimerfd_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3b9aca00,%ecx
cqto
idiv   %rcx
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3b9aca00,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x3b9aca00,%ecx
cqto
idiv   %rcx
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x3b9aca00,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x38(%rbp)
mov    -0x8(%rbp),%edi
xor    %esi,%esi
lea    -0x38(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <timerfd_settime@plt>
cmp    $0xffffffff,%eax
jne    1192 <ftimerfd_start+0x82>
movl   $0x1,-0x4(%rbp)
jmp    1199 <ftimerfd_start+0x89>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftimerfd_start>:
sub    $0x28,%rsp
mov    %rdx,%rcx
movabs $0x112e0be826d694b3,%r8
0b 2e 11
mov    %rsi,%rax
imul   %r8
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1a,%rdx
add    %rax,%rdx
mov    %rdx,0x20(%rsp)
imul   $0x3b9aca00,%rdx,%rax
sub    %rax,%rsi
mov    %rcx,%rax
imul   %r8
mov    %rsi,0x18(%rsp)
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1a,%rdx
add    %rax,%rdx
mov    %rdx,0x10(%rsp)
imul   $0x3b9aca00,%rdx,%rax
sub    %rax,%rcx
mov    %rcx,0x8(%rsp)
lea    0x8(%rsp),%rdx
xor    %esi,%esi
xor    %ecx,%ecx
call   1030 <timerfd_settime@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
sete   %cl
mov    %ecx,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.itimerspec = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i8* }
%struct.TYPE_3__ = type { i64, i8* }
define i32 @ftimerfd_start(i32 %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
%8 = alloca %struct.itimerspec
store i32 %0, i32* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%9 = load i64, i64* %6
%10 = sdiv i64 %9, 1000000000
%11 = inttoptr i64 %10 to i8*
%12 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %8, i32 0, i32 1
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 1
store i8* %11, i8** %13
%14 = load i64, i64* %6
%15 = srem i64 %14, 1000000000
%16 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %8, i32 0, i32 1
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 0
store i64 %15, i64* %17
%18 = load i64, i64* %7
%19 = sdiv i64 %18, 1000000000
%20 = inttoptr i64 %19 to i8*
%21 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %8, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 1
store i8* %20, i8** %22
%23 = load i64, i64* %7
%24 = srem i64 %23, 1000000000
%25 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %8, i32 0, i32 0
%26 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %25, i32 0, i32 0
store i64 %24, i64* %26
%27 = load i32, i32* %5
%28 = call i32 @timerfd_settime(i32 %27, i32 0, %struct.itimerspec* %8, i32* null)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %31
30: ; preds = %3
store i32 1, i32* %4
br label %32
31: ; preds = %3
store i32 0, i32* %4
br label %32
32: ; preds = %31, %30
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
%struct.itimerspec = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i8* }
%struct.TYPE_3__ = type { i64, i8* }
define i32 @ftimerfd_start(i32 %0, i64 %1, i64 %2) {
%4 = alloca %struct.itimerspec
%5 = bitcast %struct.itimerspec* %4 to i8*
%6 = sdiv i64 %1, 1000000000
%7 = inttoptr i64 %6 to i8*
%8 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %4, i64 0, i32 1, i32 1
store i8* %7, i8** %8
%9 = srem i64 %1, 1000000000
%10 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %4, i64 0, i32 1, i32 0
store i64 %9, i64* %10
%11 = sdiv i64 %2, 1000000000
%12 = inttoptr i64 %11 to i8*
%13 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %4, i64 0, i32 0, i32 1
store i8* %12, i8** %13
%14 = srem i64 %2, 1000000000
%15 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %4, i64 0, i32 0, i32 0
store i64 %14, i64* %15
%16 = call i32 @timerfd_settime(i32 %0, i32 0, %struct.itimerspec* %4, i32* null)
%17 = icmp eq i32 %16, -1
%18 = zext i1 %17 to i32
ret i32 %18
}