// File: /workspace/github_c_makefile_star2_O2/giannisdravilas[P]Disease-Monitor/tests/../modules/DiseaseMonitor.c
// Function: dm_count_records
int dm_count_records(String disease, String country, Date date_from, Date date_to){

    // Σε αυτή τη μεταβλητή αποθηκεύεται το πλήθος των records, που θα αυξάνεται καθώς θα διατρέχουμε το Map
    int counter = 0;
    
    // Διακρίνουμε τις διάφορες περιπτώσεις ανάλογα με το αν είναι NULL κάποιο από τα
    // disease, country, date_from, date_to, όλα ή κανένα. Όταν βρούμε τη σωστή περίπτωση διατρέχουμε το
    // map_disease_country_date που περιέχει περιορισμένο αριθμό εγγραφών (άρα η πολυπλοκότητα δεν εξαρτάται
    // από τον συνολικό αριθμό εγγραφών και αφού τα πλήθη υπάρχουν ήδη ως value και δε χρειάζεται να μετρηθούν
    // δεν εξαρτάται ούτε από τον αριθμό εγγραφών που πληρούν τα κριτήρια) και προσθέτουμε στον counter τα values
    // (πλήθη) των εγγραφών που πληρούν τα κριτήρια.
    if(disease){
        if(country){
            if(date_from && date_to){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_diseases(mapcount->disease, disease) && !compare_countries(mapcount->country, country)){
                        if(compare_dates(mapcount->date, date_from) >= 0 && compare_dates(mapcount->date, date_to) <= 0){
                            counter += *(int*)map_node_value(map_disease_country_date, node);
                        }
                    }
                }
            }else if(date_from){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_diseases(mapcount->disease, disease) && !compare_countries(mapcount->country, country)){
                        if(compare_dates(mapcount->date, date_from) >= 0){
                            counter += *(int*)map_node_value(map_disease_country_date, node);
                        }
                    }
                }
            }else if(date_to){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_diseases(mapcount->disease, disease) && !compare_countries(mapcount->country, country)){
                        if(compare_dates(mapcount->date, date_to) <= 0){
                            counter += *(int*)map_node_value(map_disease_country_date, node);
                        }
                    }
                }
            }else{
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_diseases(mapcount->disease, disease) && !compare_countries(mapcount->country, country)){
                        counter += *(int*)map_node_value(map_disease_country_date, node);
                    }
                }
            }
        }else{
            if(date_from && date_to){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_diseases(mapcount->disease, disease)){
                        if(compare_dates(mapcount->date, date_from) >= 0 && compare_dates(mapcount->date, date_to) <= 0){
                            counter += *(int*)map_node_value(map_disease_country_date, node);
                        }
                    }
                }
            }else if(date_from){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_diseases(mapcount->disease, disease)){
                        if(compare_dates(mapcount->date, date_from) >= 0){
                            counter += *(int*)map_node_value(map_disease_country_date, node);
                        }
                    }
                }
            }else if(date_to){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_diseases(mapcount->disease, disease)){
                        if(compare_dates(mapcount->date, date_to) <= 0){
                            counter += *(int*)map_node_value(map_disease_country_date, node);
                        }
                    }
                }
            }else{
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_diseases(mapcount->disease, disease)){
                        counter += *(int*)map_node_value(map_disease_country_date, node);
                    }
                }
            }
        }
    }else{
        if(country){
            if(date_from && date_to){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_countries(mapcount->country, country)){
                        if(compare_dates(mapcount->date, date_from) >= 0 && compare_dates(mapcount->date, date_to) <= 0){
                            counter += *(int*)map_node_value(map_disease_country_date, node);
                        }
                    }
                }
            }else if(date_from){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_countries(mapcount->country, country)){
                        if(compare_dates(mapcount->date, date_from) >= 0){
                            counter += *(int*)map_node_value(map_disease_country_date, node);
                        }
                    }
                }
            }else if(date_to){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_countries(mapcount->country, country)){
                        if(compare_dates(mapcount->date, date_to) <= 0){
                            counter += *(int*)map_node_value(map_disease_country_date, node);
                        }
                    }
                }
            }else{
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(!compare_countries(mapcount->country, country)){
                        counter += *(int*)map_node_value(map_disease_country_date, node);
                    }
                }
            }
        }else{
            if(date_from && date_to){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(compare_dates(mapcount->date, date_from) >= 0 && compare_dates(mapcount->date, date_to) <= 0){
                        counter += *(int*)map_node_value(map_disease_country_date, node);
                    }
                }
            }else if(date_from){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(compare_dates(mapcount->date, date_from) >= 0){
                        counter += *(int*)map_node_value(map_disease_country_date, node);
                    }
                }
            }else if(date_to){
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    MapCount mapcount = map_node_key(map_disease_country_date, node);
                    if(compare_dates(mapcount->date, date_to) <= 0){
                        counter += *(int*)map_node_value(map_disease_country_date, node);
                    }
                }
            }else{
                for(MapNode node = map_first(map_disease_country_date); node != MAP_EOF; node = map_next(map_disease_country_date, node)){
                    counter += *(int*)map_node_value(map_disease_country_date, node);
                }
            }
        }
    }

    return counter;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbp
testq %rdx, %rdx
setne %al
movq %rcx, (%rsp)
testq %rcx, %rcx
setne %bl
andb %al, %bl
movq 0x94fb(%rip), %rdi      # 0xe728
callq 0x6767
movq %rax, %r14
testq %rbp, %rbp
je 0x52d6
testq %r13, %r13
je 0x535c
testb %bl, %bl
je 0x53db
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x94c7(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq (%rax), %rdi
movq %rbp, %rsi
callq 0x2180
testl %eax, %eax
jne 0x52bf
movq 0x8(%r15), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jne 0x52bf
movq 0x10(%r15), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2180
testl %eax, %eax
js 0x52bf
movq %r15, %rdi
movq (%rsp), %rsi
callq 0x2180
testl %eax, %eax
jg 0x52bf
movq 0x9473(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x9462(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x5251
testq %r13, %r13
je 0x5455
testb %bl, %bl
je 0x54c2
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x942f(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq 0x8(%rax), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jne 0x5348
movq 0x10(%r15), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2180
testl %eax, %eax
js 0x5348
movq %r15, %rdi
movq (%rsp), %rsi
callq 0x2180
testl %eax, %eax
jg 0x5348
movq 0x93ea(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x93d9(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x52e9
testb %bl, %bl
je 0x552d
xorl %ebx, %ebx
movq (%rsp), %r13
testq %r14, %r14
je 0x5870
movq 0x93ae(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq (%rax), %rdi
movq %rbp, %rsi
callq 0x2180
testl %eax, %eax
jne 0x53c7
movq 0x10(%r15), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2180
testl %eax, %eax
js 0x53c7
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jg 0x53c7
movq 0x936b(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x935a(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x536a
testq %r12, %r12
je 0x559b
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x9332(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq (%rax), %rdi
movq %rbp, %rsi
callq 0x2180
testl %eax, %eax
jne 0x5441
movq 0x8(%r15), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jne 0x5441
movq 0x10(%r15), %rdi
movq %r12, %rsi
callq 0x2180
testl %eax, %eax
js 0x5441
movq 0x92f1(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x92e0(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x53e6
testb %bl, %bl
je 0x5618
xorl %ebx, %ebx
movq (%rsp), %r13
testq %r14, %r14
je 0x5870
movq 0x92b5(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq 0x10(%rax), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x2180
testl %eax, %eax
js 0x54ae
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jg 0x54ae
movq 0x9284(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x9273(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x5463
testq %r12, %r12
je 0x5674
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x924b(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq 0x8(%rax), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jne 0x5519
movq 0x10(%r15), %rdi
movq %r12, %rsi
callq 0x2180
testl %eax, %eax
js 0x5519
movq 0x9219(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x9208(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x54cd
testq %r12, %r12
movq (%rsp), %r13
je 0x56e2
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x91dc(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq (%rax), %rdi
movq %rbp, %rsi
callq 0x2180
testl %eax, %eax
jne 0x5587
movq 0x10(%r15), %rdi
movq %r12, %rsi
callq 0x2180
testl %eax, %eax
js 0x5587
movq 0x91ab(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x919a(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x553c
cmpq $0x0, (%rsp)
je 0x5797
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x9170(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq (%rax), %rdi
movq %rbp, %rsi
callq 0x2180
testl %eax, %eax
jne 0x5604
movq 0x8(%r15), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jne 0x5604
movq 0x10(%r15), %rdi
movq (%rsp), %rsi
callq 0x2180
testl %eax, %eax
jg 0x5604
movq 0x912e(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x911d(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x55a8
testq %r12, %r12
movq (%rsp), %r15
je 0x57f8
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x90f1(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq 0x10(%rax), %rdi
movq %r12, %rsi
callq 0x2180
testl %eax, %eax
js 0x5660
movq 0x90d2(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x90c1(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x5627
cmpq $0x0, (%rsp)
je 0x5881
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x9097(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq 0x8(%rax), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jne 0x56ce
movq 0x10(%r15), %rdi
movq (%rsp), %rsi
callq 0x2180
testl %eax, %eax
jg 0x56ce
movq 0x9064(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x9053(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x5681
xorl %ebx, %ebx
testq %r13, %r13
jne 0x578d
testq %r14, %r14
je 0x5870
movq 0x902b(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq (%rax), %rdi
movq %rbp, %rsi
callq 0x2180
testl %eax, %eax
jne 0x5725
movq 0x900d(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x8ffc(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x56ed
movq 0x8fe8(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq (%rax), %rdi
movq %rbp, %rsi
callq 0x2180
testl %eax, %eax
jne 0x577b
movq 0x10(%r15), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jg 0x577b
movq 0x8fb7(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x8fa6(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
testq %r14, %r14
jne 0x5739
jmp 0x5870
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x8f7f(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq %rax, %r15
movq (%rax), %rdi
movq %rbp, %rsi
callq 0x2180
testl %eax, %eax
jne 0x57e4
movq 0x8(%r15), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jne 0x57e4
movq 0x8f4e(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x8f3d(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x5799
xorl %ebx, %ebx
testq %r15, %r15
je 0x586b
testq %r14, %r14
je 0x5870
movq 0x8f1d(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq 0x10(%rax), %rdi
movq %r15, %rsi
callq 0x2180
testl %eax, %eax
jg 0x5834
movq 0x8efe(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x8eed(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x57ff
movq 0x8ed9(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x8ec8(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
testq %r14, %r14
jne 0x5848
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
testq %r14, %r14
je 0x5870
movq 0x8e99(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69ba
movq 0x8(%rax), %rdi
movq %r13, %rsi
callq 0x2180
testl %eax, %eax
jne 0x58b8
movq 0x8e7a(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x69d3
addl (%rax), %ebx
movq 0x8e69(%rip), %rdi      # 0xe728
movq %r14, %rsi
callq 0x6823
movq %rax, %r14
jmp 0x5883