#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 */
struct TYPE_4__ {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct TYPE_3__ {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct itimerval {
  TYPE_2__ it_value;
  TYPE_1__ it_interval;
};

/* Variables and functions */
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ exit_cleanup();
int /*<<< orphan*/ perror(char *);
scalar_t__ setitimer(int /*<<< orphan*/, struct itimerval *,
                     int /*<<< orphan*/ *);
void init_timer(void) {
  struct itimerval interval;
  interval.it_interval.tv_sec = 1;
  interval.it_interval.tv_usec = 0;
  interval.it_value.tv_sec = 1;
  interval.it_value.tv_usec = 0;
  if (setitimer(ITIMER_REAL, &interval, NULL) != 0) {
    perror("Unable to set interval timer");
    exit_cleanup();
  }
}


x86 assembly (clang, -O0):
<init_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x1,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
movl   $0x1,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <setitimer@plt>
cmp    $0x0,%rax
je     1189 <init_timer+0x59>
lea    0xe83(%rip),%rdi
call   1040 <perror@plt>
mov    $0x0,%al
call   1050 <exit_cleanup@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_timer>:
sub    $0x28,%rsp
movl   $0x1,0x18(%rsp)
movq   $0x0,0x20(%rsp)
movl   $0x1,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1030 <setitimer@plt>
test   %rax,%rax
jne    1175 <init_timer+0x45>
add    $0x28,%rsp
ret
lea    0xe84(%rip),%rdi
call   1040 <perror@plt>
xor    %eax,%eax
add    $0x28,%rsp
jmp    1050 <exit_cleanup@plt>

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i64 }
%struct.TYPE_3__ = type { i32, i64 }
@ITIMER_REAL = global i32 0
@.str = [29 x i8] c"Unable to set interval timer\00"
define void @init_timer() {
%1 = alloca %struct.itimerval
%2 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i32 0, i32 1
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i32 0, i32 0
store i32 1, i32* %3
%4 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i32 0, i32 1
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 1
store i64 0, i64* %5
%6 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i32 0, i32 0
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %6, i32 0, i32 0
store i32 1, i32* %7
%8 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i32 0, i32 0
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i32 0, i32 1
store i64 0, i64* %9
%10 = load i32, i32* @ITIMER_REAL
%11 = call i64 @setitimer(i32 %10, %struct.itimerval* %1, i32* null)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (...) @exit_cleanup()
br label %16
16: ; preds = %13, %0
ret void
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i64 }
%struct.TYPE_3__ = type { i32, i64 }
@ITIMER_REAL = global i32 0
@.str = [29 x i8] c"Unable to set interval timer\00"
define void @init_timer() {
%1 = alloca %struct.itimerval
%2 = bitcast %struct.itimerval* %1 to i8*
%3 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 1, i32 0
store i32 1, i32* %3
%4 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 1, i32 1
store i64 0, i64* %4
%5 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 0, i32 0
store i32 1, i32* %5
%6 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %1, i64 0, i32 0, i32 1
store i64 0, i64* %6
%7 = load i32, i32* @ITIMER_REAL
%8 = call i64 @setitimer(i32 %7, %struct.itimerval* %1, i32* null)
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 (...) @exit_cleanup()
br label %13
13: ; preds = %10, %0
ret void
}