#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 int uint64_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int /*<<< orphan*/);
int /*<<< orphan*/ _TimerBaseValid(scalar_t__);
uint64_t TimerValueGet64(uint32_t ui32Base) {
  uint32_t ui32High1, ui32High2, ui32Low;
  ASSERT(_TimerBaseValid(ui32Base));
  do {
    ui32High1 = (*((volatile uint32_t *)(ui32Base + 0x0000004C)));
    ui32Low = (*((volatile uint32_t *)(ui32Base + 0x00000048)));
    ui32High2 = (*((volatile uint32_t *)(ui32Base + 0x0000004C)));
  } while (ui32High1 != ui32High2);
  return (((uint64_t)ui32High1 << 32) | (uint64_t)ui32Low);
}


x86 assembly (clang, -O0):
<TimerValueGet64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <_TimerBaseValid@plt>
mov    %eax,%edi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%rax
mov    0x4c(%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x48(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4c(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    113c <TimerValueGet64+0x1c>
mov    -0x10(%rbp),%rax
mov    $0x20,%ecx
shl    %cl,%eax
mov    -0x20(%rbp),%rcx
or     %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerValueGet64>:
push   %rbx
mov    %rdi,%rbx
call   1040 <_TimerBaseValid@plt>
mov    %eax,%edi
call   1030 <ASSERT@plt>
mov    0x4c(%rbx),%rax
mov    0x48(%rbx),%rcx
cmp    0x4c(%rbx),%rax
jne    1130 <TimerValueGet64+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define i32 @TimerValueGet64(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 @ASSERT(i32 %7)
br label %9
9: ; preds = %22, %1
%10 = load i64, i64* %2
%11 = add nsw i64 %10, 76
%12 = inttoptr i64 %11 to i64*
%13 = load volatile i64, i64* %12
store i64 %13, i64* %3
%14 = load i64, i64* %2
%15 = add nsw i64 %14, 72
%16 = inttoptr i64 %15 to i64*
%17 = load volatile i64, i64* %16
store i64 %17, i64* %5
%18 = load i64, i64* %2
%19 = add nsw i64 %18, 76
%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 = trunc i64 %27 to i32
%29 = shl i32 %28, 32
%30 = load i64, i64* %5
%31 = trunc i64 %30 to i32
%32 = or i32 %29, %31
ret i32 %32
}

LLVM IR (-O2):
define i32 @TimerValueGet64(i64 %0) {
%2 = tail call i32 @_TimerBaseValid(i64 %0)
%3 = tail call i32 @ASSERT(i32 %2)
%4 = add nsw i64 %0, 76
%5 = inttoptr i64 %4 to i64*
%6 = add nsw i64 %0, 72
%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
ret i32 poison
}