// File: /workspace/github_c_makefile_star2_O0/niuyuling[P]CProxy/main.c
// Function: process_signal
int process_signal(int signal, char *process_name)
{
    char bufer[CACHE_SIZE];
    char comm[CACHE_SIZE];
    char proc_comm_name[CACHE_SIZE];
    FILE *fp;
    DIR *dir;
    struct dirent *ptr;
    pid_t self_pid;

    self_pid = getpid();
    dir = opendir("/proc");
    bzero(bufer, 0);
    bzero(comm, 0);
    bzero(proc_comm_name, 0);
    while ((ptr = readdir(dir)) != NULL) {
        if (ptr->d_type != DT_DIR)
            continue;
        if (strcmp(ptr->d_name, ".") == 0 || strcmp(ptr->d_name, "..") == 0 || atoi(ptr->d_name) == self_pid)
            continue;

        sprintf(comm, "/proc/%s/comm", ptr->d_name);
        if (access(comm, F_OK) == 0) {
            fp = fopen(comm, "r");
            if (fgets(bufer, CACHE_SIZE - 1, fp) == NULL) {
                fclose(fp);
                continue;
            }
            sscanf(bufer, "%s", proc_comm_name);
            if (!strcmp(process_name, proc_comm_name)) {
                if (signal == SERVER_TYPE_STOP)
                    kill(atoi(ptr->d_name), SIGTERM);
                else {
                    closedir(dir);
                    if (signal != SERVICE_TYPE_STATUS_NOT_PRINT)
                        printf("\t%d\n", atoi(ptr->d_name));;
                    return 0;
                }
            }
            fclose(fp);
        }
    }
    closedir(dir);

    if (signal == SERVER_TYPE_STATUS) ;
    else if (signal == SERVICE_TYPE_STATUS_NOT_PRINT)
        return 1;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x360, %rsp            # imm = 0x360
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x20e0
movl %eax, -0x35c(%rbp)
leaq 0x942e(%rip), %rdi      # 0xc132
callq 0x2110
movq %rax, -0x350(%rbp)
leaq -0x120(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x21c0
leaq -0x230(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x21c0
leaq -0x340(%rbp), %rdi
xorl %esi, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x21c0
movq -0x350(%rbp), %rdi
callq 0x2340
movq %rax, -0x358(%rbp)
cmpq $0x0, %rax
je 0x2eed
movq -0x358(%rbp), %rax
movzbl 0x12(%rax), %eax
cmpl $0x4, %eax
je 0x2d75
jmp 0x2d46
movq -0x358(%rbp), %rdi
addq $0x13, %rdi
leaq 0x93b2(%rip), %rsi      # 0xc139
callq 0x22b0
cmpl $0x0, %eax
je 0x2dc5
movq -0x358(%rbp), %rdi
addq $0x13, %rdi
leaq 0x9395(%rip), %rsi      # 0xc138
callq 0x22b0
cmpl $0x0, %eax
je 0x2dc5
movq -0x358(%rbp), %rdi
addq $0x13, %rdi
callq 0x24a0
cmpl -0x35c(%rbp), %eax
jne 0x2dca
jmp 0x2d46
leaq -0x230(%rbp), %rdi
movq -0x358(%rbp), %rdx
addq $0x13, %rdx
leaq 0x9358(%rip), %rsi      # 0xc13b
movb $0x0, %al
callq 0x24d0
leaq -0x230(%rbp), %rdi
xorl %esi, %esi
callq 0x2460
cmpl $0x0, %eax
jne 0x2ee8
leaq -0x230(%rbp), %rdi
leaq 0x97e2(%rip), %rsi      # 0xc5f1
callq 0x2470
movq %rax, -0x348(%rbp)
leaq -0x120(%rbp), %rdi
movq -0x348(%rbp), %rdx
movl $0x10d, %esi            # imm = 0x10D
callq 0x2290
cmpq $0x0, %rax
jne 0x2e4a
movq -0x348(%rbp), %rdi
callq 0x2100
jmp 0x2d46
leaq -0x120(%rbp), %rdi
leaq -0x340(%rbp), %rdx
leaq 0x92ea(%rip), %rsi      # 0xc149
movb $0x0, %al
callq 0x2370
movq -0x10(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x22b0
cmpl $0x0, %eax
jne 0x2edc
cmpl $0x1, -0x8(%rbp)
jne 0x2e9f
movq -0x358(%rbp), %rdi
addq $0x13, %rdi
callq 0x24a0
movl %eax, %edi
movl $0xf, %esi
callq 0x2320
jmp 0x2eda
movq -0x350(%rbp), %rdi
callq 0x2220
cmpl $0x4, -0x8(%rbp)
je 0x2ed1
movq -0x358(%rbp), %rdi
addq $0x13, %rdi
callq 0x24a0
movl %eax, %esi
leaq 0x9282(%rip), %rdi      # 0xc14c
movb $0x0, %al
callq 0x2180
movl $0x0, -0x4(%rbp)
jmp 0x2f19
jmp 0x2edc
movq -0x348(%rbp), %rdi
callq 0x2100
jmp 0x2d46
movq -0x350(%rbp), %rdi
callq 0x2220
cmpl $0x3, -0x8(%rbp)
jne 0x2f01
jmp 0x2f12
cmpl $0x4, -0x8(%rbp)
jne 0x2f10
movl $0x1, -0x4(%rbp)
jmp 0x2f19
jmp 0x2f12
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x360, %rsp            # imm = 0x360
popq %rbp
retq
nopw %cs:(%rax,%rax)