#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*/ rxTools();
void main() {
  int fbfound = 0;
  unsigned char *screen = 0x20000000;
  for (int i = 0; i < 0x30; i++) {
    if (*((unsigned int *)(screen + i + 0)) == 0xABADF00D &&
        *((unsigned int *)(screen + i + 4)) == 0xDEADBEEF) {
      fbfound = 1;
      screen += i;
    }
  }
  if (!fbfound) {
    screen = 0x20046500;
    for (int i = 0; i < 0x30; i++) {
      if (*((unsigned int *)(screen + i + 0)) == 0xABADF00D &&
          *((unsigned int *)(screen + i + 4)) == 0xDEADBEEF) {
        fbfound = 1;
        screen += i;
      }
    }
  }
  *((unsigned int *)0x080FFFC0) = 0x20000010;
  *((unsigned int *)0x080FFFC4) = 0x20046520;
  *((unsigned int *)0x080FFFD8) = 0;
  unsigned int *buf = 0x20400000;
  unsigned int base = 0x67893421;
  unsigned int seed = 0x12756342;
  for (int i = 0; i < 400 * 1024 / 4; i++) {
    buf[i] ^= base;
    base += seed;
  }
  unsigned char *src = 0x20400000;
  unsigned char *dst = 0x08000000;
  for (int i = 0; i < 320 * 1024; i++) {
    dst[i] = src[i];
  }
  *(unsigned int *)0x10000020 = 0;
  *(unsigned int *)0x10000020 = 0x340;
  rxTools();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x20000000,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x30,-0x14(%rbp)
jge    118f <main+0x7f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0xabadf00d,(%rax,%rcx,1)
jne    117c <main+0x6c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0xdeadbeef,0x4(%rax,%rcx,1)
de
jne    117c <main+0x6c>
movl   $0x1,-0x4(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1181 <main+0x71>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112f <main+0x1f>
cmpl   $0x0,-0x4(%rbp)
jne    120e <main+0xfe>
mov    $0x20046500,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x30,-0x18(%rbp)
jge    1209 <main+0xf9>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0xabadf00d,(%rax,%rcx,1)
jne    11f6 <main+0xe6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0xdeadbeef,0x4(%rax,%rcx,1)
de
jne    11f6 <main+0xe6>
movl   $0x1,-0x4(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    11fb <main+0xeb>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a9 <main+0x99>
jmp    120e <main+0xfe>
mov    $0x80fffc0,%eax
movl   $0x20000010,(%rax)
mov    $0x80fffc4,%eax
movl   $0x20046520,(%rax)
mov    $0x80fffd8,%eax
movl   $0x0,(%rax)
mov    $0x20400000,%eax
mov    %rax,-0x20(%rbp)
movl   $0x67893421,-0x24(%rbp)
movl   $0x12756342,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x19000,-0x2c(%rbp)
jge    1282 <main+0x172>
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xor    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    124d <main+0x13d>
mov    $0x20400000,%eax
mov    %rax,-0x38(%rbp)
mov    $0x8000000,%eax
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x50000,-0x44(%rbp)
jge    12cc <main+0x1bc>
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    129b <main+0x18b>
mov    $0x10000020,%eax
movl   $0x0,(%rax)
mov    $0x10000020,%eax
movl   $0x340,(%rax)
mov    $0x0,%al
call   1030 <rxTools@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x20400000,%eax
movl   $0x20000010,0x80fffc0
movl   $0x20046520,0x80fffc4
20 65 04 20
movl   $0x0,0x80fffd8
movdqa 0xec2(%rip),%xmm0
mov    $0xc,%ecx
movdqa 0xec5(%rip),%xmm1
movdqa 0xecd(%rip),%xmm2
movdqa 0xed5(%rip),%xmm3
movdqa 0xedd(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqa %xmm0,%xmm5
paddd  %xmm1,%xmm5
movdqa -0x30(%rax,%rcx,4),%xmm6
pxor   %xmm0,%xmm6
pxor   -0x20(%rax,%rcx,4),%xmm5
movdqa %xmm6,-0x30(%rax,%rcx,4)
movdqa %xmm5,-0x20(%rax,%rcx,4)
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm0,%xmm6
pxor   -0x10(%rax,%rcx,4),%xmm5
paddd  %xmm3,%xmm6
pxor   (%rax,%rcx,4),%xmm6
movdqa %xmm5,-0x10(%rax,%rcx,4)
movdqa %xmm6,(%rax,%rcx,4)
paddd  %xmm4,%xmm0
add    $0x10,%rcx
cmp    $0x1900c,%rcx
jne    1170 <main+0x60>
mov    $0x90,%ecx
movaps -0x90(%rax,%rcx,1),%xmm0
ff
movaps -0x80(%rax,%rcx,1),%xmm1
movdqa -0x70(%rax,%rcx,1),%xmm2
movdqa -0x60(%rax,%rcx,1),%xmm3
movaps %xmm0,-0x18400090(%rax,%rcx,1)
e7
movaps %xmm1,-0x18400080(%rax,%rcx,1)
e7
movdqa %xmm2,-0x18400070(%rax,%rcx,1)
movdqa %xmm3,-0x18400060(%rax,%rcx,1)
bf e7
movaps -0x50(%rax,%rcx,1),%xmm0
movaps -0x40(%rax,%rcx,1),%xmm1
movaps %xmm0,-0x18400050(%rax,%rcx,1)
e7
movaps %xmm1,-0x18400040(%rax,%rcx,1)
e7
movaps -0x30(%rax,%rcx,1),%xmm0
movaps -0x20(%rax,%rcx,1),%xmm1
movaps %xmm0,-0x18400030(%rax,%rcx,1)
e7
movaps %xmm1,-0x18400020(%rax,%rcx,1)
e7
movdqa -0x10(%rax,%rcx,1),%xmm0
movdqa (%rax,%rcx,1),%xmm1
movdqa %xmm0,-0x18400010(%rax,%rcx,1)
bf e7
movdqa %xmm1,-0x18400000(%rax,%rcx,1)
c0 e7
add    $0xa0,%rcx
cmp    $0x50090,%rcx
jne    11d0 <main+0xc0>
movl   $0x340,0x10000020
xor    %eax,%eax
jmp    1030 <rxTools@plt>

LLVM IR (-O0):
define void @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32 0, i32* %1
store i8* inttoptr (i64 536870912 to i8*), i8** %2
store i32 0, i32* %3
br label %12
12: ; preds = %39, %0
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 48
br i1 %14, label %15, label %42
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = bitcast i8* %20 to i32*
%22 = load i32, i32* %21
%23 = icmp eq i32 %22, -1414664179
br i1 %23, label %24, label %38
24: ; preds = %15
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = getelementptr inbounds i8, i8* %28, i64 4
%30 = bitcast i8* %29 to i32*
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, -559038737
br i1 %32, label %33, label %38
33: ; preds = %24
store i32 1, i32* %1
%34 = load i32, i32* %3
%35 = load i8*, i8** %2
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8, i8* %35, i64 %36
store i8* %37, i8** %2
br label %38
38: ; preds = %33, %24, %15
br label %39
39: ; preds = %38
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %12
42: ; preds = %12
%43 = load i32, i32* %1
%44 = icmp ne i32 %43, 0
br i1 %44, label %77, label %45
45: ; preds = %42
store i8* inttoptr (i64 537158912 to i8*), i8** %2
store i32 0, i32* %4
br label %46
46: ; preds = %73, %45
%47 = load i32, i32* %4
%48 = icmp slt i32 %47, 48
br i1 %48, label %49, label %76
49: ; preds = %46
%50 = load i8*, i8** %2
%51 = load i32, i32* %4
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = getelementptr inbounds i8, i8* %53, i64 0
%55 = bitcast i8* %54 to i32*
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, -1414664179
br i1 %57, label %58, label %72
58: ; preds = %49
%59 = load i8*, i8** %2
%60 = load i32, i32* %4
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = getelementptr inbounds i8, i8* %62, i64 4
%64 = bitcast i8* %63 to i32*
%65 = load i32, i32* %64
%66 = icmp eq i32 %65, -559038737
br i1 %66, label %67, label %72
67: ; preds = %58
store i32 1, i32* %1
%68 = load i32, i32* %4
%69 = load i8*, i8** %2
%70 = sext i32 %68 to i64
%71 = getelementptr inbounds i8, i8* %69, i64 %70
store i8* %71, i8** %2
br label %72
72: ; preds = %67, %58, %49
br label %73
73: ; preds = %72
%74 = load i32, i32* %4
%75 = add nsw i32 %74, 1
store i32 %75, i32* %4
br label %46
76: ; preds = %46
br label %77
77: ; preds = %76, %42
store i32 536870928, i32* inttoptr (i64 135266240 to i32*)
store i32 537158944, i32* inttoptr (i64 135266244 to i32*)
store i32 0, i32* inttoptr (i64 135266264 to i32*)
store i32* inttoptr (i64 541065216 to i32*), i32** %5
store i32 1737045025, i32* %6
store i32 309683010, i32* %7
store i32 0, i32* %8
br label %78
78: ; preds = %92, %77
%79 = load i32, i32* %8
%80 = icmp slt i32 %79, 102400
br i1 %80, label %81, label %95
81: ; preds = %78
%82 = load i32, i32* %6
%83 = load i32*, i32** %5
%84 = load i32, i32* %8
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i32, i32* %83, i64 %85
%87 = load i32, i32* %86
%88 = xor i32 %87, %82
store i32 %88, i32* %86
%89 = load i32, i32* %7
%90 = load i32, i32* %6
%91 = add i32 %90, %89
store i32 %91, i32* %6
br label %92
92: ; preds = %81
%93 = load i32, i32* %8
%94 = add nsw i32 %93, 1
store i32 %94, i32* %8
br label %78
95: ; preds = %78
store i8* inttoptr (i64 541065216 to i8*), i8** %9
store i8* inttoptr (i64 134217728 to i8*), i8** %10
store i32 0, i32* %11
br label %96
96: ; preds = %109, %95
%97 = load i32, i32* %11
%98 = icmp slt i32 %97, 327680
br i1 %98, label %99, label %112
99: ; preds = %96
%100 = load i8*, i8** %9
%101 = load i32, i32* %11
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %100, i64 %102
%104 = load i8, i8* %103
%105 = load i8*, i8** %10
%106 = load i32, i32* %11
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %105, i64 %107
store i8 %104, i8* %108
br label %109
109: ; preds = %99
%110 = load i32, i32* %11
%111 = add nsw i32 %110, 1
store i32 %111, i32* %11
br label %96
112: ; preds = %96
store i32 0, i32* inttoptr (i64 268435488 to i32*)
store i32 832, i32* inttoptr (i64 268435488 to i32*)
%113 = call i32 (...) @rxTools()
ret void
}

LLVM IR (-O2):
define void @main() {
store i32 536870928, i32* inttoptr (i64 135266240 to i32*)
store i32 537158944, i32* inttoptr (i64 135266244 to i32*)
store i32 0, i32* inttoptr (i64 135266264 to i32*)
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %28, %1 ]
%3 = phi <4 x i32> [ <i32 1737045025, i32 2046728035, i32 -1938556251, i32 -1628873241>, %0 ], [ %29, %1 ]
%4 = add <4 x i32> %3, <i32 1238732040, i32 1238732040, i32 1238732040, i32 1238732040>
%5 = getelementptr inbounds i32, i32* inttoptr (i64 541065216 to i32*), i64 %2
%6 = bitcast i32* %5 to <4 x i32>*
%7 = load <4 x i32>, <4 x i32>* %6
%8 = getelementptr inbounds i32, i32* %5, i64 4
%9 = bitcast i32* %8 to <4 x i32>*
%10 = load <4 x i32>, <4 x i32>* %9
%11 = xor <4 x i32> %7, %3
%12 = xor <4 x i32> %10, %4
%13 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> %11, <4 x i32>* %13
%14 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> %12, <4 x i32>* %14
%15 = or i64 %2, 8
%16 = add <4 x i32> %3, <i32 -1817503216, i32 -1817503216, i32 -1817503216, i32 -1817503216>
%17 = add <4 x i32> %3, <i32 -578771176, i32 -578771176, i32 -578771176, i32 -578771176>
%18 = getelementptr inbounds i32, i32* inttoptr (i64 541065216 to i32*), i64 %15
%19 = bitcast i32* %18 to <4 x i32>*
%20 = load <4 x i32>, <4 x i32>* %19
%21 = getelementptr inbounds i32, i32* %18, i64 4
%22 = bitcast i32* %21 to <4 x i32>*
%23 = load <4 x i32>, <4 x i32>* %22
%24 = xor <4 x i32> %20, %16
%25 = xor <4 x i32> %23, %17
%26 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %24, <4 x i32>* %26
%27 = bitcast i32* %21 to <4 x i32>*
store <4 x i32> %25, <4 x i32>* %27
%28 = add nuw nsw i64 %2, 16
%29 = add <4 x i32> %3, <i32 659960864, i32 659960864, i32 659960864, i32 659960864>
%30 = icmp eq i64 %28, 102400
br i1 %30, label %31, label %1
31: ; preds = %1, %31
%32 = phi i64 [ %87, %31 ], [ 0, %1 ]
%33 = getelementptr inbounds i8, i8* inttoptr (i64 541065216 to i8*), i64 %32
%34 = bitcast i8* %33 to <16 x i8>*
%35 = load <16 x i8>, <16 x i8>* %34
%36 = getelementptr inbounds i8, i8* %33, i64 16
%37 = bitcast i8* %36 to <16 x i8>*
%38 = load <16 x i8>, <16 x i8>* %37
%39 = getelementptr inbounds i8, i8* inttoptr (i64 134217728 to i8*), i64 %32
%40 = bitcast i8* %39 to <16 x i8>*
store <16 x i8> %35, <16 x i8>* %40
%41 = getelementptr inbounds i8, i8* %39, i64 16
%42 = bitcast i8* %41 to <16 x i8>*
store <16 x i8> %38, <16 x i8>* %42
%43 = add nuw nsw i64 %32, 32
%44 = getelementptr inbounds i8, i8* inttoptr (i64 541065216 to i8*), i64 %43
%45 = bitcast i8* %44 to <16 x i8>*
%46 = load <16 x i8>, <16 x i8>* %45
%47 = getelementptr inbounds i8, i8* %44, i64 16
%48 = bitcast i8* %47 to <16 x i8>*
%49 = load <16 x i8>, <16 x i8>* %48
%50 = getelementptr inbounds i8, i8* inttoptr (i64 134217728 to i8*), i64 %43
%51 = bitcast i8* %50 to <16 x i8>*
store <16 x i8> %46, <16 x i8>* %51
%52 = getelementptr inbounds i8, i8* %50, i64 16
%53 = bitcast i8* %52 to <16 x i8>*
store <16 x i8> %49, <16 x i8>* %53
%54 = add nuw nsw i64 %32, 64
%55 = getelementptr inbounds i8, i8* inttoptr (i64 541065216 to i8*), i64 %54
%56 = bitcast i8* %55 to <16 x i8>*
%57 = load <16 x i8>, <16 x i8>* %56
%58 = getelementptr inbounds i8, i8* %55, i64 16
%59 = bitcast i8* %58 to <16 x i8>*
%60 = load <16 x i8>, <16 x i8>* %59
%61 = getelementptr inbounds i8, i8* inttoptr (i64 134217728 to i8*), i64 %54
%62 = bitcast i8* %61 to <16 x i8>*
store <16 x i8> %57, <16 x i8>* %62
%63 = getelementptr inbounds i8, i8* %61, i64 16
%64 = bitcast i8* %63 to <16 x i8>*
store <16 x i8> %60, <16 x i8>* %64
%65 = add nuw nsw i64 %32, 96
%66 = getelementptr inbounds i8, i8* inttoptr (i64 541065216 to i8*), i64 %65
%67 = bitcast i8* %66 to <16 x i8>*
%68 = load <16 x i8>, <16 x i8>* %67
%69 = getelementptr inbounds i8, i8* %66, i64 16
%70 = bitcast i8* %69 to <16 x i8>*
%71 = load <16 x i8>, <16 x i8>* %70
%72 = getelementptr inbounds i8, i8* inttoptr (i64 134217728 to i8*), i64 %65
%73 = bitcast i8* %72 to <16 x i8>*
store <16 x i8> %68, <16 x i8>* %73
%74 = getelementptr inbounds i8, i8* %72, i64 16
%75 = bitcast i8* %74 to <16 x i8>*
store <16 x i8> %71, <16 x i8>* %75
%76 = add nuw nsw i64 %32, 128
%77 = getelementptr inbounds i8, i8* inttoptr (i64 541065216 to i8*), i64 %76
%78 = bitcast i8* %77 to <16 x i8>*
%79 = load <16 x i8>, <16 x i8>* %78
%80 = getelementptr inbounds i8, i8* %77, i64 16
%81 = bitcast i8* %80 to <16 x i8>*
%82 = load <16 x i8>, <16 x i8>* %81
%83 = getelementptr inbounds i8, i8* inttoptr (i64 134217728 to i8*), i64 %76
%84 = bitcast i8* %83 to <16 x i8>*
store <16 x i8> %79, <16 x i8>* %84
%85 = getelementptr inbounds i8, i8* %83, i64 16
%86 = bitcast i8* %85 to <16 x i8>*
store <16 x i8> %82, <16 x i8>* %86
%87 = add nuw nsw i64 %32, 160
%88 = icmp eq i64 %87, 327680
br i1 %88, label %89, label %31
89: ; preds = %31
store i32 832, i32* inttoptr (i64 268435488 to i32*)
%90 = tail call i32 (...) @rxTools()
ret void
}