#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_3__ {
  long tv_sec;
  long tv_usec;
};
struct TYPE_4__ {
  long tv_sec;
  long tv_usec;
};
struct itimerval {
  TYPE_1__ it_value;
  TYPE_2__ it_interval;
};

/* Variables and functions */
int /*<<< orphan*/ ITIMER_REAL;
int setitimer(int /*<<< orphan*/, struct itimerval *, int /*<<< orphan*/ *);
int setTicker(int n_msecs) {
  struct itimerval new_timeset;
  long n_sec, n_usecs;
  n_sec = n_msecs / 1000;
  n_usecs = (n_msecs % 1000) * 1000L;
  new_timeset.it_interval.tv_sec = n_sec;
  new_timeset.it_interval.tv_usec = n_usecs;
  n_msecs = 1;
  n_sec = n_msecs / 1000;
  n_usecs = (n_msecs % 1000) * 1000L;
  new_timeset.it_value.tv_sec = n_sec;
  new_timeset.it_value.tv_usec = n_usecs;
  return setitimer(ITIMER_REAL, &new_timeset, NULL);
}


x86 assembly (clang, -O0):
<setTicker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
imul   $0x3e8,%rax,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cltq
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
imul   $0x3e8,%rax,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <setitimer@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setTicker>:
sub    $0x28,%rsp
movslq %edi,%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
movslq %ecx,%rcx
imul   $0x3e8,%ecx,%edx
sub    %edx,%eax
imul   $0x3e8,%eax,%eax
cltq
mov    %rcx,0x10(%rsp)
mov    %rax,0x18(%rsp)
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rsi
xor    %edx,%edx
call   1030 <setitimer@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.itimerval = type { %struct.TYPE_3__, %struct.TYPE_4__ }
%struct.TYPE_3__ = type { i64, i64 }
%struct.TYPE_4__ = type { i64, i64 }
@ITIMER_REAL = global i32 0
define i32 @setTicker(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.itimerval
%4 = alloca i64
%5 = alloca i64
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = sdiv i32 %6, 1000
%8 = sext i32 %7 to i64
store i64 %8, i64* %4
%9 = load i32, i32* %2
%10 = srem i32 %9, 1000
%11 = sext i32 %10 to i64
%12 = mul nsw i64 %11, 1000
store i64 %12, i64* %5
%13 = load i64, i64* %4
%14 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 1
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %14, i32 0, i32 0
store i64 %13, i64* %15
%16 = load i64, i64* %5
%17 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %17, i32 0, i32 1
store i64 %16, i64* %18
store i32 1, i32* %2
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 1000
%21 = sext i32 %20 to i64
store i64 %21, i64* %4
%22 = load i32, i32* %2
%23 = srem i32 %22, 1000
%24 = sext i32 %23 to i64
%25 = mul nsw i64 %24, 1000
store i64 %25, i64* %5
%26 = load i64, i64* %4
%27 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %27, i32 0, i32 0
store i64 %26, i64* %28
%29 = load i64, i64* %5
%30 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %3, i32 0, i32 0
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %30, i32 0, i32 1
store i64 %29, i64* %31
%32 = load i32, i32* @ITIMER_REAL
%33 = call i32 @setitimer(i32 %32, %struct.itimerval* %3, i32* null)
ret i32 %33
}

LLVM IR (-O2):
%struct.itimerval = type { %struct.TYPE_3__, %struct.TYPE_4__ }
%struct.TYPE_3__ = type { i64, i64 }
%struct.TYPE_4__ = type { i64, i64 }
@ITIMER_REAL = global i32 0
define i32 @setTicker(i32 %0) {
%2 = alloca %struct.itimerval
%3 = bitcast %struct.itimerval* %2 to i8*
%4 = sdiv i32 %0, 1000
%5 = sext i32 %4 to i64
%6 = srem i32 %0, 1000
%7 = mul nsw i32 %6, 1000
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 1, i32 0
store i64 %5, i64* %9
%10 = getelementptr inbounds %struct.itimerval, %struct.itimerval* %2, i64 0, i32 1, i32 1
store i64 %8, i64* %10
%11 = bitcast %struct.itimerval* %2 to <2 x i64>*
store <2 x i64> <i64 0, i64 1000>, <2 x i64>* %11
%12 = load i32, i32* @ITIMER_REAL
%13 = call i32 @setitimer(i32 %12, %struct.itimerval* %2, i32* null)
ret i32 %13
}