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

/* Variables and functions */
int /*<<< orphan*/ rr_dt_now(long *, long *);
void rr_dt_expire_at(long long delta, long *sec, long *ms) {
  long now_sec, now_ms, utl_sec, utl_ms;
  rr_dt_now(&now_sec, &now_ms);
  utl_sec = now_sec + delta / 1000;
  utl_ms = now_ms + delta % 1000;
  if (utl_ms >= 1000) {
    utl_sec++;
    utl_ms -= 1000;
  }
  *sec = utl_sec;
  *ms = utl_ms;
}


x86 assembly (clang, -O0):
<rr_dt_expire_at>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <rr_dt_now@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    -0x40(%rbp),%rax
add    %rdx,%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x3e8,-0x38(%rbp)
jl     119e <rr_dt_expire_at+0x8e>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
sub    $0x3e8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rr_dt_expire_at>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <rr_dt_now@plt>
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mov    %rbx,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x7,%rdx
add    %rax,%rdx
imul   $0x3e8,%rdx,%rax
add    0x8(%rsp),%rdx
mov    (%rsp),%rcx
sub    %rax,%rbx
lea    (%rcx,%rbx,1),%rax
xor    %esi,%esi
cmp    $0x3e8,%rax
lea    -0x3e8(%rcx,%rbx,1),%rcx
ff
cmovl  %rax,%rcx
setge  %sil
add    %rdx,%rsi
mov    %rsi,(%r15)
mov    %rcx,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rr_dt_expire_at(i64 %0, i64* %1, i64* %2) {
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
store i64 %0, i64* %4
store i64* %1, i64** %5
store i64* %2, i64** %6
%11 = call i32 @rr_dt_now(i64* %7, i64* %8)
%12 = load i64, i64* %7
%13 = load i64, i64* %4
%14 = sdiv i64 %13, 1000
%15 = add nsw i64 %12, %14
store i64 %15, i64* %9
%16 = load i64, i64* %8
%17 = load i64, i64* %4
%18 = srem i64 %17, 1000
%19 = add nsw i64 %16, %18
store i64 %19, i64* %10
%20 = load i64, i64* %10
%21 = icmp sge i64 %20, 1000
br i1 %21, label %22, label %27
22: ; preds = %3
%23 = load i64, i64* %9
%24 = add nsw i64 %23, 1
store i64 %24, i64* %9
%25 = load i64, i64* %10
%26 = sub nsw i64 %25, 1000
store i64 %26, i64* %10
br label %27
27: ; preds = %22, %3
%28 = load i64, i64* %9
%29 = load i64*, i64** %5
store i64 %28, i64* %29
%30 = load i64, i64* %10
%31 = load i64*, i64** %6
store i64 %30, i64* %31
ret void
}

LLVM IR (-O2):
define void @rr_dt_expire_at(i64 %0, i64* nocapture writeonly %1, i64* nocapture writeonly %2) {
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i64* %4 to i8*
%7 = bitcast i64* %5 to i8*
%8 = call i32 @rr_dt_now(i64* %4, i64* %5)
%9 = load i64, i64* %4
%10 = sdiv i64 %0, 1000
%11 = add nsw i64 %9, %10
%12 = load i64, i64* %5
%13 = srem i64 %0, 1000
%14 = add nsw i64 %12, %13
%15 = icmp sgt i64 %14, 999
%16 = add nsw i64 %14, -1000
%17 = zext i1 %15 to i64
%18 = add nsw i64 %11, %17
%19 = select i1 %15, i64 %16, i64 %14
store i64 %18, i64* %1
store i64 %19, i64* %2
ret void
}