#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 */
typedef int uint32_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int32_t FlashAllUserRegisterSave(void) {
  uint32_t ui32Index;
  for (ui32Index = 0; ui32Index < 4; ui32Index++) {
    (*((volatile uint32_t *)(0x400FD000))) = (0x80000000 + ui32Index);
    (*((volatile uint32_t *)(0x400FD008))) = 0xA4420000 | 0x00000008;
    while ((*((volatile uint32_t *)(0x400FD008))) & 0x00000008) {
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<FlashAllUserRegisterSave>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    115b <FlashAllUserRegisterSave+0x5b>
mov    -0x4(%rbp),%ecx
add    $0x80000000,%ecx
mov    $0x400fd000,%eax
mov    %ecx,(%rax)
mov    $0x400fd008,%eax
movl   $0xa4420008,(%rax)
mov    $0x400fd008,%eax
mov    (%rax),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1148 <FlashAllUserRegisterSave+0x48>
jmp    1130 <FlashAllUserRegisterSave+0x30>
jmp    114d <FlashAllUserRegisterSave+0x4d>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    110b <FlashAllUserRegisterSave+0xb>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<FlashAllUserRegisterSave>:
movl   $0x80000000,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
testl  $0x8,0x400fd008
jne    1120 <FlashAllUserRegisterSave+0x20>
movl   $0x80000001,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    1150 <FlashAllUserRegisterSave+0x50>
movl   $0x80000002,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    1180 <FlashAllUserRegisterSave+0x80>
movl   $0x80000003,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    11b0 <FlashAllUserRegisterSave+0xb0>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @FlashAllUserRegisterSave() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %14, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 4
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = load i32, i32* %1
%7 = add i32 -2147483648, %6
store volatile i32 %7, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %8
8: ; preds = %12, %5
%9 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%10 = and i32 %9, 8
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
br label %8
13: ; preds = %8
br label %14
14: ; preds = %13
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 1
store i32 %16, i32* %1
br label %2
17: ; preds = %2
ret i32 0
}

LLVM IR (-O2):
define i32 @FlashAllUserRegisterSave() {
store volatile i32 -2147483648, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %1
1: ; preds = %1, %0
%2 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%3 = and i32 %2, 8
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %1
5: ; preds = %1
store volatile i32 -2147483647, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %6
6: ; preds = %6, %5
%7 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%8 = and i32 %7, 8
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %6
10: ; preds = %6
store volatile i32 -2147483646, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %11
11: ; preds = %11, %10
%12 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%13 = and i32 %12, 8
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %11
15: ; preds = %11
store volatile i32 -2147483645, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %16
16: ; preds = %16, %15
%17 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%18 = and i32 %17, 8
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %16
20: ; preds = %16
ret i32 0
}