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

/* Variables and functions */
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;
  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     1138 <eeprom_write_dword+0x28>
jmp    12a4 <eeprom_write_dword+0x194>
mov    -0x10(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x14(%rbp)
je     115d <eeprom_write_dword+0x4d>
jmp    114c <eeprom_write_dword+0x3c>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     118d <eeprom_write_dword+0x7d>
jmp    11fa <eeprom_write_dword+0xea>
movslq -0x10(%rbp),%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
je     1188 <eeprom_write_dword+0x78>
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    12a4 <eeprom_write_dword+0x194>
movslq -0x10(%rbp),%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
je     11b8 <eeprom_write_dword+0xa8>
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     11f5 <eeprom_write_dword+0xe5>
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    12a4 <eeprom_write_dword+0x194>
movslq -0x10(%rbp),%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
je     1225 <eeprom_write_dword+0x115>
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     1262 <eeprom_write_dword+0x152>
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     129f <eeprom_write_dword+0x18f>
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    12a4 <eeprom_write_dword+0x194>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eeprom_write_dword>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x7fc,%edi
jle    112a <eeprom_write_dword+0x1a>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %esi,%ebp
mov    %edi,%eax
and    $0x3,%eax
cmp    $0x2,%eax
je     1153 <eeprom_write_dword+0x43>
test   %eax,%eax
jne    11a7 <eeprom_write_dword+0x97>
movslq %edi,%rax
cmp    %ebp,0x14000000(,%rax,4)
je     111f <eeprom_write_dword+0xf>
mov    $0x14000000,%ecx
mov    %ebp,(%rcx,%rax,4)
jmp    1228 <eeprom_write_dword+0x118>
mov    $0x14000000,%r14d
mov    %rdi,%rbx
shl    $0x20,%rbx
mov    %rbx,%rax
sar    $0x1e,%rax
cmp    %ebp,0x14000000(%rax)
je     117d <eeprom_write_dword+0x6d>
movslq %edi,%rax
mov    %ebp,(%r14,%rax,4)
xor    %eax,%eax
call   1030 <flexram_wait@plt>
movabs $0x200000000,%rax
add    %rax,%rbx
mov    %rbx,%rax
sar    $0x1e,%rax
sar    $0x10,%ebp
cmp    %ebp,(%r14,%rax,1)
je     111f <eeprom_write_dword+0xf>
sar    $0x20,%rbx
mov    %ebp,(%r14,%rbx,4)
jmp    1228 <eeprom_write_dword+0x118>
mov    $0x14000000,%r14d
mov    %rdi,%r15
shl    $0x20,%r15
mov    %r15,%rax
sar    $0x1e,%rax
cmp    %ebp,0x14000000(%rax)
je     11d1 <eeprom_write_dword+0xc1>
movslq %edi,%rax
mov    %ebp,(%r14,%rax,4)
xor    %eax,%eax
call   1030 <flexram_wait@plt>
movabs $0x100000000,%rax
add    %r15,%rax
mov    %rax,%rdx
sar    $0x1e,%rdx
mov    %ebp,%ecx
sar    $0x8,%ecx
cmp    %ecx,(%r14,%rdx,1)
je     11ff <eeprom_write_dword+0xef>
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
sar    $0x18,%ebp
cmp    %ebp,(%r14,%rax,1)
je     111f <eeprom_write_dword+0xf>
sar    $0x20,%r15
mov    %ebp,(%r14,%r15,4)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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 %107
11: ; preds = %2
%12 = load i32, i32* %5
%13 = and i32 %12, 3
switch i32 %13, label %59 [
i32 0, label %14
i32 2, label %28
]
14: ; preds = %11
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %16
%18 = load i32, i32* %17
%19 = load i32, i32* %4
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %27
21: ; preds = %14
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %24
store i32 %22, i32* %25
%26 = call i32 (...) @flexram_wait()
br label %27
27: ; preds = %21, %14
br label %107
28: ; preds = %11
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %30
%32 = load i32, i32* %31
%33 = load i32, i32* %4
%34 = icmp ne i32 %32, %33
br i1 %34, label %35, label %41
35: ; preds = %28
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %38
store i32 %36, i32* %39
%40 = call i32 (...) @flexram_wait()
br label %41
41: ; preds = %35, %28
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %4
%48 = ashr i32 %47, 16
%49 = icmp ne i32 %46, %48
br i1 %49, label %50, label %58
50: ; preds = %41
%51 = load i32, i32* %4
%52 = ashr i32 %51, 16
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %55
store i32 %52, i32* %56
%57 = call i32 (...) @flexram_wait()
br label %58
58: ; preds = %50, %41
br label %107
59: ; preds = %11
%60 = load i32, i32* %5
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %61
%63 = load i32, i32* %62
%64 = load i32, i32* %4
%65 = icmp ne i32 %63, %64
br i1 %65, label %66, label %72
66: ; preds = %59
%67 = load i32, i32* %4
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %69
store i32 %67, i32* %70
%71 = call i32 (...) @flexram_wait()
br label %72
72: ; preds = %66, %59
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %75
%77 = load i32, i32* %76
%78 = load i32, i32* %4
%79 = ashr i32 %78, 8
%80 = icmp ne i32 %77, %79
br i1 %80, label %81, label %89
81: ; preds = %72
%82 = load i32, i32* %4
%83 = ashr i32 %82, 8
%84 = load i32, i32* %5
%85 = add nsw i32 %84, 1
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %86
store i32 %83, i32* %87
%88 = call i32 (...) @flexram_wait()
br label %89
89: ; preds = %81, %72
%90 = load i32, i32* %5
%91 = add nsw i32 %90, 3
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %92
%94 = load i32, i32* %93
%95 = load i32, i32* %4
%96 = ashr i32 %95, 24
%97 = icmp ne i32 %94, %96
br i1 %97, label %98, label %106
98: ; preds = %89
%99 = load i32, i32* %4
%100 = ashr i32 %99, 24
%101 = load i32, i32* %5
%102 = add nsw i32 %101, 3
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %103
store i32 %100, i32* %104
%105 = call i32 (...) @flexram_wait()
br label %106
106: ; preds = %98, %89
br label %107
107: ; preds = %10, %27, %58, %106
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 %58, label %6
6: ; preds = %2
%7 = and i32 %4, 3
switch i32 %7, label %31 [
i32 0, label %8
i32 2, label %15
]
8: ; preds = %6
%9 = shl i64 %3, 32
%10 = ashr exact i64 %9, 32
%11 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, %1
br i1 %13, label %58, label %14
14: ; preds = %8
store i32 %1, i32* %11
br label %56
15: ; preds = %6
%16 = shl i64 %3, 32
%17 = ashr exact i64 %16, 32
%18 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %17
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, %1
br i1 %20, label %23, label %21
21: ; preds = %15
store i32 %1, i32* %18
%22 = tail call i32 (...) @flexram_wait()
br label %23
23: ; preds = %21, %15
%24 = add i64 %16, 8589934592
%25 = ashr exact i64 %24, 32
%26 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %25
%27 = load i32, i32* %26
%28 = ashr i32 %1, 16
%29 = icmp eq i32 %27, %28
br i1 %29, label %58, label %30
30: ; preds = %23
store i32 %28, i32* %26
br label %56
31: ; preds = %6
%32 = shl i64 %3, 32
%33 = ashr exact i64 %32, 32
%34 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %33
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, %1
br i1 %36, label %39, label %37
37: ; preds = %31
store i32 %1, i32* %34
%38 = tail call i32 (...) @flexram_wait()
br label %39
39: ; preds = %37, %31
%40 = add i64 %32, 4294967296
%41 = ashr exact i64 %40, 32
%42 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %41
%43 = load i32, i32* %42
%44 = ashr i32 %1, 8
%45 = icmp eq i32 %43, %44
br i1 %45, label %48, label %46
46: ; preds = %39
store i32 %44, i32* %42
%47 = tail call i32 (...) @flexram_wait()
br label %48
48: ; preds = %46, %39
%49 = add i64 %32, 12884901888
%50 = ashr exact i64 %49, 32
%51 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %50
%52 = load i32, i32* %51
%53 = ashr i32 %1, 24
%54 = icmp eq i32 %52, %53
br i1 %54, label %58, label %55
55: ; preds = %48
store i32 %53, i32* %51
br label %56
56: ; preds = %14, %30, %55
%57 = tail call i32 (...) @flexram_wait()
br label %58
58: ; preds = %56, %48, %23, %8, %2
ret void
}