#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 */
scalar_t__ fmem_get_byte(int /*<<< orphan*/);
unsigned long arm_get_reset_vector(void) {
  unsigned long vector;
  unsigned long adr = 0x04;
  vector = (unsigned long)fmem_get_byte(adr++);
  vector |= ((unsigned long)fmem_get_byte(adr++)) << 8;
  vector |= ((unsigned long)fmem_get_byte(adr++)) << 16;
  vector |= ((unsigned long)fmem_get_byte(adr++)) << 24;
  vector &= 0x0fffffffe;
  return vector;
}


x86 assembly (clang, -O0):
<arm_get_reset_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x4,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    %eax,%edi
call   1030 <fmem_get_byte@plt>
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    %eax,%edi
call   1030 <fmem_get_byte@plt>
shl    $0x8,%rax
or     -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    %eax,%edi
call   1030 <fmem_get_byte@plt>
shl    $0x10,%rax
or     -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    %eax,%edi
call   1030 <fmem_get_byte@plt>
shl    $0x18,%rax
or     -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
movabs $0xfffffffe,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<arm_get_reset_vector>:
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
call   1030 <fmem_get_byte@plt>
mov    %rax,%r14
mov    $0x5,%edi
call   1030 <fmem_get_byte@plt>
mov    %rax,%rbx
shl    $0x8,%ebx
or     %r14d,%ebx
mov    $0x6,%edi
call   1030 <fmem_get_byte@plt>
mov    %rax,%r14
shl    $0x10,%r14d
mov    $0x7,%edi
call   1030 <fmem_get_byte@plt>
shl    $0x18,%eax
or     %r14d,%eax
or     %ebx,%eax
and    $0xfffffffe,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @arm_get_reset_vector() {
%1 = alloca i64
%2 = alloca i64
store i64 4, i64* %2
%3 = load i64, i64* %2
%4 = add i64 %3, 1
store i64 %4, i64* %2
%5 = trunc i64 %3 to i32
%6 = call i64 @fmem_get_byte(i32 %5)
store i64 %6, i64* %1
%7 = load i64, i64* %2
%8 = add i64 %7, 1
store i64 %8, i64* %2
%9 = trunc i64 %7 to i32
%10 = call i64 @fmem_get_byte(i32 %9)
%11 = shl i64 %10, 8
%12 = load i64, i64* %1
%13 = or i64 %12, %11
store i64 %13, i64* %1
%14 = load i64, i64* %2
%15 = add i64 %14, 1
store i64 %15, i64* %2
%16 = trunc i64 %14 to i32
%17 = call i64 @fmem_get_byte(i32 %16)
%18 = shl i64 %17, 16
%19 = load i64, i64* %1
%20 = or i64 %19, %18
store i64 %20, i64* %1
%21 = load i64, i64* %2
%22 = add i64 %21, 1
store i64 %22, i64* %2
%23 = trunc i64 %21 to i32
%24 = call i64 @fmem_get_byte(i32 %23)
%25 = shl i64 %24, 24
%26 = load i64, i64* %1
%27 = or i64 %26, %25
store i64 %27, i64* %1
%28 = load i64, i64* %1
%29 = and i64 %28, 4294967294
store i64 %29, i64* %1
%30 = load i64, i64* %1
ret i64 %30
}

LLVM IR (-O2):
define i64 @arm_get_reset_vector() {
%1 = tail call i64 @fmem_get_byte(i32 4)
%2 = tail call i64 @fmem_get_byte(i32 5)
%3 = shl i64 %2, 8
%4 = or i64 %3, %1
%5 = tail call i64 @fmem_get_byte(i32 6)
%6 = shl i64 %5, 16
%7 = or i64 %4, %6
%8 = tail call i64 @fmem_get_byte(i32 7)
%9 = shl i64 %8, 24
%10 = or i64 %7, %9
%11 = and i64 %10, 4294967294
ret i64 %11
}