#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*/ run(char *, char **);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void restoreHandler(char *command, int argc, char **argv) {
  char *cmd[10];
  char *str;
  char *str1;
  char str3[128];
  if (!strcmp(command, "cp") || !strcmp(command, "CP")) {
    strcpy(str3, "cust/backup/");
    strcat(str3, argv[1]);
    cmd[0] = "/sbin/busybox";
    cmd[1] = "rm";
    cmd[2] = argv[1];
    cmd[3] = NULL;
    run(cmd[0], cmd);
    cmd[1] = "cp";
    cmd[2] = "-a";
    cmd[3] = str3;
    cmd[4] = argv[1];
    cmd[5] = NULL;
    run(cmd[0], cmd);
  } else if (!strcmp(command, "rm") || !strcmp(command, "RM")) {
    strcpy(str3, "cust/backup/");
    strcat(str3, argv[0]);
    cmd[0] = "/sbin/busybox";
    cmd[1] = "cp";
    cmd[2] = "-a";
    cmd[3] = str3;
    cmd[4] = argv[0];
    cmd[5] = NULL;
    run(cmd[0], cmd);
  }
}


x86 assembly (clang, -O0):
<restoreHandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     1188 <restoreHandler+0x48>
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    122d <restoreHandler+0xed>
lea    -0x100(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
call   1060 <strcat@plt>
lea    0xe5d(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe60(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
movq   $0x0,-0x58(%rbp)
mov    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <run@plt>
lea    0xe13(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe2c(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    -0x100(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <run@plt>
jmp    12d6 <restoreHandler+0x196>
mov    -0x8(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
je     125f <restoreHandler+0x11f>
mov    -0x8(%rbp),%rdi
lea    0xdd6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12d1 <restoreHandler+0x191>
lea    -0x100(%rbp),%rdi
lea    0xd99(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x100(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1060 <strcat@plt>
lea    0xd87(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xd69(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xd82(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    -0x100(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <run@plt>
jmp    12d6 <restoreHandler+0x196>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<restoreHandler>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xd8,%rsp
mov    %rdx,%r15
mov    %rdi,%rbx
lea    0xea5(%rip),%r14
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1205 <restoreHandler+0xc5>
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1205 <restoreHandler+0xc5>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11ac <restoreHandler+0x6c>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    128d <restoreHandler+0x14d>
lea    0xe53(%rip),%rsi
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    (%r15),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xe41(%rip),%rdi
mov    %rdi,(%rsp)
mov    %r14,0x8(%rsp)
lea    0xe42(%rip),%rax
mov    %rax,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    (%r15),%rax
mov    %rax,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    %rsp,%rsi
jmp    1288 <restoreHandler+0x148>
lea    0xdfa(%rip),%rsi
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    0x8(%r15),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
lea    0xde7(%rip),%rdi
mov    %rdi,(%rsp)
lea    0xdea(%rip),%rax
mov    %rax,0x8(%rsp)
mov    0x8(%r15),%rax
mov    %rax,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    %rsp,%r12
mov    %r12,%rsi
call   1040 <run@plt>
mov    %r14,0x8(%rsp)
lea    0xdbf(%rip),%rax
mov    %rax,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    0x8(%r15),%rax
mov    %rax,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    (%rsp),%rdi
mov    %r12,%rsi
call   1040 <run@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"cp\00"
@.str.1 = [3 x i8] c"CP\00"
@.str.2 = [13 x i8] c"cust/backup/\00"
@.str.3 = [14 x i8] c"/sbin/busybox\00"
@.str.4 = [3 x i8] c"rm\00"
@.str.5 = [3 x i8] c"-a\00"
@.str.6 = [3 x i8] c"RM\00"
define void @restoreHandler(i8* %0, i32 %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8**
%7 = alloca [10 x i8*]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [128 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8** %2, i8*** %6
%11 = load i8*, i8** %4
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %3
%15 = load i8*, i8** %4
%16 = call i32 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp ne i32 %16, 0
br i1 %17, label %50, label %18
18: ; preds = %14, %3
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%20 = call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%22 = load i8**, i8*** %6
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcat(i8* %21, i8* %24)
%26 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %26
%27 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %27
%28 = load i8**, i8*** %6
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 2
store i8* %30, i8** %31
%32 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 3
store i8* null, i8** %32
%33 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%34 = load i8*, i8** %33
%35 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%36 = call i32 @run(i8* %34, i8** %35)
%37 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %37
%38 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %38
%39 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%40 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 3
store i8* %39, i8** %40
%41 = load i8**, i8*** %6
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 4
store i8* %43, i8** %44
%45 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 5
store i8* null, i8** %45
%46 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%47 = load i8*, i8** %46
%48 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%49 = call i32 @run(i8* %47, i8** %48)
br label %81
50: ; preds = %14
%51 = load i8*, i8** %4
%52 = call i32 @strcmp(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = load i8*, i8** %4
%56 = call i32 @strcmp(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%57 = icmp ne i32 %56, 0
br i1 %57, label %80, label %58
58: ; preds = %54, %50
%59 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%60 = call i32 @strcpy(i8* %59, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%61 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%62 = load i8**, i8*** %6
%63 = getelementptr inbounds i8*, i8** %62, i64 0
%64 = load i8*, i8** %63
%65 = call i32 @strcat(i8* %61, i8* %64)
%66 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %66
%67 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %67
%68 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %68
%69 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%70 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 3
store i8* %69, i8** %70
%71 = load i8**, i8*** %6
%72 = getelementptr inbounds i8*, i8** %71, i64 0
%73 = load i8*, i8** %72
%74 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 4
store i8* %73, i8** %74
%75 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 5
store i8* null, i8** %75
%76 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%77 = load i8*, i8** %76
%78 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%79 = call i32 @run(i8* %77, i8** %78)
br label %80
80: ; preds = %58, %54
br label %81
81: ; preds = %80, %18
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"cp\00"
@.str.1 = [3 x i8] c"CP\00"
@.str.2 = [13 x i8] c"cust/backup/\00"
@.str.3 = [14 x i8] c"/sbin/busybox\00"
@.str.4 = [3 x i8] c"rm\00"
@.str.5 = [3 x i8] c"-a\00"
@.str.6 = [3 x i8] c"RM\00"
define void @restoreHandler(i8* nocapture %0, i32 %1, i8** nocapture %2) {
%4 = alloca [10 x i8*]
%5 = alloca [128 x i8]
%6 = bitcast [10 x i8*]* %4 to i8*
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %10, %3
%14 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%15 = getelementptr inbounds i8*, i8** %2, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @strcat(i8* %7, i8* %16)
%18 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8** %19
%20 = load i8*, i8** %15
%21 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 2
store i8* %20, i8** %21
%22 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 3
store i8* null, i8** %22
%23 = call i32 @run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %18)
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %19
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %21
store i8* %7, i8** %22
%24 = load i8*, i8** %15
%25 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 4
store i8* %24, i8** %25
%26 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 5
store i8* null, i8** %26
%27 = load i8*, i8** %18
%28 = call i32 @run(i8* %27, i8** %18)
br label %47
29: ; preds = %10
%30 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %47
35: ; preds = %32, %29
%36 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%37 = load i8*, i8** %2
%38 = call i32 @strcat(i8* %7, i8* %37)
%39 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %39
%40 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %40
%41 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %41
%42 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 3
store i8* %7, i8** %42
%43 = load i8*, i8** %2
%44 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 4
store i8* %43, i8** %44
%45 = getelementptr inbounds [10 x i8*], [10 x i8*]* %4, i64 0, i64 5
store i8* null, i8** %45
%46 = call i32 @run(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %39)
br label %47
47: ; preds = %32, %35, %13
ret void
}