#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 volatile uint8_t;
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ eeprom_initialize();
int /*<<< orphan*/ flexram_wait();
void eeprom_write_dword(uint32_t *addr, uint32_t value) {
  uint32_t offset = (uint32_t)addr;
  if (offset >= 2048 - 3)
    return;
  if (!((*(volatile uint8_t *)0x40020001) & ((uint8_t)0x01)))
    eeprom_initialize();
  switch (offset & 3) {
  case 0:
    if (*(uint32_t *)(&((uint8_t *)0x14000000)[offset]) != value) {
      *(uint32_t *)(&((uint8_t *)0x14000000)[offset]) = value;
      flexram_wait();
    }
    return;
  case 2:
    if (*(uint16_t *)(&((uint8_t *)0x14000000)[offset]) != value) {
      *(uint16_t *)(&((uint8_t *)0x14000000)[offset]) = value;
      flexram_wait();
    }
    if (*(uint16_t *)(&((uint8_t *)0x14000000)[offset + 2]) != (value >> 16)) {
      *(uint16_t *)(&((uint8_t *)0x14000000)[offset + 2]) = value >> 16;
      flexram_wait();
    }
    return;
  default:
    if (((uint8_t *)0x14000000)[offset] != value) {
      ((uint8_t *)0x14000000)[offset] = value;
      flexram_wait();
    }
    if (*(uint16_t *)(&((uint8_t *)0x14000000)[offset + 1]) != (value >> 8)) {
      *(uint16_t *)(&((uint8_t *)0x14000000)[offset + 1]) = value >> 8;
      flexram_wait();
    }
    if (((uint8_t *)0x14000000)[offset + 3] != (value >> 24)) {
      ((uint8_t *)0x14000000)[offset + 3] = value >> 24;
      flexram_wait();
    }
  }
}


