// File: greenpau[P]mnpa/main.cpp
// Function: stop()
void stop() {
    std::string pid_title = "Name:\\tmnpa";
    int pid = -1;
    std::string stop_pid = std::to_string(getpid());
    DIR *dp = opendir("/proc");
    if (dp == NULL) {
        logit(ERROR,"failed to open /proc directory");
        exit(1);
    }
    struct dirent *dir;
    std::vector<pid_t> pids;
    std::regex stop_pid_rgx ("Name:\\tmnpa");
    while (pid < 0 && (dir = readdir(dp))) {
        int cid = atoi(dir->d_name);
        if (cid > 0) {
            std::string cur_pid = std::to_string(cid);
            std::string cur_pid_file = "/proc/" + cur_pid + "/status";
            std::ifstream cid_fs;
            cid_fs.open(cur_pid_file, std::ifstream::in);
            if (cid_fs.is_open()) {
                std::string cur_pid_status;
                getline(cid_fs, cur_pid_status);
                cid_fs.close();
                if (std::regex_match(cur_pid_status, stop_pid_rgx)) {
                    if (stop_pid != cur_pid) {
                        pids.push_back(cid);
                    }
                }
            }
        }
    }
    if (pids.size() > 0) {
        logit(INFO,"mnpa is running, stopping processes ...");
        for (auto &i : pids) {
            kill(i, SIGQUIT);
        }
        sleep(5);
        for (auto &i : pids) {
            if (kill(i, 0) == 0) {
                logit(INFO,"mnpa with PID #" + std::to_string(i) + " is still running!");
            } else {
                logit(INFO,"mnpa with PID #" + std::to_string(i) + " was stopped successfully");
            }
        }
    } else {
        logit(INFO,"mnpa is not running ...");
    }
    closedir(dp);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x500, %rsp            # imm = 0x500
leaq -0x21(%rbp), %rdi
movq %rdi, -0x4b0(%rbp)
callq 0x54db0
movq -0x4b0(%rbp), %rdx
leaq 0xe893d(%rip), %rsi     # 0x1021a6
leaq -0x20(%rbp), %rdi
callq 0x235f0
jmp 0x19874
leaq -0x21(%rbp), %rdi
callq 0x54dd0
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
callq 0x162d0
movl %eax, %esi
leaq -0x58(%rbp), %rdi
callq 0x23760
jmp 0x19896
leaq 0xe8915(%rip), %rdi     # 0x1021b2
callq 0x163a0
movq %rax, -0x4b8(%rbp)
jmp 0x198ab
movq -0x4b8(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x1998c
leaq -0x81(%rbp), %rdi
movq %rdi, -0x4c0(%rbp)
callq 0x54db0
movq -0x4c0(%rbp), %rdx
leaq 0xe88d6(%rip), %rsi     # 0x1021b8
leaq -0x80(%rbp), %rdi
callq 0x235f0
jmp 0x198ed
movl $0x2, %edi
leaq -0x80(%rbp), %rsi
callq 0x196f0
jmp 0x198fd
leaq -0x80(%rbp), %rdi
callq 0xcf470
leaq -0x81(%rbp), %rdi
callq 0x54dd0
movl $0x1, %edi
callq 0x161b0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x21(%rbp), %rdi
callq 0x54dd0
jmp 0x1a0aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1a0a1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1a098
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1997b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xcf470
leaq -0x81(%rbp), %rdi
callq 0x54dd0
jmp 0x1a098
leaq -0xa8(%rbp), %rdi
callq 0x23880
leaq 0xe8807(%rip), %rsi     # 0x1021a6
leaq -0xc8(%rbp), %rdi
movl $0x10, %edx
callq 0x238a0
jmp 0x199b2
jmp 0x199b4
xorl %eax, %eax
cmpl $0x0, -0x38(%rbp)
movb %al, -0x4c1(%rbp)
jge 0x199ef
movq -0x60(%rbp), %rdi
callq 0x16400
movq %rax, -0x4d0(%rbp)
jmp 0x199d4
movq -0x4d0(%rbp), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, %rax
setne %al
movb %al, -0x4c1(%rbp)
movb -0x4c1(%rbp), %al
testb $0x1, %al
jne 0x199fe
jmp 0x19c41
movq -0x90(%rbp), %rdi
addq $0x13, %rdi
callq 0x16530
movl %eax, -0xcc(%rbp)
cmpl $0x0, -0xcc(%rbp)
jle 0x19c3c
movl -0xcc(%rbp), %esi
leaq -0xf0(%rbp), %rdi
callq 0x23760
jmp 0x19a35
leaq 0xe879b(%rip), %rsi     # 0x1021d7
leaq -0x130(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
callq 0x23990
jmp 0x19a51
leaq 0xe8786(%rip), %rdx     # 0x1021de
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x23940
jmp 0x19a6d
leaq -0x130(%rbp), %rdi
callq 0xcf470
leaq -0x338(%rbp), %rdi
callq 0x9a510
jmp 0x19a87
leaq -0x338(%rbp), %rdi
leaq -0x110(%rbp), %rsi
movl $0x8, %edx
callq 0x9ae10
jmp 0x19aa1
leaq -0x338(%rbp), %rdi
callq 0x97b70
movb %al, -0x4d1(%rbp)
jmp 0x19ab5
movb -0x4d1(%rbp), %al
testb $0x1, %al
jne 0x19ac4
jmp 0x19bed
leaq -0x358(%rbp), %rdi
movq %rdi, -0x4e0(%rbp)
callq 0xcf360
movq -0x4e0(%rbp), %rsi
leaq -0x338(%rbp), %rdi
callq 0xd1ba0
jmp 0x19aec
leaq -0x338(%rbp), %rdi
callq 0x9bf70
jmp 0x19afa
leaq -0x358(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
xorl %edx, %edx
callq 0x23aa0
movb %al, -0x4e1(%rbp)
jmp 0x19b17
movb -0x4e1(%rbp), %al
testb $0x1, %al
jne 0x19b26
jmp 0x19be1
leaq -0x58(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x23af0
testb $0x1, %al
jne 0x19b3f
jmp 0x19bdf
leaq -0xa8(%rbp), %rdi
leaq -0xcc(%rbp), %rsi
callq 0x23b20
jmp 0x19b54
jmp 0x19bdf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1a08c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1a080
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x19c2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x130(%rbp), %rdi
callq 0xcf470
jmp 0x19c2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x19c1f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x19c13
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x358(%rbp), %rdi
callq 0xcf470
jmp 0x19c13
jmp 0x19be1
leaq -0x358(%rbp), %rdi
callq 0xcf470
leaq -0x338(%rbp), %rdi
callq 0x9c320
leaq -0x110(%rbp), %rdi
callq 0xcf470
leaq -0xf0(%rbp), %rdi
callq 0xcf470
jmp 0x19c3c
leaq -0x338(%rbp), %rdi
callq 0x9c320
leaq -0x110(%rbp), %rdi
callq 0xcf470
leaq -0xf0(%rbp), %rdi
callq 0xcf470
jmp 0x1a080
jmp 0x199b4
leaq -0xa8(%rbp), %rdi
callq 0x23b90
cmpq $0x0, %rax
jbe 0x19fb5
leaq -0x379(%rbp), %rdi
movq %rdi, -0x4f0(%rbp)
callq 0x54db0
movq -0x4f0(%rbp), %rdx
leaq 0xe856e(%rip), %rsi     # 0x1021e6
leaq -0x378(%rbp), %rdi
callq 0x235f0
jmp 0x19c86
xorl %edi, %edi
leaq -0x378(%rbp), %rsi
callq 0x196f0
jmp 0x19c96
leaq -0x378(%rbp), %rdi
callq 0xcf470
leaq -0x379(%rbp), %rdi
callq 0x54dd0
leaq -0xa8(%rbp), %rax
movq %rax, -0x388(%rbp)
movq -0x388(%rbp), %rdi
callq 0x23bb0
movq %rax, -0x390(%rbp)
movq -0x388(%rbp), %rdi
callq 0x23be0
movq %rax, -0x398(%rbp)
leaq -0x390(%rbp), %rdi
leaq -0x398(%rbp), %rsi
callq 0x23c10
testb $0x1, %al
jne 0x19cfb
jmp 0x19d66
leaq -0x390(%rbp), %rdi
callq 0x23c50
movq %rax, -0x3a0(%rbp)
movq -0x3a0(%rbp), %rax
movl (%rax), %edi
movl $0x3, %esi
callq 0x164d0
leaq -0x390(%rbp), %rdi
callq 0x23c70
jmp 0x19ce2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x19d55
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x378(%rbp), %rdi
callq 0xcf470
leaq -0x379(%rbp), %rdi
callq 0x54dd0
jmp 0x1a080
movl $0x5, %edi
callq 0x16460
jmp 0x19d72
leaq -0xa8(%rbp), %rax
movq %rax, -0x3a8(%rbp)
movq -0x3a8(%rbp), %rdi
callq 0x23bb0
movq %rax, -0x3b0(%rbp)
movq -0x3a8(%rbp), %rdi
callq 0x23be0
movq %rax, -0x3b8(%rbp)
leaq -0x3b0(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x23c10
testb $0x1, %al
jne 0x19dc2
jmp 0x19fb0
leaq -0x3b0(%rbp), %rdi
callq 0x23c50
movq %rax, -0x3c0(%rbp)
movq -0x3c0(%rbp), %rax
movl (%rax), %edi
xorl %esi, %esi
callq 0x164d0
cmpl $0x0, %eax
jne 0x19ec7
movq -0x3c0(%rbp), %rax
movl (%rax), %esi
leaq -0x420(%rbp), %rdi
callq 0x23760
jmp 0x19e05
leaq 0xe8402(%rip), %rsi     # 0x10220e
leaq -0x400(%rbp), %rdi
leaq -0x420(%rbp), %rdx
callq 0x23c90
jmp 0x19e21
leaq 0xe83f6(%rip), %rdx     # 0x10221e
leaq -0x3e0(%rbp), %rdi
leaq -0x400(%rbp), %rsi
callq 0x23940
jmp 0x19e3d
xorl %edi, %edi
leaq -0x3e0(%rbp), %rsi
callq 0x196f0
jmp 0x19e4d
leaq -0x3e0(%rbp), %rdi
callq 0xcf470
leaq -0x400(%rbp), %rdi
callq 0xcf470
leaq -0x420(%rbp), %rdi
callq 0xcf470
jmp 0x19f9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x19eb6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x19eaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x3e0(%rbp), %rdi
callq 0xcf470
leaq -0x400(%rbp), %rdi
callq 0xcf470
leaq -0x420(%rbp), %rdi
callq 0xcf470
jmp 0x1a080
movq -0x3c0(%rbp), %rax
movl (%rax), %esi
leaq -0x480(%rbp), %rdi
callq 0x23760
jmp 0x19ede
leaq 0xe8329(%rip), %rsi     # 0x10220e
leaq -0x460(%rbp), %rdi
leaq -0x480(%rbp), %rdx
callq 0x23c90
jmp 0x19efa
leaq 0xe8330(%rip), %rdx     # 0x102231
leaq -0x440(%rbp), %rdi
leaq -0x460(%rbp), %rsi
callq 0x23940
jmp 0x19f16
xorl %edi, %edi
leaq -0x440(%rbp), %rsi
callq 0x196f0
jmp 0x19f26
leaq -0x440(%rbp), %rdi
callq 0xcf470
leaq -0x460(%rbp), %rdi
callq 0xcf470
leaq -0x480(%rbp), %rdi
callq 0xcf470
jmp 0x19f9d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x19f8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x19f80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x440(%rbp), %rdi
callq 0xcf470
leaq -0x460(%rbp), %rdi
callq 0xcf470
leaq -0x480(%rbp), %rdi
callq 0xcf470
jmp 0x1a080
jmp 0x19f9f
leaq -0x3b0(%rbp), %rdi
callq 0x23c70
jmp 0x19da6
jmp 0x1a042
leaq -0x4a1(%rbp), %rdi
movq %rdi, -0x4f8(%rbp)
callq 0x54db0
movq -0x4f8(%rbp), %rdx
leaq 0xe8275(%rip), %rsi     # 0x10224b
leaq -0x4a0(%rbp), %rdi
callq 0x235f0
jmp 0x19fe4
xorl %edi, %edi
leaq -0x4a0(%rbp), %rsi
callq 0x196f0
jmp 0x19ff4
leaq -0x4a0(%rbp), %rdi
callq 0xcf470
leaq -0x4a1(%rbp), %rdi
callq 0x54dd0
jmp 0x1a042
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x1a034
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x4a0(%rbp), %rdi
callq 0xcf470
leaq -0x4a1(%rbp), %rdi
callq 0x54dd0
jmp 0x1a080
movq -0x60(%rbp), %rdi
callq 0x16760
jmp 0x1a04d
leaq -0xc8(%rbp), %rdi
callq 0x23ce0
leaq -0xa8(%rbp), %rdi
callq 0x23d10
leaq -0x58(%rbp), %rdi
callq 0xcf470
leaq -0x20(%rbp), %rdi
callq 0xcf470
addq $0x500, %rsp            # imm = 0x500
popq %rbp
retq
leaq -0xc8(%rbp), %rdi
callq 0x23ce0
leaq -0xa8(%rbp), %rdi
callq 0x23d10
leaq -0x58(%rbp), %rdi
callq 0xcf470
leaq -0x20(%rbp), %rdi
callq 0xcf470
movq -0x30(%rbp), %rdi
callq 0xfeff0
nopw %cs:(%rax,%rax)