#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*/ main();
void Reset_Handler(void) {
  unsigned long StartUpCounter = 0, HSEStatus = 0;
  *(volatile unsigned long *)0x40021000 |= 0x1 << 16;
  do {
    HSEStatus = (*(volatile unsigned long *)0x40021000 & 0x1 << 17);
    StartUpCounter++;
  } while ((HSEStatus == 0) && (StartUpCounter != 0x0500));
  *(volatile unsigned long *)0x40022000 |= 0x10;
  *(volatile unsigned long *)0x40022000 &= ~0x3;
  *(volatile unsigned long *)0x40022000 |= 0x2;
  *(volatile unsigned long *)0x40021004 &= ~(0xF << 18 | 0x1 << 17 | 0x1 << 16);
  *(volatile unsigned long *)0x40021004 |= (0x7 << 18 | 0x1 << 16);
  *(volatile unsigned long *)0x40021000 |= 0x01 << 24;
  while (((*(volatile unsigned long *)0x40021000) & 0x01 << 25) == 0)
    ;
  *(volatile unsigned long *)0x40021004 &= ~0x3;
  *(volatile unsigned long *)0x40021004 |= 0x2;
  while (((*(volatile unsigned long *)0x40021004) & 0xC) != 0x08)
    ;
  *(volatile unsigned long *)0x40021018 |=
      0x1 << 14 | 0x1 << 4 | 0x1 << 3 | 0x1 << 2 | 0x1 << 0;
  *(volatile unsigned long *)0x40010800 = 0x33333333;
  *(volatile unsigned long *)0x40010804 = 0x333334B3;
  *(volatile unsigned long *)0x40010C00 = 0x33333333;
  *(volatile unsigned long *)0x40010C04 = 0x33333333;
  *(volatile unsigned long *)0x40011004 = 0x33444444;
  *(volatile unsigned long *)0x40013810 = 0x0;
  *(volatile unsigned long *)0x4001380C = 0x200C;
  *(volatile unsigned long *)0x40013814 = 0x0;
  *(volatile unsigned long *)0x40013808 = 39 << 4 | 1;
  *(volatile unsigned long *)0x4001380C |= 0x2000;
  main();
}


x86 assembly (clang, -O0):
<Reset_Handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x40021000,%eax
mov    (%rax),%rcx
or     $0x10000,%rcx
mov    $0x40021000,%eax
mov    %rcx,(%rax)
mov    $0x40021000,%eax
mov    (%rax),%rax
and    $0x20000,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x11(%rbp)
jne    117b <Reset_Handler+0x6b>
cmpq   $0x500,-0x8(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    113f <Reset_Handler+0x2f>
mov    $0x40022000,%eax
mov    (%rax),%rcx
or     $0x10,%rcx
mov    $0x40022000,%eax
mov    %rcx,(%rax)
mov    $0x40022000,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffffc,%rcx
mov    $0x40022000,%eax
mov    %rcx,(%rax)
mov    $0x40022000,%eax
mov    (%rax),%rcx
or     $0x2,%rcx
mov    $0x40022000,%eax
mov    %rcx,(%rax)
mov    $0x40021004,%eax
mov    (%rax),%rcx
and    $0xffffffffffc0ffff,%rcx
mov    $0x40021004,%eax
mov    %rcx,(%rax)
mov    $0x40021004,%eax
mov    (%rax),%rcx
or     $0x1d0000,%rcx
mov    $0x40021004,%eax
mov    %rcx,(%rax)
mov    $0x40021000,%eax
mov    (%rax),%rcx
or     $0x1000000,%rcx
mov    $0x40021000,%eax
mov    %rcx,(%rax)
mov    $0x40021000,%eax
mov    (%rax),%rax
and    $0x2000000,%rax
cmp    $0x0,%rax
jne    1224 <Reset_Handler+0x114>
jmp    1207 <Reset_Handler+0xf7>
mov    $0x40021004,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffffc,%rcx
mov    $0x40021004,%eax
mov    %rcx,(%rax)
mov    $0x40021004,%eax
mov    (%rax),%rcx
or     $0x2,%rcx
mov    $0x40021004,%eax
mov    %rcx,(%rax)
mov    $0x40021004,%eax
mov    (%rax),%rax
and    $0xc,%rax
cmp    $0x8,%rax
je     1267 <Reset_Handler+0x157>
jmp    124c <Reset_Handler+0x13c>
mov    $0x40021018,%eax
mov    (%rax),%rcx
or     $0x401d,%rcx
mov    $0x40021018,%eax
mov    %rcx,(%rax)
mov    $0x40010800,%eax
movq   $0x33333333,(%rax)
mov    $0x40010804,%eax
movq   $0x333334b3,(%rax)
mov    $0x40010c00,%eax
movq   $0x33333333,(%rax)
mov    $0x40010c04,%eax
movq   $0x33333333,(%rax)
mov    $0x40011004,%eax
movq   $0x33444444,(%rax)
mov    $0x40013810,%eax
movq   $0x0,(%rax)
mov    $0x4001380c,%eax
movq   $0x200c,(%rax)
mov    $0x40013814,%eax
movq   $0x0,(%rax)
mov    $0x40013808,%eax
movq   $0x271,(%rax)
mov    $0x4001380c,%eax
mov    (%rax),%rcx
or     $0x2000,%rcx
mov    $0x4001380c,%eax
mov    %rcx,(%rax)
mov    $0x0,%al
call   1030 <main@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Reset_Handler>:
orq    $0x10000,0x40021000
mov    $0x4ff,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rax
setb   %cl
testq  $0x20000,0x40021000
jne    1149 <Reset_Handler+0x39>
test   %cl,%cl
jne    1130 <Reset_Handler+0x20>
orq    $0x10,0x40022000
40 10
andq   $0xfffffffffffffffc,0x40022000
40 fc
orq    $0x2,0x40022000
40 02
andq   $0xffffffffffc0ffff,0x40021004
40 ff ff c0 ff
orq    $0x1d0000,0x40021004
orq    $0x1000000,0x40021000
nopl   0x0(%rax,%rax,1)
testq  $0x2000000,0x40021000
je     1190 <Reset_Handler+0x80>
andq   $0xfffffffffffffffc,0x40021004
40 fc
orq    $0x2,0x40021004
40 02
mov    0x40021004,%rax
40
and    $0xc,%eax
cmp    $0x8,%eax
jne    11b0 <Reset_Handler+0xa0>
orq    $0x401d,0x40021018
movq   $0x33333333,0x40010800
40 33 33 33 33
movq   $0x333334b3,0x40010804
40 b3 34 33 33
movq   $0x33333333,0x40010c00
40 33 33 33 33
movq   $0x33333333,0x40010c04
40 33 33 33 33
movq   $0x33444444,0x40011004
40 44 44 44 33
movq   $0x0,0x40013810
movq   $0x200c,0x4001380c
movq   $0x0,0x40013814
movq   $0x271,0x40013808
orq    $0x2000,0x4001380c
xor    %eax,%eax
jmp    1030 <main@plt>

LLVM IR (-O0):
define void @Reset_Handler() {
%1 = alloca i64
%2 = alloca i64
store i64 0, i64* %1
store i64 0, i64* %2
%3 = load volatile i64, i64* inttoptr (i64 1073876992 to i64*)
%4 = or i64 %3, 65536
store volatile i64 %4, i64* inttoptr (i64 1073876992 to i64*)
br label %5
5: ; preds = %16, %0
%6 = load volatile i64, i64* inttoptr (i64 1073876992 to i64*)
%7 = and i64 %6, 131072
store i64 %7, i64* %2
%8 = load i64, i64* %1
%9 = add i64 %8, 1
store i64 %9, i64* %1
br label %10
10: ; preds = %5
%11 = load i64, i64* %2
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i64, i64* %1
%15 = icmp ne i64 %14, 1280
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ false, %10 ], [ %15, %13 ]
br i1 %17, label %5, label %18
18: ; preds = %16
%19 = load volatile i64, i64* inttoptr (i64 1073881088 to i64*)
%20 = or i64 %19, 16
store volatile i64 %20, i64* inttoptr (i64 1073881088 to i64*)
%21 = load volatile i64, i64* inttoptr (i64 1073881088 to i64*)
%22 = and i64 %21, -4
store volatile i64 %22, i64* inttoptr (i64 1073881088 to i64*)
%23 = load volatile i64, i64* inttoptr (i64 1073881088 to i64*)
%24 = or i64 %23, 2
store volatile i64 %24, i64* inttoptr (i64 1073881088 to i64*)
%25 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%26 = and i64 %25, -4128769
store volatile i64 %26, i64* inttoptr (i64 1073876996 to i64*)
%27 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%28 = or i64 %27, 1900544
store volatile i64 %28, i64* inttoptr (i64 1073876996 to i64*)
%29 = load volatile i64, i64* inttoptr (i64 1073876992 to i64*)
%30 = or i64 %29, 16777216
store volatile i64 %30, i64* inttoptr (i64 1073876992 to i64*)
br label %31
31: ; preds = %35, %18
%32 = load volatile i64, i64* inttoptr (i64 1073876992 to i64*)
%33 = and i64 %32, 33554432
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
br label %31
36: ; preds = %31
%37 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%38 = and i64 %37, -4
store volatile i64 %38, i64* inttoptr (i64 1073876996 to i64*)
%39 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%40 = or i64 %39, 2
store volatile i64 %40, i64* inttoptr (i64 1073876996 to i64*)
br label %41
41: ; preds = %45, %36
%42 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%43 = and i64 %42, 12
%44 = icmp ne i64 %43, 8
br i1 %44, label %45, label %46
45: ; preds = %41
br label %41
46: ; preds = %41
%47 = load volatile i64, i64* inttoptr (i64 1073877016 to i64*)
%48 = or i64 %47, 16413
store volatile i64 %48, i64* inttoptr (i64 1073877016 to i64*)
store volatile i64 858993459, i64* inttoptr (i64 1073809408 to i64*)
store volatile i64 858993843, i64* inttoptr (i64 1073809412 to i64*)
store volatile i64 858993459, i64* inttoptr (i64 1073810432 to i64*)
store volatile i64 858993459, i64* inttoptr (i64 1073810436 to i64*)
store volatile i64 860111940, i64* inttoptr (i64 1073811460 to i64*)
store volatile i64 0, i64* inttoptr (i64 1073821712 to i64*)
store volatile i64 8204, i64* inttoptr (i64 1073821708 to i64*)
store volatile i64 0, i64* inttoptr (i64 1073821716 to i64*)
store volatile i64 625, i64* inttoptr (i64 1073821704 to i64*)
%49 = load volatile i64, i64* inttoptr (i64 1073821708 to i64*)
%50 = or i64 %49, 8192
store volatile i64 %50, i64* inttoptr (i64 1073821708 to i64*)
%51 = call i32 (...) @main()
ret void
}

