#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__ {
  unsigned int tv_sec;
  int /*<<< orphan*/ tv_usec;
};
struct itimerval {
  TYPE_1__ it_value;
};

/* Variables and functions */
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ __syscall(int, int /*<<< orphan*/, struct itimerval *,
                             struct itimerval *);
unsigned alarm(unsigned seconds) {
  struct itimerval it = {.it_value.tv_sec = seconds};
  __syscall(104, ITIMER_REAL, &it, &it);
  return it.it_value.tv_sec + !!it.it_value.tv_usec;
}


x86 assembly (clang, -O0):
<alarm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2eb1(%rip),%rax
mov    (%rax),%esi
mov    $0x68,%edi
lea    -0x10(%rbp),%rcx
mov    %rcx,%rdx
call   1030 <__syscall@plt>
mov    -0x10(%rbp),%eax
cmpl   $0x0,-0xc(%rbp)
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
add    %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alarm>:
push   %rax
mov    %edi,(%rsp)
movl   $0x0,0x4(%rsp)
mov    0x2ebd(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rcx
mov    $0x68,%edi
mov    %rcx,%rdx
call   1030 <__syscall@plt>
mov    (%rsp),%eax
cmpl   $0x1,0x4(%rsp)
sbb    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i32 }
@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 0
%5 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %4, i32 0, i32 0
%6 = load i32, i32* %2
store i32 %6, i32* %5
%7 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %4, i32 0, i32 1
store i32 0, i32* %7
%8 = load i32, i32* @ITIMER_REAL
%9 = call i32 @__syscall(i32 104, i32 %8, %struct.itimerval* %3, %struct.itimerval* %3)
%10 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%11 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 1
%15 = load i32, i32* %14
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = add i32 %12, %19
ret i32 %20
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i32 }
@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 0, i32 0
store i32 %0, i32* %4
%5 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 0, i32 1
store i32 0, i32* %5
%6 = load i32, i32* @ITIMER_REAL
%7 = call i32 @__syscall(i32 104, i32 %6, %struct.itimerval* %2, %struct.itimerval* %2)
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
%11 = zext i1 %10 to i32
%12 = add i32 %8, %11
ret i32 %12
}