#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*/ RB_AUTOBOOT;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int reboot(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int usage();
int /*<<< orphan*/ wipe(char *);
int wipe_main(int argc, char *argv[]) {
  char *whatToWipe;
  if (argc != 2)
    return usage();
  whatToWipe = argv[1];
  if (0 == strcmp(whatToWipe, "system")) {
    fprintf(stdout, "Wiping /system\n");
    wipe("/system");
    fprintf(stdout, "Done wiping /android\n");
  } else if (0 == strcmp(whatToWipe, "data")) {
    fprintf(stdout, "Wiping /data\n");
    wipe("/data");
    fprintf(stdout, "Done wiping /data\n");
  } else if (0 == strcmp(whatToWipe, "all")) {
    fprintf(stdout, "Wiping /system and /data\n");
    wipe("/system");
    wipe("/data");
    fprintf(stdout, "Done wiping /system and /data\n");
  } else if (0 == strcmp(whatToWipe, "nuke")) {
    int ret;
    fprintf(stdout, "Nuking the device...\n");
    wipe("/system");
    wipe("/data");
    fprintf(stdout, "Device nuked! Rebooting...\n");
    ret = reboot(RB_AUTOBOOT);
    if (ret < 0) {
      fprintf(stderr, "Reboot failed, %s\n", strerror(errno));
      return 1;
    }
  } else {
    return usage();
  }
  return 0;
}


