#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 UART_LSR;
unsigned char UART_LSR_TEMT;
unsigned char UART_LSR_THRE;
int /*<<< orphan*/ barrier();
void flush(void) {
  unsigned char v, *base = ((unsigned char *)0xf0000be0);
  do {
    v = base[UART_LSR << 2];
    barrier();
  } while ((v & (UART_LSR_TEMT | UART_LSR_THRE)) !=
           (UART_LSR_TEMT | UART_LSR_THRE));
}


x86 assembly (clang, -O0):
<flush>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xf0000be0,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2eac(%rip),%rcx
mov    (%rcx),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1(%rbp)
mov    $0x0,%al
call   1030 <barrier@plt>
movzbl -0x1(%rbp),%eax
mov    0x2e84(%rip),%rcx
movzbl (%rcx),%ecx
mov    0x2e92(%rip),%rdx
movzbl (%rdx),%edx
or     %edx,%ecx
and    %ecx,%eax
mov    0x2e6c(%rip),%rcx
movzbl (%rcx),%ecx
mov    0x2e7a(%rip),%rdx
movzbl (%rdx),%edx
or     %edx,%ecx
cmp    %ecx,%eax
jne    1121 <flush+0x11>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flush>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2eb8(%rip),%r14
mov    $0xf0000be0,%r15d
mov    0x2ea3(%rip),%r12
mov    0x2eb4(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%eax
shl    $0x2,%eax
cltq
movzbl (%rax,%r15,1),%ebx
xor    %eax,%eax
call   1030 <barrier@plt>
movzbl 0x0(%r13),%eax
or     (%r12),%al
not    %bl
test   %bl,%al
jne    1140 <flush+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@UART_LSR = global i32 0
@UART_LSR_TEMT = global i8 0
@UART_LSR_THRE = global i8 0
define void @flush() {
%1 = alloca i8
%2 = alloca i8*
store i8* inttoptr (i64 4026534880 to i8*), i8** %2
br label %3
3: ; preds = %11, %0
%4 = load i8*, i8** %2
%5 = load i32, i32* @UART_LSR
%6 = shl i32 %5, 2
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %4, i64 %7
%9 = load i8, i8* %8
store i8 %9, i8* %1
%10 = call i32 (...) @barrier()
br label %11
11: ; preds = %3
%12 = load i8, i8* %1
%13 = zext i8 %12 to i32
%14 = load i8, i8* @UART_LSR_TEMT
%15 = zext i8 %14 to i32
%16 = load i8, i8* @UART_LSR_THRE
%17 = zext i8 %16 to i32
%18 = or i32 %15, %17
%19 = and i32 %13, %18
%20 = load i8, i8* @UART_LSR_TEMT
%21 = zext i8 %20 to i32
%22 = load i8, i8* @UART_LSR_THRE
%23 = zext i8 %22 to i32
%24 = or i32 %21, %23
%25 = icmp ne i32 %19, %24
br i1 %25, label %3, label %26
26: ; preds = %11
ret void
}

LLVM IR (-O2):
@UART_LSR = global i32 0
@UART_LSR_TEMT = global i8 0
@UART_LSR_THRE = global i8 0
define void @flush() {
br label %1
1: ; preds = %1, %0
%2 = load i32, i32* @UART_LSR
%3 = shl i32 %2, 2
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* inttoptr (i64 4026534880 to i8*), i64 %4
%6 = load i8, i8* %5
%7 = tail call i32 (...) @barrier()
%8 = load i8, i8* @UART_LSR_TEMT
%9 = load i8, i8* @UART_LSR_THRE
%10 = or i8 %9, %8
%11 = and i8 %10, %6
%12 = icmp eq i8 %11, %10
br i1 %12, label %13, label %1
13: ; preds = %1
ret void
}