#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__ uint8_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
uint32_t EPINonBlockingReadGet8(uint32_t ui32Base, uint32_t ui32Count,
                                uint8_t *pui8Buf) {
  uint32_t ui32CountRead = 0;
  ;
  ;
  ;
  while ((*((volatile uint32_t *)(ui32Base + 0x0000006C))) && ui32Count--) {
    *pui8Buf = (uint8_t)(*((volatile uint32_t *)(ui32Base + 0x00000070)));
    pui8Buf++;
    ui32CountRead++;
  }
  return (ui32CountRead);
}


x86 assembly (clang, -O0):
<EPINonBlockingReadGet8>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x6c(%rax),%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
je     1148 <EPINonBlockingReadGet8+0x48>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1158 <EPINonBlockingReadGet8+0x58>
jmp    1184 <EPINonBlockingReadGet8+0x84>
mov    -0x8(%rbp),%rax
mov    0x70(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1118 <EPINonBlockingReadGet8+0x18>
mov    -0x20(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<EPINonBlockingReadGet8>:
xor    %eax,%eax
cmpq   $0x0,0x6c(%rdi)
je     113b <EPINonBlockingReadGet8+0x3b>
test   %rsi,%rsi
je     113b <EPINonBlockingReadGet8+0x3b>
add    $0xffffffffffffffff,%rsi
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x70(%rdi),%rax
mov    %rax,(%rdx,%rcx,8)
lea    0x1(%rcx),%rax
cmpq   $0x0,0x6c(%rdi)
je     113b <EPINonBlockingReadGet8+0x3b>
cmp    %rcx,%rsi
mov    %rax,%rcx
jne    1120 <EPINonBlockingReadGet8+0x20>
ret

LLVM IR (-O0):
define i64 @EPINonBlockingReadGet8(i64 %0, i64 %1, i64* %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64*
%7 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64* %2, i64** %6
store i64 0, i64* %7
br label %8
8: ; preds = %20, %3
%9 = load i64, i64* %4
%10 = add nsw i64 %9, 108
%11 = inttoptr i64 %10 to i64*
%12 = load volatile i64, i64* %11
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = load i64, i64* %5
%16 = add nsw i64 %15, -1
store i64 %16, i64* %5
%17 = icmp ne i64 %15, 0
br label %18
18: ; preds = %14, %8
%19 = phi i1 [ false, %8 ], [ %17, %14 ]
br i1 %19, label %20, label %30
20: ; preds = %18
%21 = load i64, i64* %4
%22 = add nsw i64 %21, 112
%23 = inttoptr i64 %22 to i64*
%24 = load volatile i64, i64* %23
%25 = load i64*, i64** %6
store i64 %24, i64* %25
%26 = load i64*, i64** %6
%27 = getelementptr inbounds i64, i64* %26, i32 1
store i64* %27, i64** %6
%28 = load i64, i64* %7
%29 = add nsw i64 %28, 1
store i64 %29, i64* %7
br label %8
30: ; preds = %18
%31 = load i64, i64* %7
ret i64 %31
}

LLVM IR (-O2):
define i64 @EPINonBlockingReadGet8(i64 %0, i64 %1, i64* nocapture writeonly %2) {
%4 = add nsw i64 %0, 108
%5 = inttoptr i64 %4 to i64*
%6 = load volatile i64, i64* %5
%7 = icmp eq i64 %6, 0
%8 = icmp eq i64 %1, 0
%9 = or i1 %7, %8
br i1 %9, label %25, label %10
10: ; preds = %3
%11 = add nsw i64 %0, 112
%12 = inttoptr i64 %11 to i64*
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %20, %13 ]
%15 = phi i64* [ %2, %10 ], [ %19, %13 ]
%16 = phi i64 [ %1, %10 ], [ %17, %13 ]
%17 = add nsw i64 %16, -1
%18 = load volatile i64, i64* %12
store i64 %18, i64* %15
%19 = getelementptr inbounds i64, i64* %15, i64 1
%20 = add nuw nsw i64 %14, 1
%21 = load volatile i64, i64* %5
%22 = icmp eq i64 %21, 0
%23 = icmp eq i64 %17, 0
%24 = select i1 %22, i1 true, i1 %23
br i1 %24, label %25, label %13
25: ; preds = %13, %3
%26 = phi i64 [ 0, %3 ], [ %20, %13 ]
ret i64 %26
}