#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 */
typedef scalar_t__ time_t;
struct timeval {
  scalar_t__ tv_sec;
  long tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
long GetTickCount(void) {
  static time_t initial_time = 0;
  struct timeval now;
  gettimeofday(&now, NULL);
  if (initial_time == 0) {
    initial_time = now.tv_sec;
  }
  return (now.tv_sec - initial_time) * 1000L + now.tv_usec / 1000L;
}


x86 assembly (clang, -O0):
<GetTickCount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
cmpq   $0x0,0x2f03(%rip)
jne    113e <GetTickCount+0x2e>
mov    -0x10(%rbp),%rax
mov    %rax,0x2ef2(%rip)
mov    -0x10(%rbp),%rax
sub    0x2ee7(%rip),%rax
imul   $0x3e8,%rax,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
add    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetTickCount>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x2f09(%rip),%rcx
mov    0x8(%rsp),%rax
test   %rcx,%rcx
jne    113b <GetTickCount+0x2b>
mov    %rax,0x2ef8(%rip)
mov    %rax,%rcx
sub    %rcx,%rax
imul   $0x3e8,%rax,%rcx
movabs $0x20c49ba5e353f7cf,%rax
9b c4 20
imulq  0x10(%rsp)
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x7,%rdx
add    %rdx,%rax
add    %rcx,%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
@GetTickCount.initial_time = internal global i64 0
define i64 @GetTickCount() {
%1 = alloca %struct.timeval
%2 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%3 = load i64, i64* @GetTickCount.initial_time
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%7 = load i64, i64* %6
store i64 %7, i64* @GetTickCount.initial_time
br label %8
8: ; preds = %5, %0
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%10 = load i64, i64* %9
%11 = load i64, i64* @GetTickCount.initial_time
%12 = sub nsw i64 %10, %11
%13 = mul nsw i64 %12, 1000
%14 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%15 = load i64, i64* %14
%16 = sdiv i64 %15, 1000
%17 = add nsw i64 %13, %16
ret i64 %17
}

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
@GetTickCount.initial_time = internal unnamed_addr global i64 0
define i64 @GetTickCount() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%4 = load i64, i64* @GetTickCount.initial_time
%5 = icmp eq i64 %4, 0
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%7 = load i64, i64* %6
br i1 %5, label %8, label %9
8: ; preds = %0
store i64 %7, i64* @GetTickCount.initial_time
br label %9
9: ; preds = %0, %8
%10 = phi i64 [ %7, %8 ], [ %4, %0 ]
%11 = sub nsw i64 %7, %10
%12 = mul nsw i64 %11, 1000
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%14 = load i64, i64* %13
%15 = sdiv i64 %14, 1000
%16 = add nsw i64 %12, %15
ret i64 %16
}