#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;

/* Variables and functions */
int /*<<< orphan*/ eeprom_initialize();
uint32_t eeprom_read_dword(const uint32_t *addr) {
  uint32_t offset = (uint32_t)addr;
  if (offset >= 2048 - 3)
    return 0;
  if (!((*(volatile uint8_t *)0x40020001) & ((uint8_t)0x01)))
    eeprom_initialize();
  return *(uint32_t *)(&((uint8_t *)0x14000000)[offset]);
}


x86 assembly (clang, -O0):
<eeprom_read_dword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x14(%rbp)
cmpl   $0x7fd,-0x14(%rbp)
jl     113c <eeprom_read_dword+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    1165 <eeprom_read_dword+0x55>
mov    $0x40020001,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    1156 <eeprom_read_dword+0x46>
mov    $0x0,%al
call   1030 <eeprom_initialize@plt>
movslq -0x14(%rbp),%rcx
mov    $0x14000000,%eax
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eeprom_read_dword>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
cmp    $0x7fc,%ebx
jg     113a <eeprom_read_dword+0x2a>
mov    0x40020001,%eax
test   $0x1,%al
jne    1130 <eeprom_read_dword+0x20>
xor    %eax,%eax
call   1030 <eeprom_initialize@plt>
movslq %ebx,%rax
mov    0x14000000(,%rax,4),%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @eeprom_read_dword(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
%5 = load i32*, i32** %3
%6 = ptrtoint i32* %5 to i32
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp sge i32 %7, 2045
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %21
10: ; preds = %1
%11 = load volatile i32, i32* inttoptr (i64 1073872897 to i32*)
%12 = and i32 %11, 1
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 (...) @eeprom_initialize()
br label %16
16: ; preds = %14, %10
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %18
%20 = load i32, i32* %19
store i32 %20, i32* %2
br label %21
21: ; preds = %16, %9
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
define i32 @eeprom_read_dword(i32* %0) {
%2 = ptrtoint i32* %0 to i64
%3 = trunc i64 %2 to i32
%4 = icmp sgt i32 %3, 2044
br i1 %4, label %16, label %5
5: ; preds = %1
%6 = load volatile i32, i32* inttoptr (i64 1073872897 to i32*)
%7 = and i32 %6, 1
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 (...) @eeprom_initialize()
br label %11
11: ; preds = %9, %5
%12 = shl i64 %2, 32
%13 = ashr exact i64 %12, 32
%14 = getelementptr inbounds i32, i32* inttoptr (i64 335544320 to i32*), i64 %13
%15 = load i32, i32* %14
br label %16
16: ; preds = %1, %11
%17 = phi i32 [ %15, %11 ], [ 0, %1 ]
ret i32 %17
}