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

/* Variables and functions */
scalar_t__ checkAddress(scalar_t__);
int /*<<< orphan*/ sFLASH_ReadBuffer(void *, scalar_t__, size_t);
int sFLASH_ReadSingleByte(int);
void HAL_EEPROM_Get(uint32_t index, void *data, size_t length) {
  if (checkAddress(index)) {
    if (sFLASH_ReadSingleByte(0x03E000 + 0x200) != 1) {
      sFLASH_ReadBuffer(data, 0x03F000 + index, length);
    } else {
      sFLASH_ReadBuffer(data, 0x03E000 + index, length);
    }
  }
}


x86 assembly (clang, -O0):
<HAL_EEPROM_Get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <checkAddress@plt>
cmp    $0x0,%rax
je     11a4 <HAL_EEPROM_Get+0x74>
mov    $0x3e200,%edi
call   1050 <sFLASH_ReadSingleByte@plt>
cmp    $0x1,%eax
je     1187 <HAL_EEPROM_Get+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x3f000,%rsi
mov    -0x18(%rbp),%rdx
call   1040 <sFLASH_ReadBuffer@plt>
jmp    119f <HAL_EEPROM_Get+0x6f>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x3e000,%rsi
mov    -0x18(%rbp),%rdx
call   1040 <sFLASH_ReadBuffer@plt>
jmp    11a4 <HAL_EEPROM_Get+0x74>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HAL_EEPROM_Get>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <checkAddress@plt>
test   %rax,%rax
je     1179 <HAL_EEPROM_Get+0x49>
mov    $0x3e200,%edi
call   1050 <sFLASH_ReadSingleByte@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
setne  %cl
shl    $0xc,%rcx
lea    (%rcx,%rbx,1),%rsi
add    $0x3e000,%rsi
mov    %r15,%rdi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <sFLASH_ReadBuffer@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @HAL_EEPROM_Get(i64 %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i64
store i64 %0, i64* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i64, i64* %4
%8 = call i64 @checkAddress(i64 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %3
%11 = call i32 @sFLASH_ReadSingleByte(i32 254464)
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i8*, i8** %5
%15 = load i64, i64* %4
%16 = add nsw i64 258048, %15
%17 = load i64, i64* %6
%18 = call i32 @sFLASH_ReadBuffer(i8* %14, i64 %16, i64 %17)
br label %25
19: ; preds = %10
%20 = load i8*, i8** %5
%21 = load i64, i64* %4
%22 = add nsw i64 253952, %21
%23 = load i64, i64* %6
%24 = call i32 @sFLASH_ReadBuffer(i8* %20, i64 %22, i64 %23)
br label %25
25: ; preds = %19, %13
br label %26
26: ; preds = %25, %3
ret void
}

LLVM IR (-O2):
define void @HAL_EEPROM_Get(i64 %0, i8* %1, i64 %2) {
%4 = tail call i64 @checkAddress(i64 %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = tail call i32 @sFLASH_ReadSingleByte(i32 254464)
%8 = icmp eq i32 %7, 1
%9 = select i1 %8, i64 253952, i64 258048
%10 = add nsw i64 %9, %0
%11 = tail call i32 @sFLASH_ReadBuffer(i8* %1, i64 %10, i64 %2)
br label %12
12: ; preds = %6, %3
ret void
}