#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 */
int /*<<< orphan*/ assert_failed(char *, int);
void Reset_Handler(void) {
  extern int main(void);
  extern unsigned __data_start__;
  extern unsigned __data_end__;
  extern unsigned const __data_load__;
  extern unsigned __bss_start__;
  extern unsigned __bss_end__;
  unsigned const *src;
  unsigned *dst;
  src = &__data_load__;
  for (dst = &__data_start__; dst < &__data_end__; ++dst, ++src) {
    *dst = *src;
  }
  for (dst = &__bss_start__; dst < &__bss_end__; ++dst) {
    *dst = 0;
  }
  (void)main();
  assert_failed("Reset_Handler", 191);
}


x86 assembly (clang, -O0):
<Reset_Handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ec1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0x2e9e(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
cmp    %rax,-0x10(%rbp)
jae    1178 <Reset_Handler+0x58>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
jmp    113e <Reset_Handler+0x1e>
mov    0x2e41(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e3e(%rip),%rax
cmp    %rax,-0x10(%rbp)
jae    11af <Reset_Handler+0x8f>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x10(%rbp)
jmp    1183 <Reset_Handler+0x63>
call   1030 <main@plt>
lea    0xe45(%rip),%rdi
mov    $0xbf,%esi
call   1040 <assert_failed@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Reset_Handler>:
push   %rax
mov    0x2e90(%rip),%rdi
cmp    0x2e81(%rip),%rdi
jae    1181 <Reset_Handler+0x41>
lea    0x4(%rdi),%rax
mov    0x2e74(%rip),%rcx
cmp    %rax,%rcx
cmova  %rcx,%rax
mov    %rdi,%rcx
not    %rcx
lea    (%rcx,%rax,1),%rdx
add    $0x4,%rdx
and    $0xfffffffffffffffc,%rdx
mov    0x2e74(%rip),%rsi
call   1040 <memcpy@plt>
mov    0x2e38(%rip),%rdi
cmp    0x2e39(%rip),%rdi
jae    11bc <Reset_Handler+0x7c>
lea    0x4(%rdi),%rax
mov    0x2e2c(%rip),%rcx
cmp    %rax,%rcx
cmova  %rcx,%rax
mov    %rdi,%rcx
not    %rcx
lea    (%rcx,%rax,1),%rdx
add    $0x4,%rdx
and    $0xfffffffffffffffc,%rdx
xor    %esi,%esi
call   1030 <memset@plt>
call   1050 <main@plt>
lea    0xe38(%rip),%rdi
mov    $0xbf,%esi
pop    %rax
jmp    1060 <assert_failed@plt>

LLVM IR (-O0):
@__data_load__ = external constant i32
@__data_start__ = external global i32
@__data_end__ = external global i32
@__bss_start__ = external global i32
@__bss_end__ = external global i32
@.str = [14 x i8] c"Reset_Handler\00"
define void @Reset_Handler() {
%1 = alloca i32*
%2 = alloca i32*
store i32* @__data_load__, i32** %1
store i32* @__data_start__, i32** %2
br label %3
3: ; preds = %10, %0
%4 = load i32*, i32** %2
%5 = icmp ult i32* %4, @__data_end__
br i1 %5, label %6, label %15
6: ; preds = %3
%7 = load i32*, i32** %1
%8 = load i32, i32* %7
%9 = load i32*, i32** %2
store i32 %8, i32* %9
br label %10
10: ; preds = %6
%11 = load i32*, i32** %2
%12 = getelementptr inbounds i32, i32* %11, i32 1
store i32* %12, i32** %2
%13 = load i32*, i32** %1
%14 = getelementptr inbounds i32, i32* %13, i32 1
store i32* %14, i32** %1
br label %3
15: ; preds = %3
store i32* @__bss_start__, i32** %2
br label %16
16: ; preds = %21, %15
%17 = load i32*, i32** %2
%18 = icmp ult i32* %17, @__bss_end__
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = load i32*, i32** %2
store i32 0, i32* %20
br label %21
21: ; preds = %19
%22 = load i32*, i32** %2
%23 = getelementptr inbounds i32, i32* %22, i32 1
store i32* %23, i32** %2
br label %16
24: ; preds = %16
%25 = call i32 @main()
%26 = call i32 @assert_failed(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 191)
ret void
}

LLVM IR (-O2):
@__data_load__ = external constant i32
@__data_start__ = external global i32
@__data_end__ = external global i32
@__bss_start__ = external global i32
@__bss_end__ = external global i32
@.str = [14 x i8] c"Reset_Handler\00"
define void @Reset_Handler() {
br i1 icmp ult (i32* @__data_start__, i32* @__data_end__), label %1, label %5
1: ; preds = %0
%2 = call i64 @llvm.umax.i64(i64 ptrtoint (i32* @__data_end__ to i64), i64 add (i64 ptrtoint (i32* @__data_start__ to i64), i64 4))
%3 = add i64 %2, add (i64 xor (i64 ptrtoint (i32* @__data_start__ to i64), i64 -1), i64 4)
%4 = and i64 %3, -4
br label %5
5: ; preds = %1, %0
br i1 icmp ult (i32* @__bss_start__, i32* @__bss_end__), label %6, label %10
6: ; preds = %5
%7 = call i64 @llvm.umax.i64(i64 ptrtoint (i32* @__bss_end__ to i64), i64 add (i64 ptrtoint (i32* @__bss_start__ to i64), i64 4))
%8 = add i64 %7, add (i64 xor (i64 ptrtoint (i32* @__bss_start__ to i64), i64 -1), i64 4)
%9 = and i64 %8, -4
br label %10
10: ; preds = %6, %5
%11 = tail call i32 @main()
%12 = tail call i32 @assert_failed(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 191)
ret void
}