// File: /workspace/github_c_makefile_star2_O3/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 0x9209(%rip), %rdi      # 0xe748
callq 0x6b4f
movq %rax, %rbx
testq %r13, %r13
je 0x55ee
testq %r12, %r12
je 0x567d
testb %bpl, %bpl
je 0x5702
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x91d4(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x55d2
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x55d2
movq 0x10(%r14), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x55d2
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x55d2
movq 0x9180(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x916f(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x556d
jmp 0x5c51
testq %r12, %r12
je 0x5784
testb %bpl, %bpl
je 0x57f7
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x9136(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq 0x8(%rax), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5661
movq 0x10(%r14), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x5661
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5661
movq 0x90f1(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x90e0(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x560b
jmp 0x5c51
testb %bpl, %bpl
je 0x586a
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x90b0(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x56e6
movq 0x10(%r14), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x56e6
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x56e6
movq 0x906c(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x905b(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5691
jmp 0x5c51
testq %r15, %r15
je 0x58dc
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x902b(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5768
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5768
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x5768
movq 0x8fea(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8fd9(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5716
jmp 0x5c51
testb %bpl, %bpl
je 0x5961
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8fa9(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq 0x10(%rax), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x57db
movq %r14, %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x57db
movq 0x8f77(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8f66(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5798
jmp 0x5c51
testq %r15, %r15
je 0x59c1
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8f36(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq 0x8(%rax), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x584e
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x584e
movq 0x8f04(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8ef3(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x580b
jmp 0x5c51
testq %r15, %r15
je 0x5a37
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8ec3(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x58c0
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x58c0
movq 0x8e92(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8e81(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x587e
jmp 0x5c51
cmpq $0x0, (%rsp)
je 0x5aac
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8e4f(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5945
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5945
movq 0x10(%r14), %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5945
movq 0x8e0d(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8dfc(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x58f2
jmp 0x5c51
testq %r15, %r15
je 0x5b15
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8dcc(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq 0x10(%rax), %rdi
movq %r15, %rsi
callq 0x2190
testl %eax, %eax
js 0x59a5
movq 0x8dad(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8d9c(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5975
jmp 0x5c51
cmpq $0x0, (%rsp)
je 0x5b78
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8d6a(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq 0x8(%rax), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5a1b
movq 0x10(%r14), %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5a1b
movq 0x8d37(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8d26(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x59d7
jmp 0x5c51
cmpq $0x0, (%rsp)
je 0x5bcf
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8cf4(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5a90
movq 0x10(%r14), %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5a90
movq 0x8cc2(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8cb1(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5a4d
jmp 0x5c51
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8c8a(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq %rax, %r14
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5af9
movq 0x8(%r14), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5af9
movq 0x8c59(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8c48(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5ab7
jmp 0x5c51
cmpq $0x0, (%rsp)
je 0x5c1e
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8c16(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq 0x10(%rax), %rdi
movq (%rsp), %rsi
callq 0x2190
testl %eax, %eax
jg 0x5b5c
movq 0x8bf6(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8be5(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5b2b
jmp 0x5c51
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8bbe(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq 0x8(%rax), %rdi
movq %r12, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5bb3
movq 0x8b9f(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8b8e(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5b83
jmp 0x5c51
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8b6b(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6da2
movq (%rax), %rdi
movq %r13, %rsi
callq 0x2190
testl %eax, %eax
jne 0x5c05
movq 0x8b4d(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8b3c(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5bd6
jmp 0x5c51
testq %rbx, %rbx
je 0x5c4f
xorl %ebp, %ebp
movq 0x8b1c(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6dbb
addl (%rax), %ebp
movq 0x8b0b(%rip), %rdi      # 0xe748
movq %rbx, %rsi
callq 0x6c0b
movq %rax, %rbx
testq %rax, %rax
jne 0x5c25
jmp 0x5c51
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq