#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 unsigned long *)(0x400FD000))) = ui32Temp;
    (*((volatile unsigned long *)(0x400FD008))) = 0xA4420000 | 0x00000008;
    while ((*((volatile unsigned long *)(0x400FD008))) & 0x00000008) {
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<FlashProtectSave>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
cmpl   $0x8,-0x4(%rbp)
jge    115c <FlashProtectSave+0x5c>
movslq -0x4(%rbp),%rcx
mov    $0x400fd000,%eax
mov    %rcx,(%rax)
mov    $0x400fd008,%eax
mov    $0xa4420008,%ecx
mov    %rcx,(%rax)
mov    $0x400fd008,%eax
mov    (%rax),%rax
and    $0x8,%rax
cmp    $0x0,%rax
je     1149 <FlashProtectSave+0x49>
jmp    112e <FlashProtectSave+0x2e>
jmp    114e <FlashProtectSave+0x4e>
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>:
mov    $0xa4420008,%eax
movq   $0x0,0x400fd000
mov    %rax,0x400fd008
40
nopl   0x0(%rax)
testq  $0x8,0x400fd008
jne    1120 <FlashProtectSave+0x20>
movq   $0x1,0x400fd000
mov    %rax,0x400fd008
40
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
testq  $0x8,0x400fd008
jne    1150 <FlashProtectSave+0x50>
movq   $0x2,0x400fd000
mov    %rax,0x400fd008
40
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
testq  $0x8,0x400fd008
jne    1180 <FlashProtectSave+0x80>
movq   $0x3,0x400fd000
mov    %rax,0x400fd008
40
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
testq  $0x8,0x400fd008
jne    11b0 <FlashProtectSave+0xb0>
movq   $0x4,0x400fd000
mov    %rax,0x400fd008
40
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
testq  $0x8,0x400fd008
jne    11e0 <FlashProtectSave+0xe0>
movq   $0x5,0x400fd000
mov    %rax,0x400fd008
40
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
testq  $0x8,0x400fd008
jne    1210 <FlashProtectSave+0x110>
movq   $0x6,0x400fd000
mov    %rax,0x400fd008
40
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
testq  $0x8,0x400fd008
jne    1240 <FlashProtectSave+0x140>
movq   $0x7,0x400fd000
mov    %rax,0x400fd008
40
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
testq  $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 = %14, %0
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 8
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = load i32, i32* %1
%7 = sext i32 %6 to i64
store volatile i64 %7, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788808, i64* inttoptr (i64 1074778120 to i64*)
br label %8
8: ; preds = %12, %5
%9 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%10 = and i64 %9, 8
%11 = icmp ne i64 %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 @FlashProtectSave() {
store volatile i64 0, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788808, i64* inttoptr (i64 1074778120 to i64*)
br label %1
1: ; preds = %1, %0
%2 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%3 = and i64 %2, 8
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %1
5: ; preds = %1
store volatile i64 1, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788808, i64* inttoptr (i64 1074778120 to i64*)
br label %6
6: ; preds = %6, %5
%7 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%8 = and i64 %7, 8
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %6
10: ; preds = %6
store volatile i64 2, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788808, i64* inttoptr (i64 1074778120 to i64*)
br label %11
11: ; preds = %11, %10
%12 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%13 = and i64 %12, 8
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %11
15: ; preds = %11
store volatile i64 3, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788808, i64* inttoptr (i64 1074778120 to i64*)
br label %16
16: ; preds = %16, %15
%17 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%18 = and i64 %17, 8
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %16
20: ; preds = %16
store volatile i64 4, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788808, i64* inttoptr (i64 1074778120 to i64*)
br label %21
21: ; preds = %21, %20
%22 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%23 = and i64 %22, 8
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %21
25: ; preds = %21
store volatile i64 5, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788808, i64* inttoptr (i64 1074778120 to i64*)
br label %26
26: ; preds = %26, %25
%27 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%28 = and i64 %27, 8
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %26
30: ; preds = %26
store volatile i64 6, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788808, i64* inttoptr (i64 1074778120 to i64*)
br label %31
31: ; preds = %31, %30
%32 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%33 = and i64 %32, 8
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %31
35: ; preds = %31
store volatile i64 7, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788808, i64* inttoptr (i64 1074778120 to i64*)
br label %36
36: ; preds = %36, %35
%37 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%38 = and i64 %37, 8
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %36
40: ; preds = %36
ret i32 0
}