#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 FlashProgram(unsigned long *pulData, unsigned long ulAddress,
                  unsigned long ulCount) {
  {
    if (!(!(ulAddress & 3))) {
      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",
          223);
    }
  };
  {
    if (!(!(ulCount & 3))) {
      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",
          224);
    }
  };
  (*((volatile unsigned long *)(0x400FD014))) =
      (0x00000001 | 0x00000200 | 0x00000400 | 0x00002000);
  if ((*((volatile unsigned long *)(0x400FE1A0))) & 0x00000001) {
    while (ulCount) {
      (*((volatile unsigned long *)(0x400FD000))) = ulAddress & ~(0x7f);
      while (((ulAddress & 0x7c) ||
              ((*((volatile unsigned long *)(0x400FD030))) == 0)) &&
             (ulCount != 0)) {
        (*((volatile unsigned long *)(0x400FD100 + (ulAddress & 0x7c)))) =
            *pulData++;
        ulAddress += 4;
        ulCount -= 4;
      }
      (*((volatile unsigned long *)(0x400FD020))) = 0xA4420000 | 0x00000001;
      while ((*((volatile unsigned long *)(0x400FD020))) & 0x00000001) {
      }
    }
  } else {
    while (ulCount) {
      (*((volatile unsigned long *)(0x400FD000))) = ulAddress;
      (*((volatile unsigned long *)(0x400FD004))) = *pulData;
      (*((volatile unsigned long *)(0x400FD008))) = 0xA4420000 | 0x00000001;
      while ((*((volatile unsigned long *)(0x400FD008))) & 0x00000001) {
      }
      pulData++;
      ulAddress += 4;
      ulCount -= 4;
    }
  }
  if ((*((volatile unsigned long *)(0x400FD00C))) &
      (0x00000001 | 0x00000200 | 0x00000400 | 0x00002000)) {
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<FlashProgram>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
je     1147 <FlashProgram+0x37>
lea    0xec3(%rip),%rdi
mov    $0xdf,%esi
call   1030 <AssertFailure@plt>
mov    -0x20(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
je     116a <FlashProgram+0x5a>
lea    0xea0(%rip),%rdi
mov    $0xe0,%esi
call   1030 <AssertFailure@plt>
mov    $0x400fd014,%eax
movq   $0x2601,(%rax)
mov    $0x400fe1a0,%eax
mov    (%rax),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1262 <FlashProgram+0x152>
jmp    1191 <FlashProgram+0x81>
cmpq   $0x0,-0x20(%rbp)
je     125d <FlashProgram+0x14d>
mov    -0x18(%rbp),%rcx
and    $0xffffffffffffff80,%rcx
mov    $0x400fd000,%eax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
and    $0x7c,%rax
cmp    $0x0,%rax
jne    11d5 <FlashProgram+0xc5>
mov    $0x400fd030,%eax
mov    (%rax),%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    11e0 <FlashProgram+0xd0>
cmpq   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11f0 <FlashProgram+0xe0>
jmp    1230 <FlashProgram+0x120>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
and    $0x7c,%rax
add    $0x400fd100,%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
sub    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    11ac <FlashProgram+0x9c>
mov    $0x400fd020,%eax
mov    $0xa4420001,%ecx
mov    %rcx,(%rax)
mov    $0x400fd020,%eax
mov    (%rax),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1258 <FlashProgram+0x148>
jmp    123d <FlashProgram+0x12d>
jmp    1191 <FlashProgram+0x81>
jmp    12e3 <FlashProgram+0x1d3>
jmp    1267 <FlashProgram+0x157>
cmpq   $0x0,-0x20(%rbp)
je     12de <FlashProgram+0x1ce>
mov    -0x18(%rbp),%rcx
mov    $0x400fd000,%eax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    $0x400fd004,%eax
mov    %rcx,(%rax)
mov    $0x400fd008,%eax
mov    $0xa4420001,%ecx
mov    %rcx,(%rax)
mov    $0x400fd008,%eax
mov    (%rax),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     12b5 <FlashProgram+0x1a5>
jmp    129a <FlashProgram+0x18a>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
sub    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    1267 <FlashProgram+0x157>
jmp    12e3 <FlashProgram+0x1d3>
mov    $0x400fd00c,%eax
mov    (%rax),%rax
and    $0x2601,%rax
cmp    $0x0,%rax
je     1308 <FlashProgram+0x1f8>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1310 <FlashProgram+0x200>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FlashProgram>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
test   $0x3,%r15b
je     1135 <FlashProgram+0x25>
lea    0xed5(%rip),%rdi
mov    $0xdf,%esi
call   1030 <AssertFailure@plt>
test   $0x3,%bl
je     114b <FlashProgram+0x3b>
lea    0xebf(%rip),%rdi
mov    $0xe0,%esi
call   1030 <AssertFailure@plt>
movq   $0x2601,0x400fd014
testq  $0x1,0x400fe1a0
jne    11c0 <FlashProgram+0xb0>
test   %rbx,%rbx
je     1257 <FlashProgram+0x147>
mov    $0xa4420001,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,0x400fd000
40
mov    (%r14),%rcx
mov    %rcx,0x400fd004
40
mov    %rax,0x400fd008
40
nopl   0x0(%rax,%rax,1)
mov    0x400fd008,%rcx
40
test   $0x1,%cl
jne    11a0 <FlashProgram+0x90>
add    $0x8,%r14
add    $0x4,%r15
add    $0xfffffffffffffffc,%rbx
jne    1180 <FlashProgram+0x70>
jmp    1257 <FlashProgram+0x147>
test   %rbx,%rbx
je     1257 <FlashProgram+0x147>
mov    $0xa4420001,%eax
xchg   %ax,%ax
mov    %r15,%rcx
and    $0xffffffffffffff80,%rcx
mov    %rcx,0x400fd000
40
jmp    120e <FlashProgram+0xfe>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
test   %rbx,%rbx
je     1230 <FlashProgram+0x120>
mov    (%r14),%rdx
add    $0x8,%r14
or     $0x400fd100,%rcx
mov    %rdx,(%rcx)
add    $0x4,%r15
add    $0xfffffffffffffffc,%rbx
mov    %r15,%rcx
and    $0x7c,%rcx
jne    11f0 <FlashProgram+0xe0>
cmpq   $0x0,0x400fd030
jne    1232 <FlashProgram+0x122>
test   %rbx,%rbx
jne    11f5 <FlashProgram+0xe5>
jmp    1232 <FlashProgram+0x122>
nopl   0x0(%rax)
xor    %ebx,%ebx
mov    %rax,0x400fd020
40
nopw   0x0(%rax,%rax,1)
testq  $0x1,0x400fd020
jne    1240 <FlashProgram+0x130>
test   %rbx,%rbx
jne    11d0 <FlashProgram+0xc0>
mov    0x400fd00c,%rax
40
and    $0x2601,%eax
neg    %rax
sbb    %rax,%rax
pop    %rbx
pop    %r14
pop    %r15
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 @FlashProgram(i64* %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i64
store i64* %0, i64** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%8 = load i64, i64* %6
%9 = and i64 %8, 3
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @AssertFailure(i8* getelementptr inbounds ([202 x i8], [202 x i8]* @.str, i64 0, i64 0), i32 223)
br label %13
13: ; preds = %11, %3
%14 = load i64, i64* %7
%15 = and i64 %14, 3
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @AssertFailure(i8* getelementptr inbounds ([202 x i8], [202 x i8]* @.str, i64 0, i64 0), i32 224)
br label %19
19: ; preds = %17, %13
store volatile i64 9729, i64* inttoptr (i64 1074778132 to i64*)
%20 = load volatile i64, i64* inttoptr (i64 1074782624 to i64*)
%21 = and i64 %20, 1
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %62
23: ; preds = %19
br label %24
24: ; preds = %60, %23
%25 = load i64, i64* %7
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %61
27: ; preds = %24
%28 = load i64, i64* %6
%29 = and i64 %28, -128
store volatile i64 %29, i64* inttoptr (i64 1074778112 to i64*)
br label %30
30: ; preds = %42, %27
%31 = load i64, i64* %6
%32 = and i64 %31, 124
%33 = icmp ne i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load volatile i64, i64* inttoptr (i64 1074778160 to i64*)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34, %30
%38 = load i64, i64* %7
%39 = icmp ne i64 %38, 0
br label %40
40: ; preds = %37, %34
%41 = phi i1 [ false, %34 ], [ %39, %37 ]
br i1 %41, label %42, label %54
42: ; preds = %40
%43 = load i64*, i64** %5
%44 = getelementptr inbounds i64, i64* %43, i32 1
store i64* %44, i64** %5
%45 = load i64, i64* %43
%46 = load i64, i64* %6
%47 = and i64 %46, 124
%48 = add i64 1074778368, %47
%49 = inttoptr i64 %48 to i64*
store volatile i64 %45, i64* %49
%50 = load i64, i64* %6
%51 = add i64 %50, 4
store i64 %51, i64* %6
%52 = load i64, i64* %7
%53 = sub i64 %52, 4
store i64 %53, i64* %7
br label %30
54: ; preds = %40
store volatile i64 2755788801, i64* inttoptr (i64 1074778144 to i64*)
br label %55
55: ; preds = %59, %54
%56 = load volatile i64, i64* inttoptr (i64 1074778144 to i64*)
%57 = and i64 %56, 1
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %55
br label %55
60: ; preds = %55
br label %24
61: ; preds = %24
br label %83
62: ; preds = %19
br label %63
63: ; preds = %75, %62
%64 = load i64, i64* %7
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %82
66: ; preds = %63
%67 = load i64, i64* %6
store volatile i64 %67, i64* inttoptr (i64 1074778112 to i64*)
%68 = load i64*, i64** %5
%69 = load i64, i64* %68
store volatile i64 %69, i64* inttoptr (i64 1074778116 to i64*)
store volatile i64 2755788801, i64* inttoptr (i64 1074778120 to i64*)
br label %70
70: ; preds = %74, %66
%71 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%72 = and i64 %71, 1
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %70
br label %70
75: ; preds = %70
%76 = load i64*, i64** %5
%77 = getelementptr inbounds i64, i64* %76, i32 1
store i64* %77, i64** %5
%78 = load i64, i64* %6
%79 = add i64 %78, 4
store i64 %79, i64* %6
%80 = load i64, i64* %7
%81 = sub i64 %80, 4
store i64 %81, i64* %7
br label %63
82: ; preds = %63
br label %83
83: ; preds = %82, %61
%84 = load volatile i64, i64* inttoptr (i64 1074778124 to i64*)
%85 = and i64 %84, 9729
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %88
87: ; preds = %83
store i64 -1, i64* %4
br label %89
88: ; preds = %83
store i64 0, i64* %4
br label %89
89: ; preds = %88, %87
%90 = load i64, i64* %4
ret i64 %90
}

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 @FlashProgram(i64* nocapture %0, i64 %1, i64 %2) {
%4 = and i64 %1, 3
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @AssertFailure(i8* getelementptr inbounds ([202 x i8], [202 x i8]* @.str, i64 0, i64 0), i32 223)
br label %8
8: ; preds = %6, %3
%9 = and i64 %2, 3
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @AssertFailure(i8* getelementptr inbounds ([202 x i8], [202 x i8]* @.str, i64 0, i64 0), i32 224)
br label %13
13: ; preds = %11, %8
store volatile i64 9729, i64* inttoptr (i64 1074778132 to i64*)
%14 = load volatile i64, i64* inttoptr (i64 1074782624 to i64*)
%15 = and i64 %14, 1
%16 = icmp eq i64 %15, 0
%17 = icmp eq i64 %2, 0
br i1 %16, label %19, label %18
18: ; preds = %13
br i1 %17, label %67, label %22
19: ; preds = %13
br i1 %17, label %67, label %53
20: ; preds = %49
%21 = icmp eq i64 %48, 0
br i1 %21, label %67, label %22
22: ; preds = %18, %20
%23 = phi i64 [ %48, %20 ], [ %2, %18 ]
%24 = phi i64 [ %29, %20 ], [ %1, %18 ]
%25 = phi i64* [ %28, %20 ], [ %0, %18 ]
%26 = and i64 %24, -128
store volatile i64 %26, i64* inttoptr (i64 1074778112 to i64*)
br label %27
27: ; preds = %40, %22
%28 = phi i64* [ %25, %22 ], [ %41, %40 ]
%29 = phi i64 [ %24, %22 ], [ %45, %40 ]
%30 = phi i64 [ %23, %22 ], [ %46, %40 ]
%31 = and i64 %29, 124
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %27
%34 = load volatile i64, i64* inttoptr (i64 1074778160 to i64*)
%35 = icmp eq i64 %34, 0
%36 = icmp ne i64 %30, 0
%37 = select i1 %35, i1 %36, i1 false
br i1 %37, label %40, label %47
38: ; preds = %27
%39 = icmp eq i64 %30, 0
br i1 %39, label %47, label %40
40: ; preds = %33, %38
%41 = getelementptr inbounds i64, i64* %28, i64 1
%42 = load i64, i64* %28
%43 = or i64 %31, 1074778368
%44 = inttoptr i64 %43 to i64*
store volatile i64 %42, i64* %44
%45 = add i64 %29, 4
%46 = add i64 %30, -4
br label %27
47: ; preds = %33, %38
%48 = phi i64 [ %30, %33 ], [ 0, %38 ]
store volatile i64 2755788801, i64* inttoptr (i64 1074778144 to i64*)
br label %49
49: ; preds = %49, %47
%50 = load volatile i64, i64* inttoptr (i64 1074778144 to i64*)
%51 = and i64 %50, 1
%52 = icmp eq i64 %51, 0
br i1 %52, label %20, label %49
53: ; preds = %19, %62
%54 = phi i64 [ %65, %62 ], [ %2, %19 ]
%55 = phi i64 [ %64, %62 ], [ %1, %19 ]
%56 = phi i64* [ %63, %62 ], [ %0, %19 ]
store volatile i64 %55, i64* inttoptr (i64 1074778112 to i64*)
%57 = load i64, i64* %56
store volatile i64 %57, i64* inttoptr (i64 1074778116 to i64*)
store volatile i64 2755788801, i64* inttoptr (i64 1074778120 to i64*)
br label %58
58: ; preds = %58, %53
%59 = load volatile i64, i64* inttoptr (i64 1074778120 to i64*)
%60 = and i64 %59, 1
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %58
62: ; preds = %58
%63 = getelementptr inbounds i64, i64* %56, i64 1
%64 = add i64 %55, 4
%65 = add i64 %54, -4
%66 = icmp eq i64 %65, 0
br i1 %66, label %67, label %53
67: ; preds = %20, %62, %18, %19
%68 = load volatile i64, i64* inttoptr (i64 1074778124 to i64*)
%69 = and i64 %68, 9729
%70 = icmp ne i64 %69, 0
%71 = sext i1 %70 to i64
ret i64 %71
}