// File: /workspace/github_c_makefile_star2_O2/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, %r15
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, %r14
xorl %edi, %edi
callq 0x5b2a
movq %rax, %rbx
testq %r14, %r14
je 0x50e5
movq 0x96f4(%rip), %rdi      # 0xe718
movq %r14, %rsi
callq 0x6585
movq %r15, %r14
movq %rax, %r12
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4ec1
movq %rax, %r15
movq %r12, %rdi
movq %r14, %rsi
callq 0x4f2b
movq %rax, %r14
testq %r13, %r13
je 0x50ce
cmpq %r14, %r15
je 0x50d3
movq %r12, %rdi
movq %r15, %rsi
callq 0x7ea8
movq %rax, %rbp
movq 0x18(%rax), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jne 0x508c
movq %rbx, %rdi
callq 0x5e09
movq %rbx, %rdi
movq %rax, %rsi
movq %rbp, %rdx
callq 0x5bab
movq %r12, %rdi
movq %r15, %rsi
callq 0x7e74
movq %rax, %r15
jmp 0x5053
movq %r12, %rdi
movq %r15, %rsi
callq 0x7ea8
movq %rax, %r13
movq %rbx, %rdi
callq 0x5e09
movq %rbx, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x5bab
movq %r12, %rdi
movq %r15, %rsi
callq 0x7e74
movq %rax, %r15
cmpq %r14, %r15
jne 0x509c
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x8(%rsp)
testq %r13, %r13
je 0x5158
movq 0x962a(%rip), %rdi      # 0xe720
movq %r13, %rsi
callq 0x6585
movq %rax, %r12
movq %rax, %rdi
movq %rbp, %rsi
callq 0x4ec1
movq %rax, %r15
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x4f2b
movq %rax, %r14
cmpq %r14, %r15
je 0x50d3
movq %r12, %rdi
movq %r15, %rsi
callq 0x7ea8
movq %rax, %r13
movq %rbx, %rdi
callq 0x5e09
movq %rbx, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x5bab
movq %r12, %rdi
movq %r15, %rsi
callq 0x7e74
movq %rax, %r15
jmp 0x511f
movq %rbp, 0x10(%rsp)
movq 0x95b4(%rip), %rdi      # 0xe718
callq 0x6767
movq %rax, %r12
testq %rax, %rax
je 0x50d3
movq 0x959c(%rip), %rdi      # 0xe718
movq %r12, %rsi
callq 0x69d3
movq %rax, %r13
movq %rax, %rdi
callq 0x7beb
testl %eax, %eax
je 0x51ec
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x4ec1
movq %rax, %rbp
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x4f2b
movq %rax, %r14
cmpq %r14, %rbp
je 0x51ec
movq %r13, %rdi
movq %rbp, %rsi
callq 0x7ea8
movq %rax, %r15
movq %rbx, %rdi
callq 0x5e09
movq %rbx, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x5bab
movq %r13, %rdi
movq %rbp, %rsi
callq 0x7e74
movq %rax, %rbp
jmp 0x51b3
movq 0x9525(%rip), %rdi      # 0xe718
movq %r12, %rsi
callq 0x6823
jmp 0x5169