// File: /workspace/github_c_makefile_star2_O2/c-zhou[P]yahs/sdict.c
// Function: file_sdict_match
int file_sdict_match(char *f, sdict_t *dict)
{
    uint32_t i, m, n, s, *lens;
    uint64_t l;
    int64_t magic_number;
    char *names, *p;
    FILE *fp;

    fp = fopen(f, "r");
    if (fp == NULL)
        return 1;

    m = fread(&magic_number, sizeof(int64_t), 1, fp);
    if (m != 1) bin_fread_error();
    if (!is_valid_bin_header(magic_number))
        return 2;

    m = fread(&n, sizeof(uint32_t), 1, fp);
    if (m != 1) bin_fread_error();
    if (n != dict->n)
        return 3;
    
    lens = (uint32_t *) calloc(n, sizeof(uint32_t));
    m = fread(lens, sizeof(uint32_t), n, fp);
    if (m != n) bin_fread_error();
    for (i = 0; i < n; ++i) {
        if (dict->s[i].len != lens[i]) {
            free(lens);
            return 4;
        }
    }
    free(lens);
    
    m = fread(&l, sizeof(uint64_t), 1, fp);
    if (m != 1) bin_fread_error();
    names = (char *) calloc(l, 1);
    m = fread(names, 1, l, fp);
    if (m != l) bin_fread_error();
    for (p = names, i = 0; i < n; ++i) {
        s = strlen(dict->s[i].name);
        if (p - names >= l || strncmp(p, dict->s[i].name, s)) {
            free(names);
            return 5;
        }
        p += s + 1;
    }
    free(names);

    fclose(fp);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %rbx
leaq 0x25bc(%rip), %rsi      # 0x9a7c
callq 0x22c0
testq %rax, %rax
je 0x758e
movq %rax, %r13
leaq 0x28(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
callq 0x20c0
cmpl $0x1, %eax
je 0x74f0
xorl %eax, %eax
callq 0x27f6
movq 0x28(%rsp), %rdi
callq 0x27e3
testl %eax, %eax
je 0x7595
leaq 0x14(%rsp), %rdi
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x20c0
cmpl $0x1, %eax
je 0x7521
xorl %eax, %eax
callq 0x27f6
movl 0x14(%rsp), %r15d
cmpl (%rbx), %r15d
jne 0x759c
pushq $0x4
popq %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x21d0
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x20c0
cmpl %eax, %r15d
je 0x755a
xorl %eax, %eax
callq 0x27f6
imulq $0x6, %r15, %rax
xorl %ecx, %ecx
movq %r12, %rdx
cmpq %rcx, %rax
je 0x75a3
movq 0x8(%rbx), %rsi
movl 0x10(%rsi,%rcx,4), %esi
addq $0x6, %rcx
leaq 0x4(%rdx), %rdi
cmpl (%rdx), %esi
movq %rdi, %rdx
je 0x7563
movq %r12, %rdi
callq 0x2050
pushq $0x4
jmp 0x7667
pushq $0x1
jmp 0x7667
pushq $0x2
jmp 0x7667
pushq $0x3
jmp 0x7667
movq %r12, %rdi
callq 0x2050
leaq 0x30(%rsp), %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x20c0
cmpl $0x1, %eax
je 0x75ca
xorl %eax, %eax
callq 0x27f6
movq 0x30(%rsp), %r12
pushq $0x1
popq %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x21d0
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r13, 0x18(%rsp)
movq %r13, %rcx
callq 0x20c0
movl %eax, %eax
movq %r12, 0x20(%rsp)
cmpq %r12, %rax
je 0x760c
xorl %eax, %eax
callq 0x27f6
imulq $0x18, %r15, %r12
xorl %r13d, %r13d
movq 0x8(%rsp), %r15
cmpq %r13, %r12
je 0x7677
movq 0x8(%rbx), %rax
movq (%rax,%r13), %r14
movq %r14, %rdi
callq 0x2110
movq %rax, %rbp
movq %r15, %rax
subq 0x8(%rsp), %rax
cmpq 0x20(%rsp), %rax
jae 0x765b
movl %ebp, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x2090
testl %eax, %eax
jne 0x765b
incl %ebp
addq %rbp, %r15
addq $0x18, %r13
jmp 0x7618
movq 0x8(%rsp), %rdi
callq 0x2050
pushq $0x5
popq %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rdi
callq 0x2050
movq 0x18(%rsp), %rdi
callq 0x2100
xorl %eax, %eax
jmp 0x7668