#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 */
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ setitimer(int /*<<< orphan*/, struct itimerval *,
                             struct itimerval *);
unsigned int alarm(unsigned int seconds) {
  struct itimerval iv;
  iv.it_interval.tv_sec = iv.it_interval.tv_usec = 0;
  iv.it_value.tv_sec = seconds;
  iv.it_value.tv_usec = 0;
  setitimer(ITIMER_REAL, &iv, &iv);
  return iv.it_value.tv_sec + (iv.it_value.tv_usec ? 1 : 0);
}


x86 assembly (clang, -O0):
<alarm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2ea0(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rdx
mov    %rdx,%rsi
call   1030 <setitimer@plt>
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%rsi
xor    %ecx,%ecx
mov    $0x1,%edx
cmp    $0x0,%rsi
cmovne %edx,%ecx
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alarm>:
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rsp)
mov    %edi,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rdx
mov    %rdx,%rsi
call   1030 <setitimer@plt>
mov    0x8(%rsp),%eax
cmpq   $0x1,0x10(%rsp)
sbb    $0xffffffff,%eax
add    $0x28,%rsp
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
define i32 @alarm(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.itimerval
store i32 %0, i32* %2
%4 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 1
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 0
store i64 0, i64* %5
%6 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 1
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 1
store i64 0, i64* %7
%8 = load i32, i32* %2
%9 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %9, i32 0, i32 0
store i32 %8, i32* %10
%11 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %11, i32 0, i32 1
store i64 0, i64* %12
%13 = load i32, i32* @ITIMER_REAL
%14 = call i32 @setitimer(i32 %13, %struct.itimerval* %3, %struct.itimerval* %3)
%15 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %18, i32 0, i32 1
%20 = load i64, i64* %19
%21 = icmp ne i64 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 1, i32 0
%24 = add i32 %17, %23
ret i32 %24
}

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
define i32 @alarm(i32 %0) {
%2 = alloca %struct.itimerval
%3 = bitcast %struct.itimerval* %2 to i8*
%4 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 1, i32 0
%5 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 0
%6 = bitcast i64* %4 to i8*
store i32 %0, i32* %5
%7 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 1
store i64 0, i64* %7
%8 = load i32, i32* @ITIMER_REAL
%9 = call i32 @setitimer(i32 %8, %struct.itimerval* %2, %struct.itimerval* %2)
%10 = load i32, i32* %5
%11 = load i64, i64* %7
%12 = icmp ne i64 %11, 0
%13 = zext i1 %12 to i32
%14 = add i32 %10, %13
ret i32 %14
}