#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};
  setitimer(ITIMER_REAL, &it, &it);
  return it.it_value.tv_sec * 1000000 + it.it_value.tv_usec;
}


x86 assembly (clang, -O0):
<ualarm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%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),%rdx
mov    %rdx,%rsi
call   1030 <setitimer@plt>
imul   $0xf4240,-0x14(%rbp),%eax
add    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ualarm>:
sub    $0x18,%rsp
mov    %edi,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    %esi,0x10(%rsp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rdx
mov    %rdx,%rsi
call   1030 <setitimer@plt>
imul   $0xf4240,0xc(%rsp),%eax
add    0x8(%rsp),%eax
add    $0x18,%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
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 0
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %6, i32 0, i32 0
%8 = load i32, i32* %3
store i32 %8, i32* %7
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %6, i32 0, i32 1
store i32 0, i32* %9
%10 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 1
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%12 = load i32, i32* %4
store i32 %12, i32* %11
%13 = load i32, i32* @ITIMER_REAL
%14 = call i32 @setitimer(i32 %13, %struct.itimerval* %5, %struct.itimerval* %5)
%15 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 0
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = mul nsw i32 %17, 1000000
%19 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %5, i32 0, i32 0
%20 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = add i32 %18, %21
ret i32 %22
}

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 = bitcast %struct.itimerval* %3 to i8*
%5 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i64 0, i32 0, i32 0
store i32 %0, i32* %5
%6 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i64 0, i32 0, i32 1
store i32 0, i32* %6
%7 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i64 0, i32 1, i32 0
store i32 %1, i32* %7
%8 = load i32, i32* @ITIMER_REAL
%9 = call i32 @setitimer(i32 %8, %struct.itimerval* %3, %struct.itimerval* %3)
%10 = load i32, i32* %6
%11 = mul nsw i32 %10, 1000000
%12 = load i32, i32* %5
%13 = add i32 %11, %12
ret i32 %13
}