#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 */
unsigned short data_bus_test_r();
int /*<<< orphan*/ data_bus_test_w(int);
unsigned short data_retent_r();
int /*<<< orphan*/ data_retent_w(int);
int self_test(void) {
  unsigned short int indataaax, indata55x, indataaay, indata55y, error;
  error = 0;
  data_retent_w(0x5500);
  data_bus_test_w(0xaa55);
  indata55x = data_retent_r();
  indataaax = data_bus_test_r();
  data_retent_w(0xaa00);
  data_bus_test_w(0x55aa);
  indataaay = data_retent_r();
  indata55y = data_bus_test_r();
  if ((indata55x != 0x5500) || (indataaax != 0xaa55) || (indataaay != 0xaa00) ||
      (indata55y != 0x55aa)) {
    error = 1;
  }
  return error;
}


x86 assembly (clang, -O0):
<self_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movw   $0x0,-0xa(%rbp)
mov    $0x5500,%edi
call   1050 <data_retent_w@plt>
mov    $0xaa55,%edi
call   1060 <data_bus_test_w@plt>
mov    $0x0,%al
call   1030 <data_retent_r@plt>
mov    %ax,-0x4(%rbp)
mov    $0x0,%al
call   1040 <data_bus_test_r@plt>
mov    %ax,-0x2(%rbp)
mov    $0xaa00,%edi
call   1050 <data_retent_w@plt>
mov    $0x55aa,%edi
call   1060 <data_bus_test_w@plt>
mov    $0x0,%al
call   1030 <data_retent_r@plt>
mov    %ax,-0x6(%rbp)
mov    $0x0,%al
call   1040 <data_bus_test_r@plt>
mov    %ax,-0x8(%rbp)
movzwl -0x4(%rbp),%eax
cmp    $0x5500,%eax
jne    11de <self_test+0x9e>
movzwl -0x2(%rbp),%eax
cmp    $0xaa55,%eax
jne    11de <self_test+0x9e>
movzwl -0x6(%rbp),%eax
cmp    $0xaa00,%eax
jne    11de <self_test+0x9e>
movzwl -0x8(%rbp),%eax
cmp    $0x55aa,%eax
je     11e4 <self_test+0xa4>
movw   $0x1,-0xa(%rbp)
movzwl -0xa(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<self_test>:
push   %rbp
push   %r14
push   %rbx
mov    $0x5500,%edi
call   1050 <data_retent_w@plt>
mov    $0xaa55,%edi
call   1060 <data_bus_test_w@plt>
xor    %eax,%eax
call   1030 <data_retent_r@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <data_bus_test_r@plt>
mov    %eax,%ebp
mov    $0xaa00,%edi
call   1050 <data_retent_w@plt>
mov    $0x55aa,%edi
call   1060 <data_bus_test_w@plt>
xor    %eax,%eax
call   1030 <data_retent_r@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <data_bus_test_r@plt>
xor    $0x5500,%r14d
xor    $0xffffaa55,%ebp
or     %r14d,%ebp
xor    $0xffffaa00,%ebx
or     %ebp,%ebx
xor    $0x55aa,%eax
xor    %ecx,%ecx
or     %bx,%ax
setne  %cl
mov    %ecx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @self_test() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
store i16 0, i16* %5
%6 = call i32 @data_retent_w(i32 21760)
%7 = call i32 @data_bus_test_w(i32 43605)
%8 = call zeroext i16 (...) @data_retent_r()
store i16 %8, i16* %2
%9 = call zeroext i16 (...) @data_bus_test_r()
store i16 %9, i16* %1
%10 = call i32 @data_retent_w(i32 43520)
%11 = call i32 @data_bus_test_w(i32 21930)
%12 = call zeroext i16 (...) @data_retent_r()
store i16 %12, i16* %3
%13 = call zeroext i16 (...) @data_bus_test_r()
store i16 %13, i16* %4
%14 = load i16, i16* %2
%15 = zext i16 %14 to i32
%16 = icmp ne i32 %15, 21760
br i1 %16, label %29, label %17
17: ; preds = %0
%18 = load i16, i16* %1
%19 = zext i16 %18 to i32
%20 = icmp ne i32 %19, 43605
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = load i16, i16* %3
%23 = zext i16 %22 to i32
%24 = icmp ne i32 %23, 43520
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i16, i16* %4
%27 = zext i16 %26 to i32
%28 = icmp ne i32 %27, 21930
br i1 %28, label %29, label %30
29: ; preds = %25, %21, %17, %0
store i16 1, i16* %5
br label %30
30: ; preds = %29, %25
%31 = load i16, i16* %5
%32 = zext i16 %31 to i32
ret i32 %32
}

LLVM IR (-O2):
define i32 @self_test() {
%1 = tail call i32 @data_retent_w(i32 21760)
%2 = tail call i32 @data_bus_test_w(i32 43605)
%3 = tail call zeroext i16 (...) @data_retent_r()
%4 = tail call zeroext i16 (...) @data_bus_test_r()
%5 = tail call i32 @data_retent_w(i32 43520)
%6 = tail call i32 @data_bus_test_w(i32 21930)
%7 = tail call zeroext i16 (...) @data_retent_r()
%8 = tail call zeroext i16 (...) @data_bus_test_r()
%9 = icmp ne i16 %3, 21760
%10 = icmp ne i16 %4, -21931
%11 = select i1 %9, i1 true, i1 %10
%12 = icmp ne i16 %7, -22016
%13 = select i1 %11, i1 true, i1 %12
%14 = icmp ne i16 %8, 21930
%15 = select i1 %13, i1 true, i1 %14
%16 = zext i1 %15 to i32
ret i32 %16
}