#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_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ timer_t;
struct TYPE_2__ {
  int /*<<< orphan*/ *sival_ptr;
};
struct sigevent {
  int /*<<< orphan*/ sigev_signo;
  int /*<<< orphan*/ sigev_notify;
  TYPE_1__ sigev_value;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ SIGEV_SIGNAL;
int /*<<< orphan*/ SIGUSR1;
int /*<<< orphan*/ perror(char *);
int timer_create(int /*<<< orphan*/, struct sigevent *, int /*<<< orphan*/ *);
void create_realtime_timer(void) {
  struct sigevent evp;
  timer_t timer;
  int ret;
  evp.sigev_value.sival_ptr = &timer;
  evp.sigev_notify = SIGEV_SIGNAL;
  evp.sigev_signo = SIGUSR1;
  ret = timer_create(CLOCK_REALTIME, &evp, &timer);
  if (ret) {
    perror("timer_create");
  }
}


x86 assembly (clang, -O0):
<create_realtime_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x14(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <timer_create@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1177 <create_realtime_timer+0x57>
lea    0xe8e(%rip),%rdi
call   1040 <perror@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_realtime_timer>:
sub    $0x18,%rsp
lea    0x14(%rsp),%rdx
mov    %rdx,0x8(%rsp)
mov    0x2eab(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
call   1030 <timer_create@plt>
test   %eax,%eax
jne    1161 <create_realtime_timer+0x41>
add    $0x18,%rsp
ret
lea    0xe98(%rip),%rdi
call   1040 <perror@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.sigevent = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32* }
@SIGEV_SIGNAL = global i32 0
@SIGUSR1 = global i32 0
@CLOCK_REALTIME = global i32 0
@.str = [13 x i8] c"timer_create\00"
define void @create_realtime_timer() {
%1 = alloca %struct.sigevent
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %1, i32 0, i32 2
%5 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %4, i32 0, i32 0
store i32* %2, i32** %5
%6 = load i32, i32* @SIGEV_SIGNAL
%7 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %1, i32 0, i32 1
store i32 %6, i32* %7
%8 = load i32, i32* @SIGUSR1
%9 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %1, i32 0, i32 0
store i32 %8, i32* %9
%10 = load i32, i32* @CLOCK_REALTIME
%11 = call i32 @timer_create(i32 %10, %struct.sigevent* %1, i32* %2)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %0
ret void
}

LLVM IR (-O2):
%struct.sigevent = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32* }
@SIGEV_SIGNAL = global i32 0
@SIGUSR1 = global i32 0
@CLOCK_REALTIME = global i32 0
@.str = [13 x i8] c"timer_create\00"
define void @create_realtime_timer() {
%1 = alloca %struct.sigevent
%2 = alloca i32
%3 = bitcast %struct.sigevent* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %1, i64 0, i32 2, i32 0
store i32* %2, i32** %5
%6 = load i32, i32* @SIGEV_SIGNAL
%7 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %1, i64 0, i32 1
store i32 %6, i32* %7
%8 = load i32, i32* @SIGUSR1
%9 = getelementptr inbounds %struct.sigevent, %struct.sigevent* %1, i64 0, i32 0
store i32 %8, i32* %9
%10 = load i32, i32* @CLOCK_REALTIME
%11 = call i32 @timer_create(i32 %10, %struct.sigevent* %1, i32* %2)
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %0
ret void
}