#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 */
struct TYPE_2__ {
  long tv_sec;
};
struct itimerval {
  TYPE_1__ it_value;
};

/* Variables and functions */
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int setitimer(int /*<<< orphan*/, struct itimerval *, int /*<<< orphan*/ *);
void EnableAlarm(int timeout) {
  if (timeout <= 0)
    return;
  struct itimerval timer = {};
  timer.it_value.tv_sec = (long)timeout;
  if ((setitimer(ITIMER_REAL, &timer, NULL)) == -1) {
    perror("setitimer(ITIMER_REAL, &timer, NULL)");
    exit(1);
  };
}


x86 assembly (clang, -O0):
<EnableAlarm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jg     115a <EnableAlarm+0x1a>
jmp    11a7 <EnableAlarm+0x67>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
movslq -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <setitimer@plt>
cmp    $0xffffffff,%eax
jne    11a7 <EnableAlarm+0x67>
lea    0xe68(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EnableAlarm>:
push   %rax
test   %edi,%edi
jle    1153 <EnableAlarm+0x23>
mov    %edi,%eax
mov    %rax,(%rsp)
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <setitimer@plt>
cmp    $0xffffffff,%eax
je     1155 <EnableAlarm+0x25>
pop    %rax
ret
lea    0xea4(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
@ITIMER_REAL = global i32 0
@.str = [37 x i8] c"setitimer(ITIMER_REAL, &timer, NULL)\00"
define void @EnableAlarm(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.itimerval
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp sle i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
br label %19
7: ; preds = %1
%8 = bitcast %struct.itimerval* %3 to i8*
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 0
store i64 %10, i64* %12
%13 = load i32, i32* @ITIMER_REAL
%14 = call i32 @setitimer(i32 %13, %struct.itimerval* %3, i32* null)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %19
16: ; preds = %7
%17 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %6, %7
ret void
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64 }
@ITIMER_REAL = global i32 0
@.str = [37 x i8] c"setitimer(ITIMER_REAL, &timer, NULL)\00"
define void @EnableAlarm(i32 %0) {
%2 = alloca %struct.itimerval
%3 = icmp slt i32 %0, 1
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = bitcast %struct.itimerval* %2 to i8*
%6 = zext i32 %0 to i64
%7 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 0
store i64 %6, i64* %7
%8 = load i32, i32* @ITIMER_REAL
%9 = call i32 @setitimer(i32 %8, %struct.itimerval* %2, i32* null)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = tail call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %4
br label %15
15: ; preds = %1, %14
ret void
}