#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 FlashProtectSave(void) {
  uint32_t ui32Temp;
  for (ui32Temp = 0; ui32Temp < 8; ui32Temp++) {
    (*((volatile uint32_t *)(0x400FD000))) = ui32Temp;
    (*((volatile uint32_t *)(0x400FD008))) = 0xA4420000 | 0x00000008;
    while ((*((volatile uint32_t *)(0x400FD008))) & 0x00000008) {
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<FlashProtectSave>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
cmpl   $0x8,-0x4(%rbp)
jge    1155 <FlashProtectSave+0x55>
mov    -0x4(%rbp),%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     1142 <FlashProtectSave+0x42>
jmp    112a <FlashProtectSave+0x2a>
jmp    1147 <FlashProtectSave+0x47>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    110b <FlashProtectSave+0xb>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<FlashProtectSave>:
movl   $0x0,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
testl  $0x8,0x400fd008
jne    1120 <FlashProtectSave+0x20>
movl   $0x1,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    1150 <FlashProtectSave+0x50>
movl   $0x2,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    1180 <FlashProtectSave+0x80>
movl   $0x3,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    11b0 <FlashProtectSave+0xb0>
movl   $0x4,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    11e0 <FlashProtectSave+0xe0>
movl   $0x5,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    1210 <FlashProtectSave+0x110>
movl   $0x6,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    1240 <FlashProtectSave+0x140>
movl   $0x7,0x400fd000
movl   $0xa4420008,0x400fd008
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
testl  $0x8,0x400fd008
jne    1270 <FlashProtectSave+0x170>
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @FlashProtectSave() {
store volatile i32 0, 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 1, 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 2, 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 3, 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
store volatile i32 4, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %21
21: ; preds = %21, %20
%22 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%23 = and i32 %22, 8
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %21
25: ; preds = %21
store volatile i32 5, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %26
26: ; preds = %26, %25
%27 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%28 = and i32 %27, 8
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %26
30: ; preds = %26
store volatile i32 6, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %31
31: ; preds = %31, %30
%32 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%33 = and i32 %32, 8
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %31
35: ; preds = %31
store volatile i32 7, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %36
36: ; preds = %36, %35
%37 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%38 = and i32 %37, 8
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %36
40: ; preds = %36
ret i32 0
}