// File: /workspace/github_c_makefile_star2_O1/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, %r15
movq %rsi, %r12
movq %rdi, %r13
testq %rdx, %rdx
setne %al
movq %rcx, (%rsp)
testq %rcx, %rcx
setne %bpl
andb %al, %bpl
movq 0x90b9(%rip), %rdi      # 0xe748
callq 0x6c9f
movq %rax, %rbx
testq %r13, %r13
je 0x573e
testq %r12, %r12
je 0x57cd
testb %bpl, %bpl
je 0x5852
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x9084(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5722
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5722
movq 0x10(%r14), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x5722
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5722
movq 0x9030(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x901f(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x56bd
jmp 0x5da1
testq %r12, %r12
je 0x58d4
testb %bpl, %bpl
je 0x5947
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8fe6(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq 0x8(%rax), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x57b1
movq 0x10(%r14), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x57b1
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x57b1
movq 0x8fa1(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8f90(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x575b
jmp 0x5da1
testb %bpl, %bpl
je 0x59ba
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8f60(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5836
movq 0x10(%r14), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x5836
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5836
movq 0x8f1c(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8f0b(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x57e1
jmp 0x5da1
testq %r15, %r15
je 0x5a2c
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8edb(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x58b8
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x58b8
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x58b8
movq 0x8e9a(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8e89(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5866
jmp 0x5da1
testb %bpl, %bpl
je 0x5ab1
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8e59(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq 0x10(%rax), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x592b
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x592b
movq 0x8e27(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8e16(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x58e8
jmp 0x5da1
testq %r15, %r15
je 0x5b11
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8de6(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq 0x8(%rax), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x599e
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x599e
movq 0x8db4(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8da3(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x595b
jmp 0x5da1
testq %r15, %r15
je 0x5b87
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8d73(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5a10
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x5a10
movq 0x8d42(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8d31(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x59ce
jmp 0x5da1
cmpq $0x0, (%rsp)
je 0x5bfc
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8cff(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5a95
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5a95
movq 0x10(%r14), %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5a95
movq 0x8cbd(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8cac(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5a42
jmp 0x5da1
testq %r15, %r15
je 0x5c65
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8c7c(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq 0x10(%rax), %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x5af5
movq 0x8c5d(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8c4c(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5ac5
jmp 0x5da1
cmpq $0x0, (%rsp)
je 0x5cc8
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8c1a(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq 0x8(%rax), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5b6b
movq 0x10(%r14), %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5b6b
movq 0x8be7(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8bd6(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5b27
jmp 0x5da1
cmpq $0x0, (%rsp)
je 0x5d1f
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8ba4(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5be0
movq 0x10(%r14), %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5be0
movq 0x8b72(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8b61(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5b9d
jmp 0x5da1
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8b3a(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5c49
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5c49
movq 0x8b09(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8af8(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5c07
jmp 0x5da1
cmpq $0x0, (%rsp)
je 0x5d6e
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8ac6(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq 0x10(%rax), %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5cac
movq 0x8aa6(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8a95(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5c7b
jmp 0x5da1
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8a6e(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq 0x8(%rax), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5d03
movq 0x8a4f(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x8a3e(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5cd3
jmp 0x5da1
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x8a1b(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6ef2
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5d55
movq 0x89fd(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x89ec(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5d26
jmp 0x5da1
testq %rbx, %rbx
je 0x5d9f
xorl %ebp, %ebp
movq 0x89cc(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6f0b
addl (%rax), %ebp
movq 0x89bb(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6d5b
movq %rax, %rbx
testq %rax, %rax
jne 0x5d75
jmp 0x5da1
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq