#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 */

/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ timeradd(struct timeval *, struct timeval *,
                            struct timeval *);
void initTimers(struct timeval *now, struct timeval *end, int timeoutMs) {
  gettimeofday(now, NULL);
  struct timeval timeout;
  timeout.tv_sec = timeoutMs / 1000;
  timeout.tv_usec = (timeoutMs % 1000) * 1000;
  timeradd(now, &timeout, end);
}


x86 assembly (clang, -O0):
<initTimers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
imul   $0x3e8,%edx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    -0x20(%rbp),%rsi
call   1030 <timeradd@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initTimers>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %esi,%esi
call   1040 <gettimeofday@plt>
movslq %ebp,%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
mov    %ecx,0x8(%rsp)
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
imul   $0x3e8,%eax,%eax
mov    %eax,0xc(%rsp)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <timeradd@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define void @initTimers(%struct.timeval* %0, %struct.timeval* %1, i32 %2) {
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca i32
%7 = alloca %struct.timeval
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
store i32 %2, i32* %6
%8 = load %struct.timeval*, %struct.timeval** %4
%9 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%10 = load i32, i32* %6
%11 = sdiv i32 %10, 1000
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
store i32 %11, i32* %12
%13 = load i32, i32* %6
%14 = srem i32 %13, 1000
%15 = mul nsw i32 %14, 1000
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
store i32 %15, i32* %16
%17 = load %struct.timeval*, %struct.timeval** %4
%18 = load %struct.timeval*, %struct.timeval** %5
%19 = call i32 @timeradd(%struct.timeval* %17, %struct.timeval* %7, %struct.timeval* %18)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @initTimers(%struct.timeval* %0, %struct.timeval* %1, i32 %2) {
%4 = alloca %struct.timeval
%5 = tail call i32 @gettimeofday(%struct.timeval* %0, i32* null)
%6 = bitcast %struct.timeval* %4 to i8*
%7 = sdiv i32 %2, 1000
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
store i32 %7, i32* %8
%9 = srem i32 %2, 1000
%10 = mul nsw i32 %9, 1000
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
store i32 %10, i32* %11
%12 = call i32 @timeradd(%struct.timeval* %0, %struct.timeval* %4, %struct.timeval* %1)
ret void
}