// File: /workspace/github_c_makefile_star2_O0/Carton32[P]quectel-CM/main.c
// Function: is_brother_process
static int is_brother_process(const char *dir, const char *file, void *argv[])
{
    //const char *myself = (const char *)argv[0];
    char linkname[MAX_PATH];
    char filename[MAX_PATH];
    int linksize;
    int i = 0, kill_timeout = 15;
    pid_t pid;

    //dbg_time("%s", file);
    while (file[i]) {
        if (!isdigit(file[i]))
            break;
        i++;
    }

    if (file[i]) {
        //dbg_time("%s not digit", file);
        return 0;
    }

    snprintf(linkname, MAX_PATH, "%s/%s/exe", dir, file);
    linksize = readlink(linkname, filename, MAX_PATH);
    if (linksize <= 0)
        return 0;

    filename[linksize] = 0;

    pid = atoi(file);
    if (pid >= getpid())
        return 0;

    snprintf(linkname, MAX_PATH, "%s/%s/fd", dir, file);
    if (!ls_dir(linkname, is_same_linkfile, argv))
        return 0;

    dbg_time("%s/%s/exe -> %s", dir, file, filename);
    while (kill_timeout-- && !kill(pid, 0))
    {
        kill(pid, SIGTERM);
        sleep(1);
    }
    if (!kill(pid, 0))
    {
        dbg_time("force kill %s/%s/exe -> %s", dir, file, filename);
        kill(pid, SIGKILL);
        sleep(1);
    }

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x228(%rbp)
movl $0xf, -0x22c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x228(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xb407
callq 0x5580
movq (%rax), %rax
movq -0x18(%rbp), %rcx
movslq -0x228(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0xb3f6
jmp 0xb407
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0xb3bb
movq -0x18(%rbp), %rax
movslq -0x228(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xb424
movl $0x0, -0x4(%rbp)
jmp 0xb6ba
leaq -0x120(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
movl $0x100, %esi            # imm = 0x100
leaq 0x20abb(%rip), %rdx     # 0x2befa
movb $0x0, %al
callq 0x51c0
leaq -0x120(%rbp), %rdi
leaq -0x220(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x50d0
movl %eax, -0x224(%rbp)
cmpl $0x0, -0x224(%rbp)
jg 0xb479
movl $0x0, -0x4(%rbp)
jmp 0xb6ba
movslq -0x224(%rbp), %rax
movb $0x0, -0x220(%rbp,%rax)
movq -0x18(%rbp), %rdi
callq 0x54c0
movl %eax, -0x230(%rbp)
movl -0x230(%rbp), %eax
movl %eax, -0x234(%rbp)
callq 0x5110
movl %eax, %ecx
movl -0x234(%rbp), %eax
cmpl %ecx, %eax
jl 0xb4c0
movl $0x0, -0x4(%rbp)
jmp 0xb6ba
leaq -0x120(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
movl $0x100, %esi            # imm = 0x100
leaq 0x20a29(%rip), %rdx     # 0x2bf04
movb $0x0, %al
callq 0x51c0
leaq -0x120(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x1dc(%rip), %rsi       # 0xb6d0
callq 0xb240
cmpl $0x0, %eax
jne 0xb50a
movl $0x0, -0x4(%rbp)
jmp 0xb6ba
jmp 0xb50c
movq 0x2bacd(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x240(%rbp)
callq 0x13930
movq -0x240(%rbp), %rdi
movq %rax, %rdx
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
leaq -0x220(%rbp), %r9
leaq 0x209cb(%rip), %rsi     # 0x2bf0d
movb $0x0, %al
callq 0x52c0
leaq 0x2c918(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0xb593
leaq 0x2c90b(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x248(%rbp)
callq 0x13930
movq -0x248(%rbp), %rdi
movq %rax, %rdx
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
leaq -0x220(%rbp), %r9
leaq 0x20981(%rip), %rsi     # 0x2bf0d
movb $0x0, %al
callq 0x52c0
jmp 0xb595
jmp 0xb597
movl -0x22c(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0x22c(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x249(%rbp)
je 0xb5d0
movl -0x230(%rbp), %edi
xorl %esi, %esi
callq 0x5310
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
movb %al, -0x249(%rbp)
movb -0x249(%rbp), %al
testb $0x1, %al
jne 0xb5dc
jmp 0xb5f8
movl -0x230(%rbp), %edi
movl $0xf, %esi
callq 0x5310
movl $0x1, %edi
callq 0x5550
jmp 0xb597
movl -0x230(%rbp), %edi
xorl %esi, %esi
callq 0x5310
cmpl $0x0, %eax
jne 0xb6b3
jmp 0xb610
movq 0x2b9c9(%rip), %rax     # 0x36fe0
movq (%rax), %rax
movq %rax, -0x258(%rbp)
callq 0x13930
movq -0x258(%rbp), %rdi
movq %rax, %rdx
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
leaq -0x220(%rbp), %r9
leaq 0x208dd(%rip), %rsi     # 0x2bf23
movb $0x0, %al
callq 0x52c0
leaq 0x2c814(%rip), %rax     # 0x37e68
cmpq $0x0, (%rax)
je 0xb697
leaq 0x2c807(%rip), %rax     # 0x37e68
movq (%rax), %rax
movq %rax, -0x260(%rbp)
callq 0x13930
movq -0x260(%rbp), %rdi
movq %rax, %rdx
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
leaq -0x220(%rbp), %r9
leaq 0x20893(%rip), %rsi     # 0x2bf23
movb $0x0, %al
callq 0x52c0
jmp 0xb699
movl -0x230(%rbp), %edi
movl $0x9, %esi
callq 0x5310
movl $0x1, %edi
callq 0x5550
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
nopw %cs:(%rax,%rax)