#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*/ DEBUG_ASSERT(int /*<<< orphan*/);
int /*<<< orphan*/ TimerBaseValid(unsigned long);
unsigned long long TimerLoadGet64(unsigned long ulBase) {
  unsigned long ulHigh1, ulHigh2, ulLow;
  DEBUG_ASSERT(TimerBaseValid(ulBase));
  do {
    ulHigh1 = (*((volatile unsigned long *)(ulBase + 0x0000002C)));
    ulLow = (*((volatile unsigned long *)(ulBase + 0x00000028)));
    ulHigh2 = (*((volatile unsigned long *)(ulBase + 0x0000002C)));
  } while (ulHigh1 != ulHigh2);
  return (((unsigned long long)ulHigh1 << 32) | (unsigned long long)ulLow);
}


x86 assembly (clang, -O0):
<TimerLoadGet64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <TimerBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rax
mov    0x2c(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2c(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    113c <TimerLoadGet64+0x1c>
mov    -0x10(%rbp),%rax
shl    $0x20,%rax
or     -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerLoadGet64>:
push   %rbx
mov    %rdi,%rbx
call   1030 <TimerBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    0x2c(%rbx),%rax
mov    0x28(%rbx),%rcx
cmp    0x2c(%rbx),%rax
jne    1130 <TimerLoadGet64+0x10>
shl    $0x20,%rax
or     %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @TimerLoadGet64(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %2
%6 = load i64, i64* %2
%7 = call i32 @TimerBaseValid(i64 %6)
%8 = call i32 @DEBUG_ASSERT(i32 %7)
br label %9
9: ; preds = %22, %1
%10 = load i64, i64* %2
%11 = add i64 %10, 44
%12 = inttoptr i64 %11 to i64*
%13 = load volatile i64, i64* %12
store i64 %13, i64* %3
%14 = load i64, i64* %2
%15 = add i64 %14, 40
%16 = inttoptr i64 %15 to i64*
%17 = load volatile i64, i64* %16
store i64 %17, i64* %5
%18 = load i64, i64* %2
%19 = add i64 %18, 44
%20 = inttoptr i64 %19 to i64*
%21 = load volatile i64, i64* %20
store i64 %21, i64* %4
br label %22
22: ; preds = %9
%23 = load i64, i64* %3
%24 = load i64, i64* %4
%25 = icmp ne i64 %23, %24
br i1 %25, label %9, label %26
26: ; preds = %22
%27 = load i64, i64* %3
%28 = shl i64 %27, 32
%29 = load i64, i64* %5
%30 = or i64 %28, %29
ret i64 %30
}

LLVM IR (-O2):
define i64 @TimerLoadGet64(i64 %0) {
%2 = tail call i32 @TimerBaseValid(i64 %0)
%3 = tail call i32 @DEBUG_ASSERT(i32 %2)
%4 = add i64 %0, 44
%5 = inttoptr i64 %4 to i64*
%6 = add i64 %0, 40
%7 = inttoptr i64 %6 to i64*
br label %8
8: ; preds = %8, %1
%9 = load volatile i64, i64* %5
%10 = load volatile i64, i64* %7
%11 = load volatile i64, i64* %5
%12 = icmp eq i64 %9, %11
br i1 %12, label %13, label %8
13: ; preds = %8
%14 = shl i64 %9, 32
%15 = or i64 %14, %10
ret i64 %15
}