x86 assembly (clang, -O0):
<wipe_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1188 <wipe_main+0x28>
mov    $0x0,%al
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    139a <wipe_main+0x23a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11f1 <wipe_main+0x91>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    0xe40(%rip),%rdi
call   1050 <wipe@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1393 <wipe_main+0x233>
mov    -0x18(%rbp),%rdi
lea    0xe41(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    124e <wipe_main+0xee>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    0xe0f(%rip),%rdi
call   1050 <wipe@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    138e <wipe_main+0x22e>
mov    -0x18(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12b7 <wipe_main+0x157>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    0xd86(%rip),%rdi
call   1050 <wipe@plt>
lea    0xda6(%rip),%rdi
call   1050 <wipe@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1389 <wipe_main+0x229>
mov    -0x18(%rbp),%rdi
lea    0xdd0(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1375 <wipe_main+0x215>
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
lea    0xdb2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
lea    0xd1d(%rip),%rdi
call   1050 <wipe@plt>
lea    0xd3d(%rip),%rdi
call   1050 <wipe@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
call   1070 <reboot@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1370 <wipe_main+0x210>
mov    0x2ca3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
lea    0xd6c(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    139a <wipe_main+0x23a>
jmp    1384 <wipe_main+0x224>
mov    $0x0,%al
call   1060 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    139a <wipe_main+0x23a>
jmp    1389 <wipe_main+0x229>
jmp    138e <wipe_main+0x22e>
jmp    1393 <wipe_main+0x233>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wipe_main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11c4 <wipe_main+0x64>
mov    0x8(%rsi),%rbx
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d1 <wipe_main+0x71>
lea    0xeb6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1201 <wipe_main+0xa1>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1231 <wipe_main+0xd1>
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     127b <wipe_main+0x11b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <usage@plt>
mov    0x2df8(%rip),%rbx
mov    (%rbx),%edi
lea    0xe1f(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xe1f(%rip),%rdi
call   1050 <wipe@plt>
mov    (%rbx),%edi
lea    0xe19(%rip),%rsi
jmp    126b <wipe_main+0x10b>
mov    0x2dc8(%rip),%rbx
mov    (%rbx),%edi
lea    0xe1d(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xe1b(%rip),%rdi
call   1050 <wipe@plt>
mov    (%rbx),%edi
lea    0xe13(%rip),%rsi
jmp    126b <wipe_main+0x10b>
mov    0x2d98(%rip),%rbx
mov    (%rbx),%edi
lea    0xe18(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xdbf(%rip),%rdi
call   1050 <wipe@plt>
lea    0xddf(%rip),%rdi
call   1050 <wipe@plt>
mov    (%rbx),%edi
lea    0xe08(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2d4e(%rip),%rbx
mov    (%rbx),%edi
lea    0xe0c(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xd75(%rip),%rdi
call   1050 <wipe@plt>
lea    0xd95(%rip),%rdi
call   1050 <wipe@plt>
mov    (%rbx),%edi
lea    0xdf8(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
call   1070 <reboot@plt>
test   %eax,%eax
jns    1272 <wipe_main+0x112>
mov    0x2d0b(%rip),%rax
mov    (%rax),%ebx
mov    0x2cfa(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xddd(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%ebp
jmp    1272 <wipe_main+0x112>

LLVM IR (-O0):
@.str = [7 x i8] c"system\00"
@stdout = global i32 0
@.str.1 = [16 x i8] c"Wiping /system\0A\00"
@.str.2 = [8 x i8] c"/system\00"
@.str.3 = [22 x i8] c"Done wiping /android\0A\00"
@.str.4 = [5 x i8] c"data\00"
@.str.5 = [14 x i8] c"Wiping /data\0A\00"
@.str.6 = [6 x i8] c"/data\00"
@.str.7 = [19 x i8] c"Done wiping /data\0A\00"
@.str.8 = [4 x i8] c"all\00"
@.str.9 = [26 x i8] c"Wiping /system and /data\0A\00"
@.str.10 = [31 x i8] c"Done wiping /system and /data\0A\00"
@.str.11 = [5 x i8] c"nuke\00"
@.str.12 = [22 x i8] c"Nuking the device...\0A\00"
@.str.13 = [28 x i8] c"Device nuked! Rebooting...\0A\00"
@RB_AUTOBOOT = global i32 0
@stderr = global i32 0
@.str.14 = [19 x i8] c"Reboot failed, %s\0A\00"
@errno = global i32 0
define i32 @wipe_main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @usage()
store i32 %11, i32* %3
br label %73
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%18 = icmp eq i64 0, %17
br i1 %18, label %19, label %25
19: ; preds = %12
%20 = load i32, i32* @stdout
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @wipe(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @stdout
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %72
25: ; preds = %12
%26 = load i8*, i8** %6
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i64 0, %27
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i32, i32* @stdout
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%32 = call i32 @wipe(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%33 = load i32, i32* @stdout
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %71
35: ; preds = %25
%36 = load i8*, i8** %6
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%38 = icmp eq i64 0, %37
br i1 %38, label %39, label %46
39: ; preds = %35
%40 = load i32, i32* @stdout
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%42 = call i32 @wipe(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%43 = call i32 @wipe(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%44 = load i32, i32* @stdout
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
br label %70
46: ; preds = %35
%47 = load i8*, i8** %6
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%49 = icmp eq i64 0, %48
br i1 %49, label %50, label %67
50: ; preds = %46
%51 = load i32, i32* @stdout
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0))
%53 = call i32 @wipe(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 @wipe(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%55 = load i32, i32* @stdout
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%57 = load i32, i32* @RB_AUTOBOOT
%58 = call i32 @reboot(i32 %57)
store i32 %58, i32* %7
%59 = load i32, i32* %7
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %50
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i8* %64)
store i32 1, i32* %3
br label %73
66: ; preds = %50
br label %69
67: ; preds = %46
%68 = call i32 (...) @usage()
store i32 %68, i32* %3
br label %73
69: ; preds = %66
br label %70
70: ; preds = %69, %39
br label %71
71: ; preds = %70, %29
br label %72
72: ; preds = %71, %19
store i32 0, i32* %3
br label %73
73: ; preds = %72, %67, %61, %10
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@.str = [7 x i8] c"system\00"
@stdout = global i32 0
@.str.1 = [16 x i8] c"Wiping /system\0A\00"
@.str.2 = [8 x i8] c"/system\00"
@.str.3 = [22 x i8] c"Done wiping /android\0A\00"
@.str.4 = [5 x i8] c"data\00"
@.str.5 = [14 x i8] c"Wiping /data\0A\00"
@.str.6 = [6 x i8] c"/data\00"
@.str.7 = [19 x i8] c"Done wiping /data\0A\00"
@.str.8 = [4 x i8] c"all\00"
@.str.9 = [26 x i8] c"Wiping /system and /data\0A\00"
@.str.10 = [31 x i8] c"Done wiping /system and /data\0A\00"
@.str.11 = [5 x i8] c"nuke\00"
@.str.12 = [22 x i8] c"Nuking the device...\0A\00"
@.str.13 = [28 x i8] c"Device nuked! Rebooting...\0A\00"
@RB_AUTOBOOT = global i32 0
@stderr = global i32 0
@.str.14 = [19 x i8] c"Reboot failed, %s\0A\00"
@errno = global i32 0
define i32 @wipe_main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %56
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %6
%12 = load i32, i32* @stdout
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @wipe(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdout
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %56
17: ; preds = %6
%18 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* @stdout
%22 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%23 = tail call i32 @wipe(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%24 = load i32, i32* @stdout
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
br label %56
26: ; preds = %17
%27 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i32, i32* @stdout
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
%32 = tail call i32 @wipe(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%33 = tail call i32 @wipe(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%34 = load i32, i32* @stdout
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0))
br label %56
36: ; preds = %26
%37 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %54
39: ; preds = %36
%40 = load i32, i32* @stdout
%41 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0))
%42 = tail call i32 @wipe(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%43 = tail call i32 @wipe(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%44 = load i32, i32* @stdout
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%46 = load i32, i32* @RB_AUTOBOOT
%47 = tail call i32 @reboot(i32 %46)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %39
%50 = load i32, i32* @stderr
%51 = load i32, i32* @errno
%52 = tail call i8* @strerror(i32 %51)
%53 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0), i8* %52)
br label %56
54: ; preds = %36
%55 = tail call i32 (...) @usage()
br label %56
56: ; preds = %11, %29, %20, %39, %49, %54, %4
%57 = phi i32 [ %5, %4 ], [ 1, %49 ], [ %55, %54 ], [ 0, %39 ], [ 0, %20 ], [ 0, %29 ], [ 0, %11 ]
ret i32 %57
}