#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 scalar_t__ timer_t;
struct sigevent {
  int /*<<< orphan*/ sigev_signo;
  int /*<<< orphan*/ sigev_notify;
};
struct TYPE_4__ {
  int tv_sec;
  scalar_t__ tv_nsec;
};
struct TYPE_3__ {
  int tv_sec;
  scalar_t__ tv_nsec;
};
struct itimerspec {
  TYPE_2__ it_interval;
  TYPE_1__ it_value;
};
typedef int /*<<< orphan*/ se;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ SIGEV_SIGNAL;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ TIMER_ABSTIME;
int /*<<< orphan*/ memset(struct sigevent *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ timer_create(int /*<<< orphan*/, struct sigevent *, scalar_t__ *);
scalar_t__ timer_settime(scalar_t__, int /*<<< orphan*/, struct itimerspec *,
                         struct itimerspec *);
int create(int seconds, int id) {
  timer_t tid;
  struct sigevent se;
  struct itimerspec ts, ots;
  memset(&se, 0, sizeof(se));
  se.sigev_notify = SIGEV_SIGNAL;
  se.sigev_signo = SIGUSR1;
  if (timer_create(CLOCK_REALTIME, &se, &tid) < 0) {
    perror("timer_creat");
    return -1;
  }
  printf("timer_create successfully = %d.\n", (int)tid);
  ts.it_value.tv_sec = 3;
  ts.it_value.tv_nsec = 0;
  ts.it_interval.tv_sec = seconds;
  ts.it_interval.tv_nsec = 0;
  if (timer_settime(tid, TIMER_ABSTIME, &ts, &ots) < 0) {
    perror("timer_settime");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <timer_create@plt>
cmp    $0x0,%rax
jge    11be <create+0x6e>
lea    0xe53(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1230 <create+0xe0>
mov    -0x18(%rbp),%rax
mov    %eax,%esi
lea    0xe41(%rip),%rdi
call   1050 <printf@plt>
movl   $0x3,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2de8(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
lea    -0x60(%rbp),%rcx
call   1030 <timer_settime@plt>
cmp    $0x0,%rax
jge    1229 <create+0xd9>
lea    0xe15(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1230 <create+0xe0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create>:
push   %rbp
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %edi,%ebp
mov    %rsp,%rbx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2e65(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rdx
mov    %rbx,%rsi
call   1040 <timer_create@plt>
test   %rax,%rax
js     11ff <create+0xaf>
mov    0x8(%rsp),%esi
lea    0xe5e(%rip),%rdi
call   1050 <printf@plt>
movl   $0x3,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    %ebp,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    0x8(%rsp),%rdi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
lea    0x30(%rsp),%rcx
call   1030 <timer_settime@plt>
test   %rax,%rax
js     1208 <create+0xb8>
mov    %r14d,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xdfa(%rip),%rdi
jmp    120f <create+0xbf>
lea    0xe1e(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%r14d
jmp    11f3 <create+0xa3>

LLVM IR (-O0):
%struct.sigevent = type { i32, i32 }
%struct.itimerspec = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i64 }
%struct.TYPE_3__ = type { i32, i64 }
@SIGEV_SIGNAL = global i32 0
@SIGUSR1 = global i32 0
@CLOCK_REALTIME = global i32 0
@.str = [12 x i8] c"timer_creat\00"
@.str.1 = [33 x i8] c"timer_create successfully = %d.\0A\00"
@TIMER_ABSTIME = global i32 0
@.str.2 = [14 x i8] c"timer_settime\00"
define i32 @create(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64
%7 = alloca %struct.sigevent
%8 = alloca %struct.itimerspec
%9 = alloca %struct.itimerspec
store i32 %0, i32* %4
store i32 %1, i32* %5
%10 = call i32 @memset(%struct.sigevent* %7, i32 0, i32 8)
%11 = load i32, i32* @SIGEV_SIGNAL
%12 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %7, i32 0, i32 1
store i32 %11, i32* %12
%13 = load i32, i32* @SIGUSR1
%14 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %7, i32 0, i32 0
store i32 %13, i32* %14
%15 = load i32, i32* @CLOCK_REALTIME
%16 = call i64 @timer_create(i32 %15, %struct.sigevent* %7, i64* %6)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %40
20: ; preds = %2
%21 = load i64, i64* %6
%22 = trunc i64 %21 to i32
%23 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %8, i32 0, i32 1
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %24, i32 0, i32 0
store i32 3, i32* %25
%26 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %8, i32 0, i32 1
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 1
store i64 0, i64* %27
%28 = load i32, i32* %4
%29 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %8, i32 0, i32 0
%30 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %29, i32 0, i32 0
store i32 %28, i32* %30
%31 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %8, i32 0, i32 0
%32 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %31, i32 0, i32 1
store i64 0, i64* %32
%33 = load i64, i64* %6
%34 = load i32, i32* @TIMER_ABSTIME
%35 = call i64 @timer_settime(i64 %33, i32 %34, %struct.itimerspec* %8, %struct.itimerspec* %9)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %20
%38 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %40
39: ; preds = %20
store i32 0, i32* %3
br label %40
40: ; preds = %39, %37, %18
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
%struct.sigevent = type { i32, i32 }
%struct.itimerspec = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i64 }
%struct.TYPE_3__ = type { i32, i64 }
@SIGEV_SIGNAL = global i32 0
@SIGUSR1 = global i32 0
@CLOCK_REALTIME = global i32 0
@.str = [12 x i8] c"timer_creat\00"
@.str.1 = [33 x i8] c"timer_create successfully = %d.\0A\00"
@TIMER_ABSTIME = global i32 0
@.str.2 = [14 x i8] c"timer_settime\00"
define i32 @create(i32 %0, i32 %1) {
%3 = alloca i64
%4 = alloca %struct.sigevent
%5 = alloca %struct.itimerspec
%6 = alloca %struct.itimerspec
%7 = bitcast i64* %3 to i8*
%8 = bitcast %struct.sigevent* %4 to i8*
%9 = bitcast %struct.itimerspec* %5 to i8*
%10 = bitcast %struct.itimerspec* %6 to i8*
%11 = call i32 @memset(%struct.sigevent* %4, i32 0, i32 8)
%12 = load i32, i32* @SIGEV_SIGNAL
%13 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %4, i64 0, i32 1
store i32 %12, i32* %13
%14 = load i32, i32* @SIGUSR1
%15 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %4, i64 0, i32 0
store i32 %14, i32* %15
%16 = load i32, i32* @CLOCK_REALTIME
%17 = call i64 @timer_create(i32 %16, %struct.sigevent* %4, i64* %3)
%18 = icmp slt i64 %17, 0
br i1 %18, label %31, label %19
19: ; preds = %2
%20 = load i64, i64* %3
%21 = trunc i64 %20 to i32
%22 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %5, i64 0, i32 1, i32 0
store i32 3, i32* %23
%24 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %5, i64 0, i32 1, i32 1
store i64 0, i64* %24
%25 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %5, i64 0, i32 0, i32 0
store i32 %0, i32* %25
%26 = getelementptr inbounds %struct.itimerspec, %struct.itimerspec* %5, i64 0, i32 0, i32 1
store i64 0, i64* %26
%27 = load i64, i64* %3
%28 = load i32, i32* @TIMER_ABSTIME
%29 = call i64 @timer_settime(i64 %27, i32 %28, %struct.itimerspec* %5, %struct.itimerspec* %6)
%30 = icmp slt i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %19, %2
%32 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %19 ]
%33 = call i32 @perror(i8* %32)
br label %34
34: ; preds = %31, %19
%35 = phi i32 [ 0, %19 ], [ -1, %31 ]
ret i32 %35
}