// File: /workspace/github_c_makefile_star2_O2/OhYee[P]computer_application_programming_experiment/hash_search/array_search/array_search.c
// Function: main
int main() {
    clock_start();

    mp_init(memory_length, mp_exit);

    link_list *lk = lk_init();

    char *temp = mp_new(max_string_length * sizeof(char));
    int   word_number = 0;
    int   word_exist_number = 0;

    FILE *output = open_file(output_filename, "w");
    FILE *f = open_file(patterns_filename, "r");
    while (read_file(f, temp)) {
        char *s = mp_new(sizeof(char *) * (strlen(temp) + 1));
        strcpy(s, temp);
        lk_add(lk, s);
    }
    fclose(f);

    f = open_file(words_filename, "r");
    while (read_file(f, temp)) {
        ++word_number;
        // if (word_number % 10000 == 0)
        //     printf("%d %fs %d ok\n", word_number, clock_duration(),
        //            word_exist_number);

        if (NULL != lk_search(lk, temp, compare)) {
            ++word_exist_number;
            fprintf(output, "%s yes\n", temp);
        } else {
            fprintf(output, "%s no\n", temp);
        }
    }
    fclose(f);

    fprintf(output,
            "%10.2f "
            "%" PRIu64 " %7d %7d\n",
            (double)mp_get_length() / 1024, compare_number, word_number,
            word_exist_number);
    printf("%f s\n", clock_duration());
    fclose(output);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %eax, %eax
callq 0x1ffc
leaq -0xeae(%rip), %rsi      # 0x2108
movl $0x14246810, %edi       # imm = 0x14246810
callq 0x2111
xorl %eax, %eax
callq 0x2598
movq %rax, %r14
movl $0x100, %edi            # imm = 0x100
callq 0x22fd
movq %rax, %r15
movq 0x413a(%rip), %rdi      # 0x7118
leaq 0x13a0(%rip), %rsi      # 0x4385
callq 0x2088
movq %rax, (%rsp)
movq 0x4113(%rip), %rdi      # 0x7108
leaq 0x138b(%rip), %rsi      # 0x4387
callq 0x2088
movq %rax, %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x20b1
testl %eax, %eax
je 0x3042
movq %r15, %rdi
callq 0x1080
leal 0x8(,%rax,8), %edi
callq 0x22fd
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x1040
movq %r14, %rdi
movq %r12, %rsi
callq 0x25dc
jmp 0x3004
movq %rbx, %rdi
callq 0x1070
movq 0x40bf(%rip), %rdi      # 0x7110
leaq 0x132f(%rip), %rsi      # 0x4387
callq 0x2088
movq %rax, %r13
leaq 0x132a(%rip), %rbx      # 0x4391
xorl %ebp, %ebp
xorl %r12d, %r12d
movq %r13, %rdi
movq %r15, %rsi
callq 0x20b1
testl %eax, %eax
je 0x30b8
incl %r12d
movq %r14, %rdi
movq %r15, %rsi
leaq -0xff(%rip), %rdx       # 0x2f8c
callq 0x2664
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
movq %rbx, %rsi
leaq 0x12e7(%rip), %rax      # 0x4389
cmovneq %rax, %rsi
addl %ecx, %ebp
movq (%rsp), %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10f0
jmp 0x306c
movq %r13, %rdi
callq 0x1070
xorl %eax, %eax
callq 0x22ad
movq %rax, %xmm1
punpckldq 0x124c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1254(%rip), %xmm1     # 0x4330
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x1250(%rip), %xmm0     # 0x4340
leaq 0x4061(%rip), %rax      # 0x7158
movq (%rax), %rdx
leaq 0x1297(%rip), %rsi      # 0x4398
movq (%rsp), %rbx
movq %rbx, %rdi
movl %r12d, %ecx
movl %ebp, %r8d
movb $0x1, %al
callq 0x10f0
xorl %eax, %eax
callq 0x200b
leaq 0x1289(%rip), %rdi      # 0x43ac
movb $0x1, %al
callq 0x1090
movq %rbx, %rdi
callq 0x1070
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq