// File: /workspace/github_c_makefile_star2_O1/sasairc[P]yasuna/src/subset.c
// Function: select_by_speaker
int select_by_speaker(char* speaker, polyaness_t** src, polyaness_t** dest)
{
    int             i       = 0,
                    j       = 0,
                    status  = 0;

    polyaness_t*    pt      = NULL;

    /* no modify */
    if (speaker == NULL) {
        *dest = *src;

        return 0;
    }

    if ((pt = (polyaness_t*)
                malloc(sizeof(polyaness_t))) == NULL) {
        status = -1; goto ERR;
    }

    /* extraction speaker */
    pt->record = (*src)->record;
    pt->recs = 0;
    while (i < (*src)->recs) {
        j = (*src)->record[i]->keys - 1;
        while (j >= 0) {
            if (memcmp(*((*src)->record[i]->key + j), "speaker\0", 8) == 0 &&
                    memcmp(*((*src)->record[i]->value + j), speaker, strlen(speaker) + 1) == 0) {
                *(pt->record + pt->recs) = *((*src)->record + i);
                pt->recs++;
                break;
            }
            j--;
        }
        if (j < 0)
            release_polyaness_cell(&*(pt->record + i));
        i++;
    }
    free(*src);
    *src = NULL;
    *dest = pt;

    /* no quotes */
    if (pt->recs <= 0) {
        status = -2; goto ERR;
    }

    return 0;

ERR:
    switch (status) {
        case    -1:
            fprintf(stderr, "%s: malloc(): %s\n",
                    PROGNAME, strerror(errno));
            break;
        case    -2:
            break;
    }

    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, 0x28(%rsp)
testq %rdi, %rdi
je 0xabdd
movl $0x10, %edi
callq 0x20e0
testq %rax, %rax
je 0xabe7
movq %rbx, 0x10(%rsp)
movq (%r14), %rdi
movq 0x8(%rdi), %rcx
movq %rcx, 0x8(%rax)
movq %rax, 0x8(%rsp)
movl $0x0, (%rax)
cmpl $0x0, (%rdi)
jle 0xabb6
xorl %ebx, %ebx
movabsq $0x72656b61657073, %r12 # imm = 0x72656B61657073
movq %r14, 0x18(%rsp)
movq 0x28(%rsp), %r15
movq 0x8(%rdi), %rax
movq %rbx, 0x20(%rsp)
movq (%rax,%rbx,8), %rsi
movslq (%rsi), %rbp
testq %rbp, %rbp
jle 0xab80
movq 0x8(%rsi), %r14
movq %rbp, %rbx
incq %rbx
movq %rsi, 0x30(%rsp)
movq -0x10(%r14,%rbx,8), %rax
cmpq %r12, (%rax)
jne 0xab5e
movq 0x10(%rsi), %rax
movq -0x10(%rax,%rbx,8), %r13
movq %r15, %rdi
callq 0x21a0
leaq 0x1(%rax), %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x2280
movq 0x30(%rsp), %rsi
testl %eax, %eax
je 0xab6b
decl %ebp
decq %rbx
cmpq $0x1, %rbx
jg 0xab2b
jmp 0xab80
movq 0x8(%rsp), %rdx
movq 0x8(%rdx), %rax
movslq (%rdx), %rcx
movq %rsi, (%rax,%rcx,8)
leal 0x1(%rcx), %eax
movl %eax, (%rdx)
testl %ebp, %ebp
movq 0x20(%rsp), %rbx
jg 0xab9f
leaq (,%rbx,8), %rdi
movq 0x8(%rsp), %rax
addq 0x8(%rax), %rdi
callq 0xa5c6
incq %rbx
movq 0x18(%rsp), %r14
movq (%r14), %rdi
movslq (%rdi), %rax
cmpq %rax, %rbx
jl 0xab07
callq 0x2190
movq $0x0, (%r14)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, (%rcx)
xorl %ebp, %ebp
cmpl $0x0, (%rax)
jg 0xabf1
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
jmp 0xabec
movq (%r14), %rax
movq %rax, (%rbx)
xorl %ebp, %ebp
jmp 0xabf1
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xac02
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2858
jmp 0xabf1