#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*/ delay(int);
void wait_BF(void) {
  (*((volatile unsigned long *)0xE0028004)) = 0x00400000;
  (*((volatile unsigned long *)0xE0028018)) &= ~0x00FF0000;
  (*((volatile unsigned long *)0xE002801C)) = 0x01000000;
  (*((volatile unsigned long *)0xE0028014)) = 0x02000000;
  delay(2);
  while ((*((volatile unsigned long *)0xE0028010)) & 0x00800000)
    ;
  (*((volatile unsigned long *)0xE002801C)) = 0x02000000;
  (*((volatile unsigned long *)0xE0028018)) |= 0x00FF0000;
  (*((volatile unsigned long *)0xE002800C)) = 0x00400000;
}


x86 assembly (clang, -O0):
<wait_BF>:
push   %rbp
mov    %rsp,%rbp
mov    $0xe0028004,%eax
movq   $0x400000,(%rax)
mov    $0xe0028018,%eax
mov    (%rax),%rcx
and    $0xffffffffff00ffff,%rcx
mov    $0xe0028018,%eax
mov    %rcx,(%rax)
mov    $0xe002801c,%eax
movq   $0x1000000,(%rax)
mov    $0xe0028014,%eax
movq   $0x2000000,(%rax)
mov    $0x2,%edi
call   1030 <delay@plt>
mov    $0xe0028010,%eax
mov    (%rax),%rax
and    $0x800000,%rax
cmp    $0x0,%rax
je     1176 <wait_BF+0x66>
jmp    1159 <wait_BF+0x49>
mov    $0xe002801c,%eax
movq   $0x2000000,(%rax)
mov    $0xe0028018,%eax
mov    (%rax),%rcx
or     $0xff0000,%rcx
mov    $0xe0028018,%eax
mov    %rcx,(%rax)
mov    $0xe002800c,%eax
movq   $0x400000,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<wait_BF>:
push   %rbx
mov    $0xe0028018,%ebx
movq   $0x400000,-0x14(%rbx)
andq   $0xffffffffff00ffff,(%rbx)
movq   $0x1000000,0x4(%rbx)
01
movq   $0x2000000,-0x4(%rbx)
02
mov    $0x2,%edi
call   1030 <delay@plt>
nop
testq  $0x800000,-0x8(%rbx)
jne    1140 <wait_BF+0x30>
movq   $0x2000000,0x4(%rbx)
02
orq    $0xff0000,(%rbx)
movq   $0x400000,-0xc(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @wait_BF() {
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
%1 = load volatile i64, i64* inttoptr (i64 3758260248 to i64*)
%2 = and i64 %1, -16711681
store volatile i64 %2, i64* inttoptr (i64 3758260248 to i64*)
store volatile i64 16777216, i64* inttoptr (i64 3758260252 to i64*)
store volatile i64 33554432, i64* inttoptr (i64 3758260244 to i64*)
%3 = call i32 @delay(i32 2)
br label %4
4: ; preds = %8, %0
%5 = load volatile i64, i64* inttoptr (i64 3758260240 to i64*)
%6 = and i64 %5, 8388608
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %4
br label %4
9: ; preds = %4
store volatile i64 33554432, i64* inttoptr (i64 3758260252 to i64*)
%10 = load volatile i64, i64* inttoptr (i64 3758260248 to i64*)
%11 = or i64 %10, 16711680
store volatile i64 %11, i64* inttoptr (i64 3758260248 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
ret void
}

LLVM IR (-O2):
define void @wait_BF() {
store volatile i64 4194304, i64* inttoptr (i64 3758260228 to i64*)
%1 = load volatile i64, i64* inttoptr (i64 3758260248 to i64*)
%2 = and i64 %1, -16711681
store volatile i64 %2, i64* inttoptr (i64 3758260248 to i64*)
store volatile i64 16777216, i64* inttoptr (i64 3758260252 to i64*)
store volatile i64 33554432, i64* inttoptr (i64 3758260244 to i64*)
%3 = tail call i32 @delay(i32 2)
br label %4
4: ; preds = %4, %0
%5 = load volatile i64, i64* inttoptr (i64 3758260240 to i64*)
%6 = and i64 %5, 8388608
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %4
8: ; preds = %4
store volatile i64 33554432, i64* inttoptr (i64 3758260252 to i64*)
%9 = load volatile i64, i64* inttoptr (i64 3758260248 to i64*)
%10 = or i64 %9, 16711680
store volatile i64 %10, i64* inttoptr (i64 3758260248 to i64*)
store volatile i64 4194304, i64* inttoptr (i64 3758260236 to i64*)
ret void
}