// File: /workspace/github_c_makefile_star2_O0/OhYee[P]computer_application_programming_experiment/hash_search/hashtable_search/hashtable_search.c
// Function: main
int main(int argc, char **argv) {
    clock_start();

    mp_init(memory_length, mp_exit);
    hash_table *ht = ht_init(hash_table_size);
    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)) {
        ht_add(ht, temp);
    }
    fclose(f);

    // for (int i = 0; i < (ht->length); ++i) {
    //     printf("%d %d\n", i, ht->array[i] == NULL ? 0 :
    //     ht->array[i]->length);
    // }

    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 (ht_exist(ht, temp)) {
            ++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
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, %al
callq 0x2cf0
movl $0x155ce710, %edi       # imm = 0x155CE710
leaq -0x1b29(%rip), %rsi     # 0x2f90
callq 0x2fa0
movl $0x10000, %edi          # imm = 0x10000
callq 0x4900
movq %rax, -0x18(%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0x32b0
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq 0x3629(%rip), %rdi      # 0x8118
leaq 0x897(%rip), %rsi       # 0x538d
callq 0x2e60
movq %rax, -0x30(%rbp)
movq 0x3602(%rip), %rdi      # 0x8108
leaq 0x882(%rip), %rsi       # 0x538f
callq 0x2e60
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x2eb0
cmpl $0x0, %eax
je 0x4b37
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4970
jmp 0x4b16
movq -0x38(%rbp), %rdi
callq 0x1060
movq 0x35c9(%rip), %rdi      # 0x8110
leaq 0x841(%rip), %rsi       # 0x538f
callq 0x2e60
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x2eb0
cmpl $0x0, %eax
je 0x4bbd
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x4a10
cmpl $0x0, %eax
je 0x4ba5
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x7f5(%rip), %rsi       # 0x5391
movb $0x0, %al
callq 0x10f0
jmp 0x4bbb
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq 0x7e5(%rip), %rsi       # 0x5399
movb $0x0, %al
callq 0x10f0
jmp 0x4b57
movq -0x38(%rbp), %rdi
callq 0x1060
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
xorl %eax, %eax
callq 0x3210
movq -0x40(%rbp), %rdi
movq %rax, %xmm0
movaps 0x74b(%rip), %xmm1      # 0x5330
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x74f(%rip), %xmm1      # 0x5340
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x718(%rip), %xmm1      # 0x5320
divsd %xmm1, %xmm0
leaq 0x3545(%rip), %rax      # 0x8158
movq (%rax), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
leaq 0x77c(%rip), %rsi       # 0x53a0
movb $0x1, %al
callq 0x10f0
movb $0x0, %al
callq 0x2d10
leaq 0x77b(%rip), %rdi       # 0x53b4
movb $0x1, %al
callq 0x1090
movq -0x30(%rbp), %rdi
callq 0x1060
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq