// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x10ec2
movq -0x18(%rbp), %rax
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x110c2
movl $0x10, %edi
callq 0x20e0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x10ee2
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
jmp 0x1106b
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x1102e
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jl 0x11002
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x8(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movabsq $0x72656b61657073, %rcx # imm = 0x72656B61657073
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x10ff4
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rax
movslq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2180
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
callq 0x2330
cmpl $0x0, %eax
jne 0x10ff4
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x38(%rbp), %rcx
movslq (%rcx), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x38(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x11002
movl -0x28(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x10f2c
cmpl $0x0, -0x28(%rbp)
jge 0x11020
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
movslq -0x24(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
callq 0x10400
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x10eff
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0x2170
movq -0x18(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
cmpl $0x0, (%rax)
jg 0x11062
movl $0xfffffffe, -0x2c(%rbp) # imm = 0xFFFFFFFE
jmp 0x1106b
movl $0x0, -0x4(%rbp)
jmp 0x110c2
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
subl $-0x2, %eax
je 0x110ba
jmp 0x11078
movl -0x4c(%rbp), %eax
subl $-0x1, %eax
jne 0x110bc
jmp 0x11082
movq 0x4f57(%rip), %rax      # 0x15fe0
movq (%rax), %rax
movq %rax, -0x58(%rbp)
callq 0x2300
movl (%rax), %edi
callq 0x2220
movq -0x58(%rbp), %rdi
movq %rax, %rcx
leaq 0x154e(%rip), %rsi      # 0x125f8
leaq 0x1169(%rip), %rdx      # 0x1221a
movb $0x0, %al
callq 0x23a0
jmp 0x110bc
jmp 0x110bc
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)