#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*/ DFU_file();
int /*<<< orphan*/ IMG3();
int /*<<< orphan*/ Ramdisk();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fgetn();
int /*<<< orphan*/ get_keybags();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ ipswDownloader();
int /*<<< orphan*/ kernelcache();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rootfs();
int /*<<< orphan*/ swag_logo();
int main(int argc, char const *argv[]) {
  int choice;
  char loop[5];
  swag_logo();
  ipswDownloader();
  swag_logo();
  printf("Which file you want to decrypt ?\n");
  printf(" 1) Root Filesystem\n");
  printf(" 2) Ramdisk\n");
  printf(" 3) IMG3 File\n");
  printf(" 4) DFU File\n");
  printf(" 5) Kernelcache\n");
  printf(" 6) Grab Keybags\n");
  printf("> ");
  choice = fgetn();
  switch (choice) {
  case 1:
    swag_logo();
    rootfs();
    break;
  case 2:
    swag_logo();
    Ramdisk();
    break;
  case 3:
    swag_logo();
    IMG3();
    break;
  case 4:
    swag_logo();
    DFU_file();
    break;
  case 5:
    swag_logo();
    kernelcache();
    break;
  case 6:
    swag_logo();
    get_keybags();
    break;
  case 0:
    exit(0);
  default:
    printf("No option available yet\n");
  }
  printf("Press [ENTER] to quit the tool\n");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   10d0 <swag_logo@plt>
mov    -0x29(%rbp),%al
call   1090 <ipswDownloader@plt>
mov    -0x29(%rbp),%al
call   10d0 <swag_logo@plt>
lea    0xe25(%rip),%rdi
call   1040 <printf@plt>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4f(%rip),%rdi
call   1040 <printf@plt>
lea    0xe55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
call   10a0 <fgetn@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x6,%rax
ja     12f9 <main+0x139>
mov    -0x28(%rbp),%rax
lea    0xd89(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   10d0 <swag_logo@plt>
mov    $0x0,%al
call   1050 <rootfs@plt>
jmp    1305 <main+0x145>
mov    $0x0,%al
call   10d0 <swag_logo@plt>
mov    $0x0,%al
call   10b0 <Ramdisk@plt>
jmp    1305 <main+0x145>
mov    $0x0,%al
call   10d0 <swag_logo@plt>
mov    $0x0,%al
call   10c0 <IMG3@plt>
jmp    1305 <main+0x145>
mov    $0x0,%al
call   10d0 <swag_logo@plt>
mov    $0x0,%al
call   1030 <DFU_file@plt>
jmp    1305 <main+0x145>
mov    $0x0,%al
call   10d0 <swag_logo@plt>
mov    $0x0,%al
call   1060 <kernelcache@plt>
jmp    1305 <main+0x145>
mov    $0x0,%al
call   10d0 <swag_logo@plt>
mov    $0x0,%al
call   1080 <get_keybags@plt>
jmp    1305 <main+0x145>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xda3(%rip),%rdi
call   1040 <printf@plt>
lea    0xdb0(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   10e0 <swag_logo@plt>
xor    %eax,%eax
call   10a0 <ipswDownloader@plt>
xor    %eax,%eax
call   10e0 <swag_logo@plt>
lea    0xe32(%rip),%rdi
call   1040 <puts@plt>
lea    0xe47(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
lea    0xe51(%rip),%rdi
call   1040 <puts@plt>
lea    0xe52(%rip),%rdi
call   1040 <puts@plt>
lea    0xe56(%rip),%rdi
call   1040 <puts@plt>
lea    0xddb(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   10b0 <fgetn@plt>
cmp    $0x6,%eax
ja     1274 <main+0xa4>
mov    %eax,%eax
lea    0xda5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   10e0 <swag_logo@plt>
xor    %eax,%eax
call   1060 <rootfs@plt>
jmp    12d0 <main+0x100>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
jmp    12d0 <main+0x100>
xor    %eax,%eax
call   10e0 <swag_logo@plt>
xor    %eax,%eax
call   10c0 <Ramdisk@plt>
jmp    12d0 <main+0x100>
xor    %eax,%eax
call   10e0 <swag_logo@plt>
xor    %eax,%eax
call   10d0 <IMG3@plt>
jmp    12d0 <main+0x100>
xor    %eax,%eax
call   10e0 <swag_logo@plt>
xor    %eax,%eax
call   1030 <DFU_file@plt>
jmp    12d0 <main+0x100>
xor    %eax,%eax
call   10e0 <swag_logo@plt>
xor    %eax,%eax
call   1070 <kernelcache@plt>
jmp    12d0 <main+0x100>
xor    %eax,%eax
call   10e0 <swag_logo@plt>
xor    %eax,%eax
call   1090 <get_keybags@plt>
lea    0xdc5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1080 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"Which file you want to decrypt ?\0A\00"
@.str.1 = [21 x i8] c" 1) Root Filesystem\0A\00"
@.str.2 = [13 x i8] c" 2) Ramdisk\0A\00"
@.str.3 = [15 x i8] c" 3) IMG3 File\0A\00"
@.str.4 = [14 x i8] c" 4) DFU File\0A\00"
@.str.5 = [17 x i8] c" 5) Kernelcache\0A\00"
@.str.6 = [18 x i8] c" 6) Grab Keybags\0A\00"
@.str.7 = [3 x i8] c"> \00"
@.str.8 = [25 x i8] c"No option available yet\0A\00"
@.str.9 = [32 x i8] c"Press [ENTER] to quit the tool\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [5 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @swag_logo()
%9 = call i32 (...) @ipswDownloader()
%10 = call i32 (...) @swag_logo()
%11 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 (...) @fgetn()
store i32 %19, i32* %6
%20 = load i32, i32* %6
switch i32 %20, label %41 [
i32 1, label %21
i32 2, label %24
i32 3, label %27
i32 4, label %30
i32 5, label %33
i32 6, label %36
i32 0, label %39
]
21: ; preds = %2
%22 = call i32 (...) @swag_logo()
%23 = call i32 (...) @rootfs()
br label %43
24: ; preds = %2
%25 = call i32 (...) @swag_logo()
%26 = call i32 (...) @Ramdisk()
br label %43
27: ; preds = %2
%28 = call i32 (...) @swag_logo()
%29 = call i32 (...) @IMG3()
br label %43
30: ; preds = %2
%31 = call i32 (...) @swag_logo()
%32 = call i32 (...) @DFU_file()
br label %43
33: ; preds = %2
%34 = call i32 (...) @swag_logo()
%35 = call i32 (...) @kernelcache()
br label %43
36: ; preds = %2
%37 = call i32 (...) @swag_logo()
%38 = call i32 (...) @get_keybags()
br label %43
39: ; preds = %2
%40 = call i32 @exit(i32 0)
unreachable
41: ; preds = %2
%42 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0))
br label %43
43: ; preds = %41, %36, %33, %30, %27, %24, %21
%44 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
%45 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.7 = [3 x i8] c"> \00"
@str = [33 x i8] c"Which file you want to decrypt ?\00"
@str.10 = [20 x i8] c" 1) Root Filesystem\00"
@str.11 = [12 x i8] c" 2) Ramdisk\00"
@str.12 = [14 x i8] c" 3) IMG3 File\00"
@str.13 = [13 x i8] c" 4) DFU File\00"
@str.14 = [16 x i8] c" 5) Kernelcache\00"
@str.15 = [17 x i8] c" 6) Grab Keybags\00"
@str.16 = [31 x i8] c"Press [ENTER] to quit the tool\00"
@str.17 = [24 x i8] c"No option available yet\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @swag_logo()
%4 = tail call i32 (...) @ipswDownloader()
%5 = tail call i32 (...) @swag_logo()
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.10, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.11, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.14, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.15, i64 0, i64 0))
%13 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%14 = tail call i32 (...) @fgetn()
switch i32 %14, label %35 [
i32 1, label %15
i32 2, label %18
i32 3, label %21
i32 4, label %24
i32 5, label %27
i32 6, label %30
i32 0, label %33
]
15: ; preds = %2
%16 = tail call i32 (...) @swag_logo()
%17 = tail call i32 (...) @rootfs()
br label %37
18: ; preds = %2
%19 = tail call i32 (...) @swag_logo()
%20 = tail call i32 (...) @Ramdisk()
br label %37
21: ; preds = %2
%22 = tail call i32 (...) @swag_logo()
%23 = tail call i32 (...) @IMG3()
br label %37
24: ; preds = %2
%25 = tail call i32 (...) @swag_logo()
%26 = tail call i32 (...) @DFU_file()
br label %37
27: ; preds = %2
%28 = tail call i32 (...) @swag_logo()
%29 = tail call i32 (...) @kernelcache()
br label %37
30: ; preds = %2
%31 = tail call i32 (...) @swag_logo()
%32 = tail call i32 (...) @get_keybags()
br label %37
33: ; preds = %2
%34 = tail call i32 @exit(i32 0)
unreachable
35: ; preds = %2
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.17, i64 0, i64 0))
br label %37
37: ; preds = %35, %30, %27, %24, %21, %18, %15
%38 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.16, i64 0, i64 0))
%39 = tail call i32 (...) @getchar()
ret i32 0
}