LLVM IR (-O2):
define void @Reset_Handler() {
%1 = load volatile i64, i64* inttoptr (i64 1073876992 to i64*)
%2 = or i64 %1, 65536
store volatile i64 %2, i64* inttoptr (i64 1073876992 to i64*)
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %7, %3 ]
%5 = load volatile i64, i64* inttoptr (i64 1073876992 to i64*)
%6 = and i64 %5, 131072
%7 = add nuw nsw i64 %4, 1
%8 = icmp eq i64 %6, 0
%9 = icmp ne i64 %7, 1280
%10 = select i1 %8, i1 %9, i1 false
br i1 %10, label %3, label %11
11: ; preds = %3
%12 = load volatile i64, i64* inttoptr (i64 1073881088 to i64*)
%13 = or i64 %12, 16
store volatile i64 %13, i64* inttoptr (i64 1073881088 to i64*)
%14 = load volatile i64, i64* inttoptr (i64 1073881088 to i64*)
%15 = and i64 %14, -4
store volatile i64 %15, i64* inttoptr (i64 1073881088 to i64*)
%16 = load volatile i64, i64* inttoptr (i64 1073881088 to i64*)
%17 = or i64 %16, 2
store volatile i64 %17, i64* inttoptr (i64 1073881088 to i64*)
%18 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%19 = and i64 %18, -4128769
store volatile i64 %19, i64* inttoptr (i64 1073876996 to i64*)
%20 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%21 = or i64 %20, 1900544
store volatile i64 %21, i64* inttoptr (i64 1073876996 to i64*)
%22 = load volatile i64, i64* inttoptr (i64 1073876992 to i64*)
%23 = or i64 %22, 16777216
store volatile i64 %23, i64* inttoptr (i64 1073876992 to i64*)
br label %24
24: ; preds = %24, %11
%25 = load volatile i64, i64* inttoptr (i64 1073876992 to i64*)
%26 = and i64 %25, 33554432
%27 = icmp eq i64 %26, 0
br i1 %27, label %24, label %28
28: ; preds = %24
%29 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%30 = and i64 %29, -4
store volatile i64 %30, i64* inttoptr (i64 1073876996 to i64*)
%31 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%32 = or i64 %31, 2
store volatile i64 %32, i64* inttoptr (i64 1073876996 to i64*)
br label %33
33: ; preds = %33, %28
%34 = load volatile i64, i64* inttoptr (i64 1073876996 to i64*)
%35 = and i64 %34, 12
%36 = icmp eq i64 %35, 8
br i1 %36, label %37, label %33
37: ; preds = %33
%38 = load volatile i64, i64* inttoptr (i64 1073877016 to i64*)
%39 = or i64 %38, 16413
store volatile i64 %39, i64* inttoptr (i64 1073877016 to i64*)
store volatile i64 858993459, i64* inttoptr (i64 1073809408 to i64*)
store volatile i64 858993843, i64* inttoptr (i64 1073809412 to i64*)
store volatile i64 858993459, i64* inttoptr (i64 1073810432 to i64*)
store volatile i64 858993459, i64* inttoptr (i64 1073810436 to i64*)
store volatile i64 860111940, i64* inttoptr (i64 1073811460 to i64*)
store volatile i64 0, i64* inttoptr (i64 1073821712 to i64*)
store volatile i64 8204, i64* inttoptr (i64 1073821708 to i64*)
store volatile i64 0, i64* inttoptr (i64 1073821716 to i64*)
store volatile i64 625, i64* inttoptr (i64 1073821704 to i64*)
%40 = load volatile i64, i64* inttoptr (i64 1073821708 to i64*)
%41 = or i64 %40, 8192
store volatile i64 %41, i64* inttoptr (i64 1073821708 to i64*)
%42 = tail call i32 (...) @main()
ret void
}