// File: /workspace/github_c_makefile_star2_O3/giannisdravilas[P]Disease-Monitor/tests/../modules/DiseaseMonitor.c
// Function: dm_get_records
List dm_get_records(String disease, String country, Date date_from, Date date_to){
    
    List list = list_create(NULL);
    
    // Διακρίνουμε τις διάφορες περιπτώσεις ανάλογα με το αν είναι NULL κάποιο από τα
    // disease, country, και τα δύο ή κανένα από τα δύο. Κάθε φορά βρίσκουμε το set στο
    // οποίο ανήκει η εγγραφή, καθώς και τους κόμβους του Set που αντιστοιχούν στην
    // date_from και την επόμενη της date_to. Αν η εγγραφή πληροί όλες τις απαραίτητες
    // προϋποθέσεις τότε εισάγεται στη λίστα.
    if(disease){
        Set set = map_find(map_diseases_dates, disease);
        SetNode date_from_node = get_date_from_node(set, date_from);
        SetNode date_to_node = get_date_to_node(set, date_to);
        if(country){
            for(SetNode node = date_from_node; node != date_to_node; node = set_next(set, node)){
                Record record = set_node_value(set, node);
                if(strcmp(record->country, country) == 0){
                    list_insert_next(list, list_last(list), record);
                }
            }
        }else{
            for(SetNode node = date_from_node; node != date_to_node; node = set_next(set, node)){
                Record record = set_node_value(set, node);
                list_insert_next(list, list_last(list), record);
            }
        }
    }else{
        if(country){
            Set set = map_find(map_countries_dates, country);
            SetNode date_from_node = get_date_from_node(set, date_from);
            SetNode date_to_node = get_date_to_node(set, date_to);
            for(SetNode node = date_from_node; node != date_to_node; node = set_next(set, node)){
                Record record = set_node_value(set, node);
                list_insert_next(list, list_last(list), record);
            }
        }else{
            for(MapNode node = map_first(map_diseases_dates); node != MAP_EOF; node = map_next(map_diseases_dates, node)){
                Set set = map_node_value(map_diseases_dates, node);
                if(set_size(set)){
                    SetNode date_from_node = get_date_from_node(set, date_from);
                    SetNode date_to_node = get_date_to_node(set, date_to);
                    for(SetNode node_set = date_from_node; node_set != date_to_node; node_set = set_next(set, node_set)){
                        Record record = set_node_value(set, node_set);
                        list_insert_next(list, list_last(list), record);
                    }
                }
            }
        }
    }

    return list;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r14
xorl %edi, %edi
callq 0x5f12
movq %rax, %rbx
testq %r14, %r14
je 0x5386
movq 0x9437(%rip), %rdi      # 0xe738
movq %r14, %rsi
callq 0x696d
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x5194
movq %rax, %r15
movq %r12, %rdi
movq %rbp, %rsi
callq 0x5200
movq %rax, %r14
testq %r13, %r13
je 0x5402
cmpq %r14, %r15
je 0x54fe
movq %r12, %rdi
movq %r15, %rsi
callq 0x8290
movq %rax, %rbp
movq 0x18(%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x536e
movq %rbx, %rdi
callq 0x61f1
movq %rbx, %rdi
movq %rax, %rsi
movq %rbp, %rdx
callq 0x5f93
movq %r12, %rdi
movq %r15, %rsi
callq 0x825c
movq %rax, %r15
cmpq %r14, %rax
jne 0x533a
jmp 0x54fe
testq %r13, %r13
je 0x5447
movq 0x93aa(%rip), %rdi      # 0xe740
movq %r13, %rsi
callq 0x696d
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
callq 0x5194
movq %rax, %r15
movq %r12, %rdi
movq %rbp, %rsi
callq 0x5200
cmpq %rax, %r15
je 0x54fe
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x8290
movq %rax, %r13
movq %rbx, %rdi
callq 0x61f1
movq %rbx, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x5f93
movq %r12, %rdi
movq %r15, %rsi
callq 0x825c
movq %rax, %r15
cmpq %r14, %rax
jne 0x53c6
jmp 0x54fe
cmpq %r14, %r15
je 0x54fe
movq %r12, %rdi
movq %r15, %rsi
callq 0x8290
movq %rax, %r13
movq %rbx, %rdi
callq 0x61f1
movq %rbx, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x5f93
movq %r12, %rdi
movq %r15, %rsi
callq 0x825c
movq %rax, %r15
cmpq %r14, %rax
jne 0x540b
jmp 0x54fe
movq %r15, 0x8(%rsp)
movq %rbp, 0x10(%rsp)
movq 0x92e0(%rip), %rdi      # 0xe738
callq 0x6b4f
testq %rax, %rax
je 0x54fe
movq %rax, %r12
movq 0x92c8(%rip), %rdi      # 0xe738
movq %r12, %rsi
callq 0x6dbb
movq %rax, %r13
movq %rax, %rdi
callq 0x7fd3
testl %eax, %eax
je 0x54e3
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x5194
movq %rax, %rbp
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x5200
cmpq %rax, %rbp
je 0x54e3
movq %rax, %r14
movq %r13, %rdi
movq %rbp, %rsi
callq 0x8290
movq %rax, %r15
movq %rbx, %rdi
callq 0x61f1
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x5f93
movq %r13, %rdi
movq %rbp, %rsi
callq 0x825c
movq %rax, %rbp
cmpq %r14, %rax
jne 0x54ac
movq 0x924e(%rip), %rdi      # 0xe738
movq %r12, %rsi
callq 0x6c0b
movq %rax, %r12
testq %rax, %rax
jne 0x5469
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq