#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 FlashUserSave(void) {
  (*((volatile uint32_t *)(0x400FD000))) = 0x80000000;
  (*((volatile uint32_t *)(0x400FD008))) = 0xA4420000 | 0x00000008;
  while ((*((volatile uint32_t *)(0x400FD008))) & 0x00000008) {
  }
  (*((volatile uint32_t *)(0x400FD000))) = 0x80000001;
  (*((volatile uint32_t *)(0x400FD008))) = 0xA4420000 | 0x00000008;
  while ((*((volatile uint32_t *)(0x400FD008))) & 0x00000008) {
  }
  return (0);
}


x86 assembly (clang, -O0):
<FlashUserSave>:
push   %rbp
mov    %rsp,%rbp
mov    $0x400fd000,%eax
movl   $0x80000000,(%rax)
mov    $0x400fd008,%eax
movl   $0xa4420008,(%rax)
mov    $0x400fd008,%eax
mov    (%rax),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1132 <FlashUserSave+0x32>
jmp    111a <FlashUserSave+0x1a>
mov    $0x400fd000,%eax
movl   $0x80000001,(%rax)
mov    $0x400fd008,%eax
movl   $0xa4420008,(%rax)
mov    $0x400fd008,%eax
mov    (%rax),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1160 <FlashUserSave+0x60>
jmp    1148 <FlashUserSave+0x48>
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @FlashUserSave() {
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 = %5, %0
%2 = load volatile i32, i32* inttoptr (i64 1074778120 to i32*)
%3 = and i32 %2, 8
%4 = icmp ne i32 %3, 0
br i1 %4, label %5, label %6
5: ; preds = %1
br label %1
6: ; preds = %1
store volatile i32 -2147483647, i32* inttoptr (i64 1074778112 to i32*)
store volatile i32 -1539178488, i32* inttoptr (i64 1074778120 to i32*)
br label %7
7: ; preds = %11, %6
%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
ret i32 0
}

LLVM IR (-O2):
define i32 @FlashUserSave() {
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
ret i32 0
}