// File: /workspace/github_c_makefile_star2_O1/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, %r14
leaq 0x24ea(%rip), %rsi      # 0xab6a
callq 0x22c0
testq %rax, %rax
je 0x882f
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x20c0
cmpl $0x1, %eax
je 0x86b4
xorl %eax, %eax
callq 0x2c81
movq 0x28(%rsp), %rdi
callq 0x2c6e
testl %eax, %eax
je 0x8836
leaq 0x14(%rsp), %rdi
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x20c0
cmpl $0x1, %eax
je 0x86e9
xorl %eax, %eax
callq 0x2c81
movl 0x14(%rsp), %r15d
movl $0x3, %eax
cmpl (%r14), %r15d
jne 0x885b
movl $0x4, %esi
movq %r15, %rdi
callq 0x21d0
movq %rax, %r12
movl $0x4, %esi
movq %rax, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x20c0
cmpl %eax, %r15d
je 0x872b
xorl %eax, %eax
callq 0x2c81
testq %r15, %r15
je 0x8752
movq 0x8(%r14), %rax
addq $0x10, %rax
xorl %ecx, %ecx
movl (%rax), %edx
cmpl (%r12,%rcx,4), %edx
jne 0x883d
incq %rcx
addq $0x18, %rax
cmpl %ecx, %r15d
jne 0x873a
movq %r12, %rdi
callq 0x2050
leaq 0x30(%rsp), %rdi
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x20c0
cmpl $0x1, %eax
je 0x877d
xorl %eax, %eax
callq 0x2c81
movq 0x30(%rsp), %r12
movl $0x1, %esi
movq %r12, %rdi
callq 0x21d0
movl $0x1, %esi
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r12, %rdx
movq %rbx, 0x18(%rsp)
movq %rbx, %rcx
callq 0x20c0
movl %eax, %eax
cmpq %r12, %rax
je 0x87ba
xorl %eax, %eax
callq 0x2c81
testq %r15, %r15
je 0x8817
movq 0x8(%r14), %rbx
shlq $0x3, %r15
leaq (%r15,%r15,2), %rax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
movq 0x8(%rsp), %r14
movq (%rbx,%r13), %rbp
movq %rbp, %rdi
callq 0x2110
movq %rax, %r15
movq %r14, %rax
subq 0x8(%rsp), %rax
cmpq %r12, %rax
jae 0x884c
movl %r15d, %edx
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2090
testl %eax, %eax
jne 0x884c
incl %r15d
addq %r15, %r14
addq $0x18, %r13
cmpq %r13, 0x20(%rsp)
jne 0x87d8
movq 0x8(%rsp), %rdi
callq 0x2050
movq 0x18(%rsp), %rdi
callq 0x2100
xorl %eax, %eax
jmp 0x885b
movl $0x1, %eax
jmp 0x885b
movl $0x2, %eax
jmp 0x885b
movq %r12, %rdi
callq 0x2050
movl $0x4, %eax
jmp 0x885b
movq 0x8(%rsp), %rdi
callq 0x2050
movl $0x5, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq