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

/* Variables and functions */
unsigned int INT_MAX;
int /*<<< orphan*/ ITIMER_REAL;
int setitimer(int /*<<< orphan*/, struct itimerval *, struct itimerval *);
unsigned int _alarm(unsigned int seconds) {
  struct itimerval newtimer, oldtimer;
  newtimer.it_interval.tv_sec = 0;
  newtimer.it_interval.tv_usec = 0;
  newtimer.it_value.tv_sec = seconds;
  newtimer.it_value.tv_usec = 0;
  if (setitimer(ITIMER_REAL, &newtimer, &oldtimer) == -1) {
    return INT_MAX;
  }
  return oldtimer.it_value.tv_sec;
}


x86 assembly (clang, -O0):
<_alarm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1030 <setitimer@plt>
cmp    $0xffffffff,%eax
jne    1169 <_alarm+0x59>
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    116f <_alarm+0x5f>
mov    -0x48(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_alarm>:
push   %rbx
sub    $0x40,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%rsp)
mov    %edi,(%rsp)
movq   $0x0,0x8(%rsp)
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdx
call   1030 <setitimer@plt>
cmp    $0xffffffff,%eax
jne    114e <_alarm+0x3e>
mov    0x2e9a(%rip),%rbx
mov    (%rbx),%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@ITIMER_REAL = global i32 0
@INT_MAX = global i32 0
define i32 @_alarm(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.itimerval
%5 = alloca %struct.itimerval
store i32 %0, i32* %3
%6 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %4, i32 0, i32 1
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 1
store i64 0, i64* %7
%8 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %4, i32 0, i32 1
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
store i64 0, i64* %9
%10 = load i32, i32* %3
%11 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %4, i32 0, i32 0
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %11, i32 0, i32 0
store i32 %10, i32* %12
%13 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %4, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %13, i32 0, i32 1
store i64 0, i64* %14
%15 = load i32, i32* @ITIMER_REAL
%16 = call i32 @setitimer(i32 %15, %struct.itimerval* %4, %struct.itimerval* %5)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %20
18: ; preds = %1
%19 = load i32, i32* @INT_MAX
store i32 %19, i32* %2
br label %24
20: ; preds = %1
%21 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 0
%23 = load i32, i32* %22
store i32 %23, i32* %2
br label %24
24: ; preds = %20, %18
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i64 }
%struct.TYPE_3__ = type { i64, i64 }
@ITIMER_REAL = global i32 0
@INT_MAX = global i32 0
define i32 @_alarm(i32 %0) {
%2 = alloca %struct.itimerval
%3 = alloca %struct.itimerval
%4 = bitcast %struct.itimerval* %2 to i8*
%5 = bitcast %struct.itimerval* %3 to i8*
%6 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 1, i32 0
%7 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 0
%8 = bitcast i64* %6 to i8*
store i32 %0, i32* %7
%9 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 1
store i64 0, i64* %9
%10 = load i32, i32* @ITIMER_REAL
%11 = call i32 @setitimer(i32 %10, %struct.itimerval* %2, %struct.itimerval* %3)
%12 = icmp eq i32 %11, -1
%13 = load i32, i32* @INT_MAX
%14 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i64 0, i32 0, i32 0
%15 = load i32, i32* %14
%16 = select i1 %12, i32 %13, i32 %15
ret i32 %16
}