#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 */

/* Variables and functions */
int /*<<< orphan*/ AssertFailure(char *, int);
long FlashClear(unsigned long ulAddress) {
  {
    if (!(!(ulAddress & (0x00000400 - 1)))) {
      AssertFailure(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/"
          "Demo/ARMCM3_LM3S_EK_LM3S6965_Crossworks/Boot/lib/driverlib/"
          "flashlib.c",
          156);
    }
  };
  (*((volatile unsigned long *)(0x400FD014))) =
      (0x00000001 | 0x00000200 | 0x00000800);
  (*((volatile unsigned long *)(0x400FD000))) = ulAddress;
  (*((volatile unsigned long *)(0x400FD008))) = 0xA4420000 | 0x00000002;
  while ((*((volatile unsigned long *)(0x400FD008))) & 0x00000002) {
  }
  if ((*((volatile unsigned long *)(0x400FD00C))) &
      (0x00000001 | 0x00000200 | 0x00000800)) {
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<FlashClear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0x3ff,%rax
cmp    $0x0,%rax
je     1141 <FlashClear+0x31>
lea    0xec9(%rip),%rdi
mov    $0x9c,%esi
call   1030 <AssertFailure@plt>
mov    $0x400fd014,%eax
movq   $0xa01,(%rax)
mov    -0x10(%rbp),%rcx
mov    $0x400fd000,%eax
mov    %rcx,(%rax)
mov    $0x400fd008,%eax
mov    $0xa4420002,%ecx
mov    %rcx,(%rax)
mov    $0x400fd008,%eax
mov    (%rax),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     1181 <FlashClear+0x71>
jmp    1166 <FlashClear+0x56>
mov    $0x400fd00c,%eax
mov    (%rax),%rax
and    $0xa01,%rax
cmp    $0x0,%rax
je     11a6 <FlashClear+0x96>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11ae <FlashClear+0x9e>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FlashClear>:
push   %rbx
mov    %rdi,%rbx
test   $0x3ff,%ebx
je     112d <FlashClear+0x1d>
lea    0xedd(%rip),%rdi
mov    $0x9c,%esi
call   1030 <AssertFailure@plt>
movq   $0xa01,0x400fd014
mov    %rbx,0x400fd000
40
mov    $0xa4420002,%eax
mov    %rax,0x400fd008
40
xchg   %ax,%ax
testq  $0x2,0x400fd008
jne    1150 <FlashClear+0x40>
mov    0x400fd00c,%rax
40
and    $0xa01,%eax
neg    %rax
sbb    %rax,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [202 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/Demo/ARMCM3_LM3S_EK_LM3S6965_Crossworks/Boot/lib/driverlib/flashlib.c\00"
define i64 @FlashClear(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %3
%4 = load i64, i64* %3
%5 = and i64 %4, 1023
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @AssertFailure(i8* getelementptr inbounds ([202 x i8], [202 x i8]* @.str, i64 0, i64 0), i32 156)
br label %9
9: ; preds = %7, %1
store volatile i64 2561, i64* inttoptr (i64 1074778132 to i64*)
%10 = load i64, i64* %3
store volatile i64 %10, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788802, i64* inttoptr (i64 1074778120 to i64*)
br label %11
11: ; preds = %15, %9
%12 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%13 = and i64 %12, 2
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
br label %11
16: ; preds = %11
%17 = load volatile i64, i64* inttoptr (i64 1074778124 to i64*)
%18 = and i64 %17, 2561
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i64 -1, i64* %2
br label %22
21: ; preds = %16
store i64 0, i64* %2
br label %22
22: ; preds = %21, %20
%23 = load i64, i64* %2
ret i64 %23
}

LLVM IR (-O2):
@.str = [202 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/Demo/ARMCM3_LM3S_EK_LM3S6965_Crossworks/Boot/lib/driverlib/flashlib.c\00"
define i64 @FlashClear(i64 %0) {
%2 = and i64 %0, 1023
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @AssertFailure(i8* getelementptr inbounds ([202 x i8], [202 x i8]* @.str, i64 0, i64 0), i32 156)
br label %6
6: ; preds = %4, %1
store volatile i64 2561, i64* inttoptr (i64 1074778132 to i64*)
store volatile i64 %0, i64* inttoptr (i64 1074778112 to i64*)
store volatile i64 2755788802, i64* inttoptr (i64 1074778120 to i64*)
br label %7
7: ; preds = %7, %6
%8 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%9 = and i64 %8, 2
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %7
11: ; preds = %7
%12 = load volatile i64, i64* inttoptr (i64 1074778124 to i64*)
%13 = and i64 %12, 2561
%14 = icmp ne i64 %13, 0
%15 = sext i1 %14 to i64
ret i64 %15
}