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

/* Variables and functions */
int /*<<< orphan*/ ITIMER_REAL;
int /*<<< orphan*/ setitimer(int /*<<< orphan*/, struct itimerval *,
                             int /*<<< orphan*/ *);
void start_timeout_timer(unsigned int msecs) {
  struct itimerval ival;
  ival.it_value.tv_sec = msecs / 1000;
  ival.it_value.tv_usec = (msecs % 1000) * 1000;
  ival.it_interval.tv_sec = ival.it_interval.tv_usec = 0;
  setitimer(ITIMER_REAL, &ival, NULL);
}


x86 assembly (clang, -O0):
<start_timeout_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %ecx
imul   $0x3e8,%edx,%eax
mov    %eax,-0xc(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <setitimer@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_timeout_timer>:
sub    $0x18,%rsp
mov    %edi,%eax
imul   $0x10624dd3,%rax,%rax
shr    $0x26,%rax
mov    %eax,0x10(%rsp)
imul   $0x3e8,%eax,%eax
sub    %eax,%edi
imul   $0x3e8,%edi,%eax
mov    %eax,0x14(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <setitimer@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i32, i32 }
@ITIMER_REAL = global i32 0
define void @start_timeout_timer(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.itimerval
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = udiv i32 %4, 1000
%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 0
store i32 %5, i32* %7
%8 = load i32, i32* %2
%9 = urem i32 %8, 1000
%10 = mul i32 %9, 1000
%11 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 1
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 1
store i32 %10, i32* %12
%13 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %13, i32 0, i32 0
store i64 0, i64* %14
%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 1
store i64 0, i64* %16
%17 = load i32, i32* @ITIMER_REAL
%18 = call i32 @setitimer(i32 %17, %struct.itimerval* %3, i32* null)
ret void
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64, i64 }
%struct.TYPE_3__ = type { i32, i32 }
@ITIMER_REAL = global i32 0
define void @start_timeout_timer(i32 %0) {
%2 = alloca %struct.itimerval
%3 = bitcast %struct.itimerval* %2 to i8*
%4 = udiv i32 %0, 1000
%5 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 1, i32 0
store i32 %4, i32* %5
%6 = urem i32 %0, 1000
%7 = mul nuw nsw i32 %6, 1000
%8 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 1, i32 1
store i32 %7, i32* %8
%9 = bitcast %struct.itimerval* %2 to i8*
%10 = load i32, i32* @ITIMER_REAL
%11 = call i32 @setitimer(i32 %10, %struct.itimerval* %2, i32* null)
ret void
}