void thread(void) {
  while (1) {
    if (isPressed((1 << 2) | (1 << 10))) {
      screenShot(0);
      screenShot(1);
    }
    if (isPressed((1 << 3) | (1 << 10))) {
      memdump(L"sdmc:/AXIWRAM.bin", (unsigned char *)0x1FF80000, 0x00080000);
      memdump(L"sdmc:/FCRAM.bin", (unsigned char *)0x20000000, 0x010000000);
    }
    patches();
  }
  __asm("SVC 0x09");
}


x86 assembly (clang, -O0):
<thread>:
push   %rbp
mov    %rsp,%rbp
jmp    1149 <thread+0x9>
mov    $0x404,%edi
mov    $0x0,%al
call   1050 <isPressed@plt>
cmp    $0x0,%eax
je     1173 <thread+0x33>
xor    %edi,%edi
mov    $0x0,%al
call   1030 <screenShot@plt>
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <screenShot@plt>
mov    $0x408,%edi
mov    $0x0,%al
call   1050 <isPressed@plt>
cmp    $0x0,%eax
je     11b8 <thread+0x78>
lea    0xe71(%rip),%rdi
mov    $0x1ff80000,%esi
mov    $0x80000,%edx
mov    $0x0,%al
call   1040 <memdump@plt>
lea    0xea1(%rip),%rdi
mov    $0x20000000,%esi
mov    $0x10000000,%edx
mov    $0x0,%al
call   1040 <memdump@plt>
mov    $0x0,%al
call   1060 <patches@plt>
jmp    1149 <thread+0x9>

x86 assembly (clang, -O2):
<thread>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%r14
lea    0xef6(%rip),%rbx
jmp    1167 <thread+0x27>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <patches@plt>
mov    $0x404,%edi
xor    %eax,%eax
call   1050 <isPressed@plt>
test   %eax,%eax
je     118c <thread+0x4c>
xor    %edi,%edi
xor    %eax,%eax
call   1030 <screenShot@plt>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <screenShot@plt>
mov    $0x408,%edi
xor    %eax,%eax
call   1050 <isPressed@plt>
test   %eax,%eax
je     1160 <thread+0x20>
mov    $0x1ff80000,%esi
mov    %r14,%rdi
mov    $0x80000,%edx
xor    %eax,%eax
call   1040 <memdump@plt>
mov    $0x20000000,%esi
mov    %rbx,%rdi
mov    $0x10000000,%edx
xor    %eax,%eax
call   1040 <memdump@plt>
jmp    1160 <thread+0x20>

LLVM IR (-O0):
@.str = [18 x i32] [i32 115, i32 100, i32 109, i32 99, i32 58, i32 47, i32 65, i32 88, i32 73, i32 87, i32 82, i32 65, i32 77, i32 46, i32 98, i32 105, i32 110, i32 0]
@.str.1 = [16 x i32] [i32 115, i32 100, i32 109, i32 99, i32 58, i32 47, i32 70, i32 67, i32 82, i32 65, i32 77, i32 46, i32 98, i32 105, i32 110, i32 0]
define void @thread() {
br label %1
1: ; preds = %0, %13
%2 = call i32 (i32, ...) bitcast (i32 (...)* @isPressed to i32 (i32, ...)*)(i32 1028)
%3 = icmp ne i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = call i32 (i32, ...) bitcast (i32 (...)* @screenShot to i32 (i32, ...)*)(i32 0)
%6 = call i32 (i32, ...) bitcast (i32 (...)* @screenShot to i32 (i32, ...)*)(i32 1)
br label %7
7: ; preds = %4, %1
%8 = call i32 (i32, ...) bitcast (i32 (...)* @isPressed to i32 (i32, ...)*)(i32 1032)
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = call i32 (i32*, i8*, i32, ...) bitcast (i32 (...)* @memdump to i32 (i32*, i8*, i32, ...)*)(i32* getelementptr inbounds ([18 x i32], [18 x i32]* @.str, i64 0, i64 0), i8* inttoptr (i64 536346624 to i8*), i32 524288)
%12 = call i32 (i32*, i8*, i32, ...) bitcast (i32 (...)* @memdump to i32 (i32*, i8*, i32, ...)*)(i32* getelementptr inbounds ([16 x i32], [16 x i32]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 536870912 to i8*), i32 268435456)
br label %13
13: ; preds = %10, %7
%14 = call i32 (...) @patches()
br label %1
}

LLVM IR (-O2):
@.str = [18 x i32] [i32 115, i32 100, i32 109, i32 99, i32 58, i32 47, i32 65, i32 88, i32 73, i32 87, i32 82, i32 65, i32 77, i32 46, i32 98, i32 105, i32 110, i32 0]
@.str.1 = [16 x i32] [i32 115, i32 100, i32 109, i32 99, i32 58, i32 47, i32 70, i32 67, i32 82, i32 65, i32 77, i32 46, i32 98, i32 105, i32 110, i32 0]
define void @thread() {
br label %1
1: ; preds = %0, %13
%2 = tail call i32 (i32, ...) bitcast (i32 (...)* @isPressed to i32 (i32, ...)*)(i32 1028)
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @screenShot to i32 (i32, ...)*)(i32 0)
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @screenShot to i32 (i32, ...)*)(i32 1)
br label %7
7: ; preds = %4, %1
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @isPressed to i32 (i32, ...)*)(i32 1032)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 (i32*, i8*, i32, ...) bitcast (i32 (...)* @memdump to i32 (i32*, i8*, i32, ...)*)(i32* getelementptr inbounds ([18 x i32], [18 x i32]* @.str, i64 0, i64 0), i8* inttoptr (i64 536346624 to i8*), i32 524288)
%12 = tail call i32 (i32*, i8*, i32, ...) bitcast (i32 (...)* @memdump to i32 (i32*, i8*, i32, ...)*)(i32* getelementptr inbounds ([16 x i32], [16 x i32]* @.str.1, i64 0, i64 0), i8* inttoptr (i64 536870912 to i8*), i32 268435456)
br label %13
13: ; preds = %10, %7
%14 = tail call i32 (...) @patches()
br label %1
}