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

/* Variables and functions */
int32_t FlashUserSave(void) {
  (*((volatile unsigned long *)(0x400FD000))) = 0x80000000;
  (*((volatile unsigned long *)(0x400FD008))) = 0xA4420000 | 0x00000008;
  while ((*((volatile unsigned long *)(0x400FD008))) & 0x00000008) {
  }
  (*((volatile unsigned long *)(0x400FD000))) = 0x80000001;
  (*((volatile unsigned long *)(0x400FD008))) = 0xA4420000 | 0x00000008;
  while ((*((volatile unsigned long *)(0x400FD008))) & 0x00000008) {
  }
  return (0);
}


x86 assembly (clang, -O0):
<FlashUserSave>:
push   %rbp
mov    %rsp,%rbp
mov    $0x400fd000,%eax
mov    $0x80000000,%ecx
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     1139 <FlashUserSave+0x39>
jmp    111e <FlashUserSave+0x1e>
mov    $0x400fd000,%eax
mov    $0x80000001,%ecx
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     116e <FlashUserSave+0x6e>
jmp    1153 <FlashUserSave+0x53>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<FlashUserSave>:
mov    $0xa4420008,%eax
lea    -0x24420008(%rax),%rcx
mov    %rcx,0x400fd000
40
mov    %rax,0x400fd008
40
nopl   0x0(%rax)
testq  $0x8,0x400fd008
jne    1120 <FlashUserSave+0x20>
lea    -0x24420007(%rax),%rcx
mov    %rcx,0x400fd000
40
mov    %rax,0x400fd008
40
cs nopw 0x0(%rax,%rax,1)
nop
testq  $0x8,0x400fd008
jne    1150 <FlashUserSave+0x50>
xor    %eax,%eax
ret

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