// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r13
testq %rdi, %rdi
je 0x9e21
movq %rdi, %r15
pushq $0x10
popq %rdi
callq 0x20e0
testq %rax, %rax
je 0x9e39
movq %rbx, 0x18(%rsp)
movq (%r13), %rdi
movq 0x8(%rdi), %rcx
movq %rcx, 0x10(%rsp)
movq %rcx, 0x8(%rax)
movq %rax, 0x8(%rsp)
andl $0x0, (%rax)
movq $0x0, (%rsp)
movabsq $0x72656b61657073, %r12 # imm = 0x72656B61657073
xorl %r14d, %r14d
movq %r13, 0x20(%rsp)
movslq (%rdi), %rax
cmpq %rax, %r14
jge 0x9df8
movq 0x8(%rdi), %rax
movq (%rax,%r14,8), %rbx
movl (%rbx), %ebp
testl %ebp, %ebp
jle 0x9dba
movq 0x8(%rbx), %rax
movq -0x8(%rax,%rbp,8), %rax
cmpq %r12, (%rax)
jne 0x9db5
movq 0x10(%rbx), %rax
movq -0x8(%rax,%rbp,8), %r13
movq %r15, %rdi
callq 0x21a0
leaq 0x1(%rax), %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x2280
testl %eax, %eax
je 0x9dca
decq %rbp
jmp 0x9d7f
movq 0x10(%rsp), %rax
leaq (%rax,%r14,8), %rdi
callq 0x9737
jmp 0x9de7
movq (%rsp), %rcx
movslq %ecx, %rax
movq 0x10(%rsp), %rdx
movq %rbx, (%rdx,%rax,8)
incl %ecx
movq 0x8(%rsp), %rax
movq %rcx, (%rsp)
movl %ecx, (%rax)
incq %r14
movq 0x20(%rsp), %r13
movq (%r13), %rdi
jmp 0x9d69
callq 0x2190
andq $0x0, (%r13)
movq 0x18(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, (%rax)
xorl %eax, %eax
cmpl $0x0, (%rsp)
setg %al
leal -0x2(,%rax,2), %eax
jmp 0x9e2a
movq (%r13), %rax
movq %rax, (%rbx)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x61a8(%rip), %rax      # 0xffe8
movq (%rax), %rbx
callq 0x2340
movl (%rax), %edi
callq 0x2240
leaq 0x177b(%rip), %rsi      # 0xb5d1
leaq 0x13b9(%rip), %rdx      # 0xb216
movq %rbx, %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x2400
pushq $-0x1
popq %rax
jmp 0x9e2a