#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*/ sev_time_now(long *, long *);
void sev_time_add2now(long long time_ms, long *sec, long *msec) {
  sev_time_now(sec, msec);
  *sec += time_ms / 1000;
  *msec += time_ms % 1000;
  if (*msec > 1000) {
    *sec += 1;
    *msec -= 1000;
  }
}


x86 assembly (clang, -O0):
<sev_time_add2now>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <sev_time_now@plt>
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
add    (%rax),%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    -0x18(%rbp),%rax
add    (%rax),%rdx
mov    %rdx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x3e8,(%rax)
jle    1194 <sev_time_add2now+0x84>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
sub    $0x3e8,%rcx
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sev_time_add2now>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1030 <sev_time_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
add    %rdx,(%r14)
imul   $0x3e8,%rdx,%rax
sub    %rax,%rbx
add    (%r15),%rbx
mov    %rbx,(%r15)
cmp    $0x3e9,%rbx
jl     116e <sev_time_add2now+0x5e>
addq   $0x1,(%r14)
addq   $0xfffffffffffffc18,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @sev_time_add2now(i64 %0, i64* %1, i64* %2) {
%4 = tail call i32 @sev_time_now(i64* %1, i64* %2)
%5 = sdiv i64 %0, 1000
%6 = load i64, i64* %1
%7 = add nsw i64 %6, %5
store i64 %7, i64* %1
%8 = srem i64 %0, 1000
%9 = load i64, i64* %2
%10 = add nsw i64 %9, %8
store i64 %10, i64* %2
%11 = icmp sgt i64 %10, 1000
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i64, i64* %1
%14 = add nsw i64 %13, 1
store i64 %14, i64* %1
%15 = load i64, i64* %2
%16 = add nsw i64 %15, -1000
store i64 %16, i64* %2
br label %17
17: ; preds = %12, %3
ret void
}