#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 */
int /*<<< orphan*/ main();
void ResetIntHandler() {
  extern uint32_t _etext, _data, _edata, _bss, _ebss;
  uint32_t *src = &_etext, *dst = &_data;
  while (dst < &_edata)
    *(dst++) = *(src++);
  for (dst = &_bss; dst < &_ebss; dst++)
    *dst = 0;
  main();
  while (1)
    ;
}


x86 assembly (clang, -O0):
<ResetIntHandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2eb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0x2e9e(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e8b(%rip),%rax
cmp    %rax,-0x10(%rbp)
jae    1168 <ResetIntHandler+0x58>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,(%rax)
jmp    112e <ResetIntHandler+0x1e>
mov    0x2e71(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e6e(%rip),%rax
cmp    %rax,-0x10(%rbp)
jae    11a0 <ResetIntHandler+0x90>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1173 <ResetIntHandler+0x63>
mov    $0x0,%al
call   1030 <main@plt>
jmp    11a7 <ResetIntHandler+0x97>

x86 assembly (clang, -O2):
<ResetIntHandler>:
push   %rax
mov    0x2e90(%rip),%rdi
cmp    0x2e81(%rip),%rdi
jae    1171 <ResetIntHandler+0x41>
lea    0x8(%rdi),%rax
mov    0x2e74(%rip),%rcx
cmp    %rax,%rcx
cmova  %rcx,%rax
mov    %rdi,%rcx
not    %rcx
lea    (%rcx,%rax,1),%rdx
add    $0x8,%rdx
and    $0xfffffffffffffff8,%rdx
mov    0x2e64(%rip),%rsi
call   1040 <memcpy@plt>
mov    0x2e68(%rip),%rdi
cmp    0x2e69(%rip),%rdi
jae    11ac <ResetIntHandler+0x7c>
lea    0x8(%rdi),%rax
mov    0x2e5c(%rip),%rcx
cmp    %rax,%rcx
cmova  %rcx,%rax
mov    %rdi,%rcx
not    %rcx
lea    (%rcx,%rax,1),%rdx
add    $0x8,%rdx
and    $0xfffffffffffffff8,%rdx
xor    %esi,%esi
call   1030 <memset@plt>
xor    %eax,%eax
call   1050 <main@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
jmp    11c0 <ResetIntHandler+0x90>

LLVM IR (-O0):
@_etext = external global i64
@_data = external global i64
@_edata = external global i64
@_bss = external global i64
@_ebss = external global i64
define void @ResetIntHandler() {
%1 = alloca i64*
%2 = alloca i64*
store i64* @_etext, i64** %1
store i64* @_data, i64** %2
br label %3
3: ; preds = %6, %0
%4 = load i64*, i64** %2
%5 = icmp ult i64* %4, @_edata
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = load i64*, i64** %1
%8 = getelementptr inbounds i64, i64* %7, i32 1
store i64* %8, i64** %1
%9 = load i64, i64* %7
%10 = load i64*, i64** %2
%11 = getelementptr inbounds i64, i64* %10, i32 1
store i64* %11, i64** %2
store i64 %9, i64* %10
br label %3
12: ; preds = %3
store i64* @_bss, i64** %2
br label %13
13: ; preds = %18, %12
%14 = load i64*, i64** %2
%15 = icmp ult i64* %14, @_ebss
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i64*, i64** %2
store i64 0, i64* %17
br label %18
18: ; preds = %16
%19 = load i64*, i64** %2
%20 = getelementptr inbounds i64, i64* %19, i32 1
store i64* %20, i64** %2
br label %13
21: ; preds = %13
%22 = call i32 (...) @main()
br label %23
23: ; preds = %21, %23
br label %23
}

LLVM IR (-O2):
@_etext = external global i64
@_data = external global i64
@_edata = external global i64
@_bss = external global i64
@_ebss = external global i64
define void @ResetIntHandler() {
br i1 icmp ult (i64* @_data, i64* @_edata), label %1, label %5
1: ; preds = %0
%2 = call i64 @llvm.umax.i64(i64 ptrtoint (i64* @_edata to i64), i64 add (i64 ptrtoint (i64* @_data to i64), i64 8))
%3 = add i64 %2, add (i64 xor (i64 ptrtoint (i64* @_data to i64), i64 -1), i64 8)
%4 = and i64 %3, -8
br label %5
5: ; preds = %1, %0
br i1 icmp ult (i64* @_bss, i64* @_ebss), label %6, label %10
6: ; preds = %5
%7 = call i64 @llvm.umax.i64(i64 ptrtoint (i64* @_ebss to i64), i64 add (i64 ptrtoint (i64* @_bss to i64), i64 8))
%8 = add i64 %7, add (i64 xor (i64 ptrtoint (i64* @_bss to i64), i64 -1), i64 8)
%9 = and i64 %8, -8
br label %10
10: ; preds = %6, %5
%11 = tail call i32 (...) @main()
br label %12
12: ; preds = %12, %10
br label %12
}