#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*/ tty_puthex(unsigned char);
int /*<<< orphan*/ tty_puts(char *);
void run_test(void) {
  volatile unsigned char *flash = (volatile unsigned char *)0xFFF80000;
  unsigned char info[2];
  tty_puts("FLASH test started\n");
  flash[0x5555] = 0xAA;
  flash[0x2AAA] = 0x55;
  flash[0x5555] = 0x90;
  info[0] = flash[0];
  info[1] = flash[1];
  flash[0x5555] = 0xAA;
  flash[0x2AAA] = 0x55;
  flash[0x5555] = 0xF0;
  tty_puts("FLASH query info = ");
  tty_puthex(info[0] << 8 | info[1]);
  tty_puts("\n");
  tty_puts("Done\n");
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xfff80000,%eax
mov    %rax,-0x8(%rbp)
lea    0xec8(%rip),%rdi
call   1040 <tty_puts@plt>
mov    -0x8(%rbp),%rax
movb   $0xaa,0x5555(%rax)
mov    -0x8(%rbp),%rax
movb   $0x55,0x2aaa(%rax)
mov    -0x8(%rbp),%rax
movb   $0x90,0x5555(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xa(%rbp)
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
movb   $0xaa,0x5555(%rax)
mov    -0x8(%rbp),%rax
movb   $0x55,0x2aaa(%rax)
mov    -0x8(%rbp),%rax
movb   $0xf0,0x5555(%rax)
lea    0xe7b(%rip),%rdi
call   1040 <tty_puts@plt>
movzbl -0xa(%rbp),%eax
shl    $0x8,%eax
movzbl -0x9(%rbp),%ecx
or     %ecx,%eax
movzbl %al,%edi
call   1030 <tty_puthex@plt>
lea    0xe58(%rip),%rdi
call   1040 <tty_puts@plt>
lea    0xe62(%rip),%rdi
call   1040 <tty_puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbx
lea    0xed8(%rip),%rdi
call   1040 <tty_puts@plt>
mov    $0xfff85555,%eax
movb   $0xaa,(%rax)
movb   $0x55,-0x2aab(%rax)
movb   $0x90,(%rax)
mov    -0x5555(%rax),%cl
movzbl -0x5554(%rax),%ebx
movb   $0xaa,(%rax)
movb   $0x55,-0x2aab(%rax)
movb   $0xf0,(%rax)
lea    0xeb4(%rip),%rdi
call   1040 <tty_puts@plt>
mov    %ebx,%edi
call   1030 <tty_puthex@plt>
lea    0xe9f(%rip),%rdi
call   1040 <tty_puts@plt>
lea    0xea9(%rip),%rdi
pop    %rbx
jmp    1040 <tty_puts@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"FLASH test started\0A\00"
@.str.1 = [20 x i8] c"FLASH query info = \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [6 x i8] c"Done\0A\00"
define void @run_test() {
%1 = alloca i8*
%2 = alloca [2 x i8]
store i8* inttoptr (i64 4294443008 to i8*), i8** %1
%3 = call i32 @tty_puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = load i8*, i8** %1
%5 = getelementptr inbounds i8, i8* %4, i64 21845
store volatile i8 -86, i8* %5
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8, i8* %6, i64 10922
store volatile i8 85, i8* %7
%8 = load i8*, i8** %1
%9 = getelementptr inbounds i8, i8* %8, i64 21845
store volatile i8 -112, i8* %9
%10 = load i8*, i8** %1
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load volatile i8, i8* %11
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
store i8 %12, i8* %13
%14 = load i8*, i8** %1
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load volatile i8, i8* %15
%17 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 %16, i8* %17
%18 = load i8*, i8** %1
%19 = getelementptr inbounds i8, i8* %18, i64 21845
store volatile i8 -86, i8* %19
%20 = load i8*, i8** %1
%21 = getelementptr inbounds i8, i8* %20, i64 10922
store volatile i8 85, i8* %21
%22 = load i8*, i8** %1
%23 = getelementptr inbounds i8, i8* %22, i64 21845
store volatile i8 -16, i8* %23
%24 = call i32 @tty_puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = shl i32 %27, 8
%29 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = or i32 %28, %31
%33 = trunc i32 %32 to i8
%34 = call i32 @tty_puthex(i8 zeroext %33)
%35 = call i32 @tty_puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @tty_puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"FLASH test started\0A\00"
@.str.1 = [20 x i8] c"FLASH query info = \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [6 x i8] c"Done\0A\00"
define void @run_test() {
%1 = tail call i32 @tty_puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store volatile i8 -86, i8* inttoptr (i64 4294464853 to i8*)
store volatile i8 85, i8* inttoptr (i64 4294453930 to i8*)
store volatile i8 -112, i8* inttoptr (i64 4294464853 to i8*)
%2 = load volatile i8, i8* inttoptr (i64 4294443008 to i8*)
%3 = load volatile i8, i8* inttoptr (i64 4294443009 to i8*)
store volatile i8 -86, i8* inttoptr (i64 4294464853 to i8*)
store volatile i8 85, i8* inttoptr (i64 4294453930 to i8*)
store volatile i8 -16, i8* inttoptr (i64 4294464853 to i8*)
%4 = tail call i32 @tty_puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @tty_puthex(i8 zeroext %3)
%6 = tail call i32 @tty_puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 @tty_puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}