#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*/ NullCheck(unsigned long *);
int clock_updateUptimeMillis(unsigned long millis, unsigned long *lastMillis,
                             unsigned long *delta) {
  NullCheck(lastMillis);
  NullCheck(delta);
  *delta = 0;
  if (*lastMillis == millis)
    return 0;
  if (millis < (*lastMillis)) {
    *delta = (~(0UL)) - (*lastMillis) + 1 + millis;
  } else {
    *delta = millis - (*lastMillis);
  }
  *lastMillis = millis;
  return 0;
}


x86 assembly (clang, -O0):
<clock_updateUptimeMillis>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <NullCheck@plt>
mov    -0x20(%rbp),%rdi
call   1030 <NullCheck@plt>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
cmp    -0x10(%rbp),%rax
jne    115e <clock_updateUptimeMillis+0x4e>
movl   $0x0,-0x4(%rbp)
jmp    11b5 <clock_updateUptimeMillis+0xa5>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jae    1191 <clock_updateUptimeMillis+0x81>
mov    -0x18(%rbp),%rax
mov    $0xffffffffffffffff,%rcx
sub    (%rax),%rcx
add    $0x1,%rcx
add    -0x10(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    11a3 <clock_updateUptimeMillis+0x93>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clock_updateUptimeMillis>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
call   1030 <NullCheck@plt>
mov    %r14,%rdi
call   1030 <NullCheck@plt>
movq   $0x0,(%r14)
mov    (%rbx),%rax
cmp    %r15,%rax
je     1149 <clock_updateUptimeMillis+0x39>
mov    %r15,%rcx
sub    %rax,%rcx
mov    %rcx,(%r14)
mov    %r15,(%rbx)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @clock_updateUptimeMillis(i64 %0, i64* %1, i64* %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64*
%7 = alloca i64*
store i64 %0, i64* %5
store i64* %1, i64** %6
store i64* %2, i64** %7
%8 = load i64*, i64** %6
%9 = call i32 @NullCheck(i64* %8)
%10 = load i64*, i64** %7
%11 = call i32 @NullCheck(i64* %10)
%12 = load i64*, i64** %7
store i64 0, i64* %12
%13 = load i64*, i64** %6
%14 = load i64, i64* %13
%15 = load i64, i64* %5
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %3
store i32 0, i32* %4
br label %40
18: ; preds = %3
%19 = load i64, i64* %5
%20 = load i64*, i64** %6
%21 = load i64, i64* %20
%22 = icmp ult i64 %19, %21
br i1 %22, label %23, label %31
23: ; preds = %18
%24 = load i64*, i64** %6
%25 = load i64, i64* %24
%26 = sub i64 -1, %25
%27 = add i64 %26, 1
%28 = load i64, i64* %5
%29 = add i64 %27, %28
%30 = load i64*, i64** %7
store i64 %29, i64* %30
br label %37
31: ; preds = %18
%32 = load i64, i64* %5
%33 = load i64*, i64** %6
%34 = load i64, i64* %33
%35 = sub i64 %32, %34
%36 = load i64*, i64** %7
store i64 %35, i64* %36
br label %37
37: ; preds = %31, %23
%38 = load i64, i64* %5
%39 = load i64*, i64** %6
store i64 %38, i64* %39
store i32 0, i32* %4
br label %40
40: ; preds = %37, %17
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
define i32 @clock_updateUptimeMillis(i64 %0, i64* %1, i64* %2) {
%4 = tail call i32 @NullCheck(i64* %1)
%5 = tail call i32 @NullCheck(i64* %2)
store i64 0, i64* %2
%6 = load i64, i64* %1
%7 = icmp eq i64 %6, %0
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = sub i64 %0, %6
store i64 %9, i64* %2
store i64 %0, i64* %1
br label %10
10: ; preds = %3, %8
ret i32 0
}