x86 assembly (clang, -O0):
<eeprom_write_dword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,-0x10(%rbp)
cmpl   $0x7fd,-0x10(%rbp)
jl     1148 <eeprom_write_dword+0x28>
jmp    12ce <eeprom_write_dword+0x1ae>
mov    $0x40020001,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1162 <eeprom_write_dword+0x42>
mov    $0x0,%al
call   1040 <eeprom_initialize@plt>
mov    -0x10(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x14(%rbp)
je     1187 <eeprom_write_dword+0x67>
jmp    1176 <eeprom_write_dword+0x56>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     11b7 <eeprom_write_dword+0x97>
jmp    1224 <eeprom_write_dword+0x104>
movslq -0x10(%rbp),%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
je     11b2 <eeprom_write_dword+0x92>
mov    -0xc(%rbp),%edx
movslq -0x10(%rbp),%rcx
mov    $0x14000000,%eax
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1030 <flexram_wait@plt>
jmp    12ce <eeprom_write_dword+0x1ae>
movslq -0x10(%rbp),%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
je     11e2 <eeprom_write_dword+0xc2>
mov    -0xc(%rbp),%edx
movslq -0x10(%rbp),%rcx
mov    $0x14000000,%eax
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1030 <flexram_wait@plt>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
movslq %eax,%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
cmp    %ecx,%eax
je     121f <eeprom_write_dword+0xff>
mov    -0xc(%rbp),%edx
sar    $0x10,%edx
mov    -0x10(%rbp),%eax
add    $0x2,%eax
movslq %eax,%rcx
mov    $0x14000000,%eax
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1030 <flexram_wait@plt>
jmp    12ce <eeprom_write_dword+0x1ae>
movslq -0x10(%rbp),%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
je     124f <eeprom_write_dword+0x12f>
mov    -0xc(%rbp),%edx
movslq -0x10(%rbp),%rcx
mov    $0x14000000,%eax
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1030 <flexram_wait@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
cmp    %ecx,%eax
je     128c <eeprom_write_dword+0x16c>
mov    -0xc(%rbp),%edx
sar    $0x8,%edx
mov    -0x10(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
mov    $0x14000000,%eax
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1030 <flexram_wait@plt>
mov    -0x10(%rbp),%eax
add    $0x3,%eax
movslq %eax,%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
cmp    %ecx,%eax
je     12c9 <eeprom_write_dword+0x1a9>
mov    -0xc(%rbp),%edx
sar    $0x18,%edx
mov    -0x10(%rbp),%eax
add    $0x3,%eax
movslq %eax,%rcx
mov    $0x14000000,%eax
mov    %edx,(%rax,%rcx,4)
mov    $0x0,%al
call   1030 <flexram_wait@plt>
jmp    12ce <eeprom_write_dword+0x1ae>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eeprom_write_dword>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
cmp    $0x7fc,%ebx
jle    113c <eeprom_write_dword+0x1c>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %esi,%r12d
mov    %ebx,%ebp
mov    0x40020001,%eax
test   $0x1,%al
jne    1153 <eeprom_write_dword+0x33>
xor    %eax,%eax
call   1040 <eeprom_initialize@plt>
and    $0x3,%ebp
cmp    $0x2,%ebp
je     117a <eeprom_write_dword+0x5a>
test   %ebp,%ebp
jne    11d4 <eeprom_write_dword+0xb4>
movslq %ebx,%rax
cmp    %r12d,0x14000000(,%rax,4)
14
je     1133 <eeprom_write_dword+0x13>
mov    $0x14000000,%ecx
mov    %r12d,(%rcx,%rax,4)
jmp    125d <eeprom_write_dword+0x13d>
mov    $0x14000000,%r14d
mov    %rbx,%rbp
shl    $0x20,%rbp
mov    %rbp,%rax
sar    $0x1e,%rax
cmp    %r12d,0x14000000(%rax)
je     11a5 <eeprom_write_dword+0x85>
movslq %ebx,%rax
mov    %r12d,(%r14,%rax,4)
xor    %eax,%eax
call   1030 <flexram_wait@plt>
movabs $0x200000000,%rax
add    %rax,%rbp
mov    %rbp,%rax
sar    $0x1e,%rax
sar    $0x10,%r12d
cmp    %r12d,(%r14,%rax,1)
je     1133 <eeprom_write_dword+0x13>
sar    $0x20,%rbp
mov    %r12d,(%r14,%rbp,4)
jmp    125d <eeprom_write_dword+0x13d>
mov    $0x14000000,%r14d
mov    %rbx,%r15
shl    $0x20,%r15
mov    %r15,%rax
sar    $0x1e,%rax
mov    0x14000000(%rax),%eax
cmp    %r12d,%eax
je     1201 <eeprom_write_dword+0xe1>
movslq %ebx,%rax
mov    %r12d,(%r14,%rax,4)
xor    %eax,%eax
call   1030 <flexram_wait@plt>
movabs $0x100000000,%rax
add    %r15,%rax
mov    %rax,%rdx
sar    $0x1e,%rdx
mov    %r12d,%ecx
sar    $0x8,%ecx
cmp    %ecx,(%r14,%rdx,1)
je     1230 <eeprom_write_dword+0x110>
sar    $0x20,%rax
mov    %ecx,(%r14,%rax,4)
xor    %eax,%eax
call   1030 <flexram_wait@plt>
movabs $0x300000000,%rax
add    %rax,%r15
mov    %r15,%rax
sar    $0x1e,%rax
mov    (%r14,%rax,1),%eax
sar    $0x18,%r12d
cmp    %r12d,%eax
je     1133 <eeprom_write_dword+0x13>
sar    $0x20,%r15
mov    %r12d,(%r14,%r15,4)
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <flexram_wait@plt>

LLVM IR (-O0):
define void @eeprom_write_dword(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = ptrtoint i32* %6 to i32
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp sge i32 %8, 2045
br i1 %9, label %10, label %11
10: ; preds = %2
br label %113
11: ; preds = %2
%12 = load volatile i32, i32* inttoptr (i64 1073872897 to i32*)
%13 = and i32 %12, 1
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i32 (...) @eeprom_initialize()
br label %17
17: ; preds = %15, %11
%18 = load i32, i32* %5
%19 = and i32 %18, 3
switch i32 %19, label %65 [
i32 0, label %20
i32 2, label %34
]
20: ; preds = %17
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %22
%24 = load i32, i32* %23
%25 = load i32, i32* %4
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %33
27: ; preds = %20
%28 = load i32, i32* %4
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %30
store i32 %28, i32* %31
%32 = call i32 (...) @flexram_wait()
br label %33
33: ; preds = %27, %20
br label %113
34: ; preds = %17
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %36
%38 = load i32, i32* %37
%39 = load i32, i32* %4
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %47
41: ; preds = %34
%42 = load i32, i32* %4
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %44
store i32 %42, i32* %45
%46 = call i32 (...) @flexram_wait()
br label %47
47: ; preds = %41, %34
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %50
%52 = load i32, i32* %51
%53 = load i32, i32* %4
%54 = ashr i32 %53, 16
%55 = icmp ne i32 %52, %54
br i1 %55, label %56, label %64
56: ; preds = %47
%57 = load i32, i32* %4
%58 = ashr i32 %57, 16
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 2
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %61
store i32 %58, i32* %62
%63 = call i32 (...) @flexram_wait()
br label %64
64: ; preds = %56, %47
br label %113
65: ; preds = %17
%66 = load i32, i32* %5
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %67
%69 = load volatile i32, i32* %68
%70 = load i32, i32* %4
%71 = icmp ne i32 %69, %70
br i1 %71, label %72, label %78
72: ; preds = %65
%73 = load i32, i32* %4
%74 = load i32, i32* %5
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %75
store volatile i32 %73, i32* %76
%77 = call i32 (...) @flexram_wait()
br label %78
78: ; preds = %72, %65
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %81
%83 = load i32, i32* %82
%84 = load i32, i32* %4
%85 = ashr i32 %84, 8
%86 = icmp ne i32 %83, %85
br i1 %86, label %87, label %95
87: ; preds = %78
%88 = load i32, i32* %4
%89 = ashr i32 %88, 8
%90 = load i32, i32* %5
%91 = add nsw i32 %90, 1
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %92
store i32 %89, i32* %93
%94 = call i32 (...) @flexram_wait()
br label %95
95: ; preds = %87, %78
%96 = load i32, i32* %5
%97 = add nsw i32 %96, 3
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %98
%100 = load volatile i32, i32* %99
%101 = load i32, i32* %4
%102 = ashr i32 %101, 24
%103 = icmp ne i32 %100, %102
br i1 %103, label %104, label %112
104: ; preds = %95
%105 = load i32, i32* %4
%106 = ashr i32 %105, 24
%107 = load i32, i32* %5
%108 = add nsw i32 %107, 3
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %109
store volatile i32 %106, i32* %110
%111 = call i32 (...) @flexram_wait()
br label %112
112: ; preds = %104, %95
br label %113
113: ; preds = %10, %33, %64, %112
ret void
}

LLVM IR (-O2):
define void @eeprom_write_dword(i32* %0, i32 %1) {
%3 = ptrtoint i32* %0 to i64
%4 = trunc i64 %3 to i32
%5 = icmp sgt i32 %4, 2044
br i1 %5, label %64, label %6
6: ; preds = %2
%7 = load volatile i32, i32* inttoptr (i64 1073872897 to i32*)
%8 = and i32 %7, 1
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 (...) @eeprom_initialize()
br label %12
12: ; preds = %10, %6
%13 = and i32 %4, 3
switch i32 %13, label %37 [
i32 0, label %14
i32 2, label %21
]
14: ; preds = %12
%15 = shl i64 %3, 32
%16 = ashr exact i64 %15, 32
%17 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %16
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, %1
br i1 %19, label %64, label %20
20: ; preds = %14
store i32 %1, i32* %17
br label %62
21: ; preds = %12
%22 = shl i64 %3, 32
%23 = ashr exact i64 %22, 32
%24 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %23
%25 = load i32, i32* %24
%26 = icmp eq i32 %25, %1
br i1 %26, label %29, label %27
27: ; preds = %21
store i32 %1, i32* %24
%28 = tail call i32 (...) @flexram_wait()
br label %29
29: ; preds = %27, %21
%30 = add i64 %22, 8589934592
%31 = ashr exact i64 %30, 32
%32 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %31
%33 = load i32, i32* %32
%34 = ashr i32 %1, 16
%35 = icmp eq i32 %33, %34
br i1 %35, label %64, label %36
36: ; preds = %29
store i32 %34, i32* %32
br label %62
37: ; preds = %12
%38 = shl i64 %3, 32
%39 = ashr exact i64 %38, 32
%40 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %39
%41 = load volatile i32, i32* %40
%42 = icmp eq i32 %41, %1
br i1 %42, label %45, label %43
43: ; preds = %37
store volatile i32 %1, i32* %40
%44 = tail call i32 (...) @flexram_wait()
br label %45
45: ; preds = %43, %37
%46 = add i64 %38, 4294967296
%47 = ashr exact i64 %46, 32
%48 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %47
%49 = load i32, i32* %48
%50 = ashr i32 %1, 8
%51 = icmp eq i32 %49, %50
br i1 %51, label %54, label %52
52: ; preds = %45
store i32 %50, i32* %48
%53 = tail call i32 (...) @flexram_wait()
br label %54
54: ; preds = %52, %45
%55 = add i64 %38, 12884901888
%56 = ashr exact i64 %55, 32
%57 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %56
%58 = load volatile i32, i32* %57
%59 = ashr i32 %1, 24
%60 = icmp eq i32 %58, %59
br i1 %60, label %64, label %61
61: ; preds = %54
store volatile i32 %59, i32* %57
br label %62
62: ; preds = %20, %36, %61
%63 = tail call i32 (...) @flexram_wait()
br label %64
64: ; preds = %62, %54, %29, %14, %2
ret void
}