#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*/ RamRead32A(int, unsigned long *);
int /*<<< orphan*/ RamWrite32A(int, int);
int /*<<< orphan*/ WitTim(int);
unsigned char ReadWPB(void) {
  unsigned long UlReadVal, UlCnt = 0;
  do {
    RamWrite32A(0xC000, 0xD00104);
    RamRead32A(0xD000, &UlReadVal);
    if ((UlReadVal & 0x0400) != 0)
      return (1);
    WitTim(1);
  } while (UlCnt++ < 10);
  return (0);
}


x86 assembly (clang, -O0):
<ReadWPB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x18(%rbp)
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
mov    $0xd000,%edi
lea    -0x10(%rbp),%rsi
call   1030 <RamRead32A@plt>
mov    -0x10(%rbp),%rax
and    $0x400,%rax
cmp    $0x0,%rax
je     117a <ReadWPB+0x4a>
movb   $0x1,-0x1(%rbp)
jmp    11a1 <ReadWPB+0x71>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0xa,%rax
jb     1140 <ReadWPB+0x10>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadWPB>:
push   %rbx
sub    $0x10,%rsp
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
mov    $0x1,%bl
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
mov    $0xc000,%edi
mov    $0xd00104,%esi
call   1040 <RamWrite32A@plt>
lea    0x8(%rsp),%rsi
mov    $0xd000,%edi
call   1030 <RamRead32A@plt>
testb  $0x4,0x9(%rsp)
jne    135e <ReadWPB+0x22e>
mov    $0x1,%edi
call   1050 <WitTim@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define zeroext i8 @ReadWPB() {
%1 = alloca i8
%2 = alloca i64
%3 = alloca i64
store i64 0, i64* %3
br label %4
4: ; preds = %13, %0
%5 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%6 = call i32 @RamRead32A(i32 53248, i64* %2)
%7 = load i64, i64* %2
%8 = and i64 %7, 1024
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %4
store i8 1, i8* %1
br label %18
11: ; preds = %4
%12 = call i32 @WitTim(i32 1)
br label %13
13: ; preds = %11
%14 = load i64, i64* %3
%15 = add i64 %14, 1
store i64 %15, i64* %3
%16 = icmp ult i64 %14, 10
br i1 %16, label %4, label %17
17: ; preds = %13
store i8 0, i8* %1
br label %18
18: ; preds = %17, %10
%19 = load i8, i8* %1
ret i8 %19
}

LLVM IR (-O2):
define zeroext i8 @ReadWPB() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%4 = call i32 @RamRead32A(i32 53248, i64* %1)
%5 = load i64, i64* %1
%6 = and i64 %5, 1024
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %80
8: ; preds = %0
%9 = call i32 @WitTim(i32 1)
%10 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%11 = call i32 @RamRead32A(i32 53248, i64* %1)
%12 = load i64, i64* %1
%13 = and i64 %12, 1024
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %80
15: ; preds = %8
%16 = call i32 @WitTim(i32 1)
%17 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%18 = call i32 @RamRead32A(i32 53248, i64* %1)
%19 = load i64, i64* %1
%20 = and i64 %19, 1024
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %80
22: ; preds = %15
%23 = call i32 @WitTim(i32 1)
%24 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%25 = call i32 @RamRead32A(i32 53248, i64* %1)
%26 = load i64, i64* %1
%27 = and i64 %26, 1024
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %80
29: ; preds = %22
%30 = call i32 @WitTim(i32 1)
%31 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%32 = call i32 @RamRead32A(i32 53248, i64* %1)
%33 = load i64, i64* %1
%34 = and i64 %33, 1024
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %80
36: ; preds = %29
%37 = call i32 @WitTim(i32 1)
%38 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%39 = call i32 @RamRead32A(i32 53248, i64* %1)
%40 = load i64, i64* %1
%41 = and i64 %40, 1024
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %80
43: ; preds = %36
%44 = call i32 @WitTim(i32 1)
%45 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%46 = call i32 @RamRead32A(i32 53248, i64* %1)
%47 = load i64, i64* %1
%48 = and i64 %47, 1024
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %80
50: ; preds = %43
%51 = call i32 @WitTim(i32 1)
%52 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%53 = call i32 @RamRead32A(i32 53248, i64* %1)
%54 = load i64, i64* %1
%55 = and i64 %54, 1024
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %80
57: ; preds = %50
%58 = call i32 @WitTim(i32 1)
%59 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%60 = call i32 @RamRead32A(i32 53248, i64* %1)
%61 = load i64, i64* %1
%62 = and i64 %61, 1024
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %80
64: ; preds = %57
%65 = call i32 @WitTim(i32 1)
%66 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%67 = call i32 @RamRead32A(i32 53248, i64* %1)
%68 = load i64, i64* %1
%69 = and i64 %68, 1024
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %80
71: ; preds = %64
%72 = call i32 @WitTim(i32 1)
%73 = call i32 @RamWrite32A(i32 49152, i32 13631748)
%74 = call i32 @RamRead32A(i32 53248, i64* %1)
%75 = load i64, i64* %1
%76 = and i64 %75, 1024
%77 = icmp eq i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %71
%79 = call i32 @WitTim(i32 1)
br label %80
80: ; preds = %78, %71, %64, %57, %50, %43, %36, %29, %22, %15, %8, %0
%81 = phi i8 [ 1, %0 ], [ 1, %8 ], [ 1, %15 ], [ 1, %22 ], [ 1, %29 ], [ 1, %36 ], [ 1, %43 ], [ 1, %50 ], [ 1, %57 ], [ 1, %64 ], [ 1, %71 ], [ 0, %78 ]
ret i8 %81
}