// File: /workspace/github_c_makefile_star2_O1/sharmaeklavya2[P]cerplag/compiler.c
// Function: compare_lists_type
void compare_lists_type(const char* func_name, pSD psd, bool is_output, IDListNode* actual, IDTypeListNode* formal) {
    const char* list_type = is_output? "output": "input";
    int acount=0, fcount=0;
    IDListNode* org_actual = actual;
    IDTypeListNode* org_formal = formal;
    for(; actual != NULL; actual = actual->next, acount++);
    for(; formal != NULL; formal = formal->next, fcount++);
    actual = org_actual;
    formal = org_formal;
    if(acount < fcount) {
        sprintf(msg, "Too few %s parameters to function.", list_type);
        print_error("type", ERROR, -1, actual->base.line, actual->base.col, func_name,
            "FEW_ARGS", msg);
    }
    else if(acount > fcount) {
        sprintf(msg, "Too many %s parameters to function.", list_type);
        print_error("type", ERROR, -1, actual->base.line, actual->base.col, func_name,
            "MANY_ARGS", msg);
    }
    else {
        while(actual != NULL) {
            int ftype = formal->base.type;
            int fsize = formal->base.size;
            pSTEntry entry = SD_get_entry(psd, actual->varname);
            if(entry == NULL) {
                print_undecl_id_error(actual->varname, actual->base.line, actual->base.col);
            }
            else {
                if(is_output) {
                    log_var_set(entry, actual->base.line, actual->base.col);
                }
                int atype = entry->addr->type;
                int asize = entry->addr->size;
                if(!(atype == TYPE_ERROR || (atype == ftype && asize == fsize))) {
                    char fstr[24], astr[24];
                    get_type_str(astr, atype, asize);
                    get_type_str(fstr, ftype, fsize);
                    sprintf(msg, "Actual %s parameter has type '%s', but formal %s parameter has type '%s'.",
                        list_type, astr, list_type, fstr);
                    print_error("type", ERROR, -1, actual->base.line, actual->base.col, actual->varname,
                        "FCALL_TYPE_MISMATCH", msg);
                }
                actual->base.addr = entry->addr;
            }
            actual = actual->next;
            formal = formal->next;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %r8, %r15
movq %rcx, %rbx
movl %edx, %ecx
movq %rsi, -0x40(%rbp)
leaq 0x3b5b(%rip), %rax      # 0xf37e
leaq 0x2c8b(%rip), %rdx      # 0xe4b5
movl %ecx, -0x2c(%rbp)
testl %ecx, %ecx
cmovneq %rax, %rdx
movq %rdi, %r12
xorl %eax, %eax
movl $0x0, %ecx
testq %rbx, %rbx
je 0xb852
xorl %ecx, %ecx
movq %rbx, %rsi
movq 0x38(%rsi), %rsi
incl %ecx
testq %rsi, %rsi
jne 0xb847
testq %r15, %r15
je 0xb867
xorl %eax, %eax
movq %r15, %rsi
movq 0x38(%rsi), %rsi
incl %eax
testq %rsi, %rsi
jne 0xb85c
cmpl %eax, %ecx
jae 0xb87b
leaq 0x3b36(%rip), %r15      # 0xf3a8
leaq 0x3b0c(%rip), %rsi      # 0xf385
jmp 0xb88b
jbe 0xb8c6
leaq 0x3b51(%rip), %r15      # 0xf3d5
leaq 0x3b26(%rip), %rsi      # 0xf3b1
leaq 0xf53e(%rip), %r14      # 0x1add0
movq %r14, %rdi
xorl %eax, %eax
callq 0x31b0
movl 0xc(%rbx), %ecx
movl 0x10(%rbx), %r8d
leaq 0x2f9e(%rip), %rdi      # 0xe848
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r12, %r9
pushq %r14
pushq %r15
callq 0x94d4
addq $0x68, %rsp
jmp 0xb9da
movq %rdx, -0x38(%rbp)
testq %rbx, %rbx
je 0xb9d6
movl 0x4(%r15), %r14d
movl 0x8(%r15), %r13d
movq 0x40(%rbx), %rsi
movq -0x40(%rbp), %rdi
callq 0xa0e6
testq %rax, %rax
je 0xb997
movq %rax, %r12
cmpb $0x0, -0x2c(%rbp)
je 0xb908
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
movq %r12, %rdi
callq 0xb785
movq 0x28(%r12), %rax
movl 0x18(%rax), %esi
testl %esi, %esi
je 0xb98c
movl 0x1c(%rax), %edx
cmpl %r14d, %esi
jne 0xb921
cmpl %r13d, %edx
je 0xb98c
leaq -0x60(%rbp), %rdi
callq 0xc069
leaq -0x80(%rbp), %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0xc069
leaq 0xf490(%rip), %r14      # 0x1add0
movq %r14, %rdi
leaq 0x3a95(%rip), %rsi      # 0xf3df
movq -0x38(%rbp), %rdx
leaq -0x60(%rbp), %rcx
movq %rdx, %r8
leaq -0x80(%rbp), %r9
xorl %eax, %eax
callq 0x31b0
movl 0xc(%rbx), %ecx
movl 0x10(%rbx), %r8d
movq 0x40(%rbx), %r9
leaq 0x2ed6(%rip), %rdi      # 0xe848
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
pushq %r14
leaq 0x3aa7(%rip), %rax      # 0xf429
pushq %rax
callq 0x94d4
addq $0x10, %rsp
movq 0x28(%r12), %rax
movq %rax, 0x18(%rbx)
jmp 0xb9c9
movq 0x40(%rbx), %r9
movl 0xc(%rbx), %ecx
movl 0x10(%rbx), %r8d
leaq 0x3829(%rip), %rdi      # 0xf1d2
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq 0x394d(%rip), %rax      # 0xf304
pushq %rax
leaq 0x393b(%rip), %rax      # 0xf2fa
pushq %rax
callq 0x94d4
addq $0x10, %rsp
movq 0x38(%rbx), %rbx
movq 0x38(%r15), %r15
jmp 0xb8ca
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq