// File: /workspace/github_c_makefile_star2_O0/panux[P]linit/src/linitd.c
// Function: notifyAll
bool notifyAll(struct service* s) {
    char *cmds = NULL;
    if(asprintf(&cmds, "notify %s %s", s->name, statestr(s->state)) == -1) {
        return false;
    }
    struct buf cmdb = { .dat = cmds, .len = strlen(cmds) + 1 };
    bool oks[s->notify_n];
    size_t nok = 0;
    for(size_t i = 0; i < s->notify_n; i++) {
        switch(notify(s->notify[i], s, cmdb)) {
        case notify_success:
            oks[i] = true;
            nok++;
            break;
        case notify_gone:
            oks[i] = false;
            break;
        case notify_fail:
            free(cmds);
            return false;
        }
    }
    if(nok != s->notify_n) {
        //compact the buffer
        struct conn **not = s->notify;
        for(size_t i = 0; i < s->notify_n; i++) {
            if(oks[i]) { *(not++) = s->notify[i]; }
        }
        //shrink memory allocation with realloc
        not = realloc(s->notify, sizeof(struct conn *) * nok);
        if(not == NULL) {   //reallocation failed - just change the notify_n
            s->notify_n = nok;
        } else {
            s->notify = not;
            s->notify_n = nok;
        }
    }
    free(cmds);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x13a0
movq -0x68(%rbp), %rdx
movq %rax, %rcx
leaq -0x18(%rbp), %rdi
leaq 0x28cf(%rip), %rsi      # 0x406f
movb $0x0, %al
callq 0x1190
cmpl $-0x1, %eax
jne 0x17b5
movb $0x0, -0x1(%rbp)
jmp 0x1981
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
callq 0x1090
incq %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rsp, %rcx
movq %rcx, -0x30(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x70(%rbp)
movq %rcx, %rsp
movq %rax, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x18aa
movq -0x10(%rbp), %rsi
movq 0x10(%rsi), %rax
movq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x28(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0x14e0
movl %eax, %ecx
movl %ecx, -0x74(%rbp)
testl %eax, %eax
je 0x187e
jmp 0x1842
movl -0x74(%rbp), %eax
subl $0x1, %eax
je 0x1856
jmp 0x184c
movl -0x74(%rbp), %eax
subl $0x2, %eax
je 0x1870
jmp 0x1897
movq -0x70(%rbp), %rax
movq -0x48(%rbp), %rcx
movb $0x1, (%rax,%rcx)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x1897
movq -0x70(%rbp), %rax
movq -0x48(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x1897
movq -0x18(%rbp), %rdi
callq 0x1030
movb $0x0, -0x1(%rbp)
movl $0x1, -0x4c(%rbp)
jmp 0x197a
jmp 0x1899
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x1808
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
je 0x1966
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jae 0x191e
movq -0x70(%rbp), %rax
movq -0x60(%rbp), %rcx
testb $0x1, (%rax,%rcx)
je 0x190e
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x60(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x58(%rbp), %rax
movq %rax, %rdx
addq $0x8, %rdx
movq %rdx, -0x58(%rbp)
movq %rcx, (%rax)
jmp 0x1910
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x18d0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x40(%rbp), %rsi
shlq $0x3, %rsi
callq 0x1180
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x194c
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x1964
movq -0x58(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x40(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x1966
movq -0x18(%rbp), %rdi
callq 0x1030
movb $0x1, -0x1(%rbp)
movl $0x1, -0x4c(%rbp)
movq -0x30(%rbp), %rax
movq %rax, %rsp
movb -0x1(%rbp), %al
andb $0x1, %al
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax,%rax)