// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x3349(%rip), %rsi      # 0xda94
callq 0x22d0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0xa767
movl $0x1, -0x4(%rbp)
jmp 0xa99c
movq -0x58(%rbp), %rcx
leaq -0x40(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x20c0
movl %eax, -0x20(%rbp)
cmpl $0x1, -0x20(%rbp)
je 0xa78e
movb $0x0, %al
callq 0x2a80
movq -0x40(%rbp), %rdi
callq 0x2a40
cmpl $0x0, %eax
jne 0xa7a8
movl $0x2, -0x4(%rbp)
jmp 0xa99c
movq -0x58(%rbp), %rcx
leaq -0x24(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x20c0
movl %eax, -0x20(%rbp)
cmpl $0x1, -0x20(%rbp)
je 0xa7cf
movb $0x0, %al
callq 0x2a80
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl (%rcx), %eax
je 0xa7e6
movl $0x3, -0x4(%rbp)
jmp 0xa99c
movl -0x24(%rbp), %eax
movl %eax, %edi
movl $0x4, %esi
callq 0x21d0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, %edx
movq -0x58(%rbp), %rcx
movl $0x4, %esi
callq 0x20c0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
je 0xa822
movb $0x0, %al
callq 0x2a80
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0xa874
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movq -0x30(%rbp), %rcx
movl -0x1c(%rbp), %edx
cmpl (%rcx,%rdx,4), %eax
je 0xa867
movq -0x30(%rbp), %rdi
callq 0x2050
movl $0x4, -0x4(%rbp)
jmp 0xa99c
jmp 0xa869
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa829
movq -0x30(%rbp), %rdi
callq 0x2050
movq -0x58(%rbp), %rcx
leaq -0x38(%rbp), %rdi
movl $0x8, %esi
movl $0x1, %edx
callq 0x20c0
movl %eax, -0x20(%rbp)
cmpl $0x1, -0x20(%rbp)
je 0xa8a4
movb $0x0, %al
callq 0x2a80
movq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x21d0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl $0x1, %esi
callq 0x20c0
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpq -0x38(%rbp), %rax
je 0xa8df
movb $0x0, %al
callq 0x2a80
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jae 0xa983
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x2110
movl %eax, -0x28(%rbp)
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rcx, %rax
cmpq -0x38(%rbp), %rax
jae 0xa950
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movl -0x1c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
movl -0x28(%rbp), %eax
movl %eax, %edx
callq 0x2090
cmpl $0x0, %eax
je 0xa962
movq -0x48(%rbp), %rdi
callq 0x2050
movl $0x5, -0x4(%rbp)
jmp 0xa99c
movl -0x28(%rbp), %ecx
addl $0x1, %ecx
movq -0x50(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xa8ee
movq -0x48(%rbp), %rdi
callq 0x2050
movq -0x58(%rbp), %rdi
callq 0x2100
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)