#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_usec;
  int tv_sec;
};
struct TYPE_3__ {
  unsigned int tv_usec;
};
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 ualarm(unsigned value, unsigned interval) {
  struct itimerval it = {.it_interval.tv_usec = interval,
                         .it_value.tv_usec = value},
                   it_old;
  setitimer(ITIMER_REAL, &it, &it_old);
  return it_old.it_value.tv_sec * 1000000 + it_old.it_value.tv_usec;
}


x86 assembly (clang, -O0):
<ualarm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <setitimer@plt>
imul   $0xf4240,-0x24(%rbp),%eax
add    -0x28(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ualarm>:
sub    $0x28,%rsp
mov    %edi,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    %esi,0x10(%rsp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
lea    0x18(%rsp),%rdx
call   1030 <setitimer@plt>
imul   $0xf4240,0x1c(%rsp),%eax
add    0x18(%rsp),%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i32 }
%struct.TYPE_3__ = type { i32 }
@ITIMER_REAL = global i32 0
define i32 @ualarm(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.itimerval
%6 = alloca %struct.itimerval
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 0
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 0
%9 = load i32, i32* %3
store i32 %9, i32* %8
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 1
store i32 0, i32* %10
%11 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 1
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
%13 = load i32, i32* %4
store i32 %13, i32* %12
%14 = load i32, i32* @ITIMER_REAL
%15 = call i32 @setitimer(i32 %14, %struct.itimerval* %5, %struct.itimerval* %6)
%16 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %6, i32 0, i32 0
%17 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = mul nsw i32 %18, 1000000
%20 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %6, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = add i32 %19, %22
ret i32 %23
}

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