// File: /workspace/github_c_makefile_star2_O3/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 0x3c24(%rip), %rax      # 0xf37e
leaq 0x2d54(%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 0xb789
xorl %ecx, %ecx
movq %rbx, %rsi
movq 0x38(%rsi), %rsi
incl %ecx
testq %rsi, %rsi
jne 0xb77e
testq %r15, %r15
je 0xb79e
xorl %eax, %eax
movq %r15, %rsi
movq 0x38(%rsi), %rsi
incl %eax
testq %rsi, %rsi
jne 0xb793
cmpl %eax, %ecx
jae 0xb7b2
leaq 0x3bff(%rip), %r15      # 0xf3a8
leaq 0x3bd5(%rip), %rsi      # 0xf385
jmp 0xb7c2
jbe 0xb7fd
leaq 0x3c1a(%rip), %r15      # 0xf3d5
leaq 0x3bef(%rip), %rsi      # 0xf3b1
leaq 0xf607(%rip), %r14      # 0x1add0
movq %r14, %rdi
xorl %eax, %eax
callq 0x31b0
movl 0xc(%rbx), %ecx
movl 0x10(%rbx), %r8d
leaq 0x3067(%rip), %rdi      # 0xe848
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movq %r12, %r9
pushq %r14
pushq %r15
callq 0x93bc
addq $0x68, %rsp
jmp 0xb911
movq %rdx, -0x38(%rbp)
testq %rbx, %rbx
je 0xb90d
movl 0x4(%r15), %r14d
movl 0x8(%r15), %r13d
movq 0x40(%rbx), %rsi
movq -0x40(%rbp), %rdi
callq 0x9fe2
testq %rax, %rax
je 0xb8ce
movq %rax, %r12
cmpb $0x0, -0x2c(%rbp)
je 0xb83f
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
movq %r12, %rdi
callq 0xb6bc
movq 0x28(%r12), %rax
movl 0x18(%rax), %esi
testl %esi, %esi
je 0xb8c8
movl 0x1c(%rax), %edx
cmpl %r14d, %esi
jne 0xb858
cmpl %r13d, %edx
je 0xb8c8
leaq -0x60(%rbp), %rdi
callq 0xbfb5
leaq -0x80(%rbp), %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0xbfb5
leaq 0xf559(%rip), %r14      # 0x1add0
movq %r14, %rdi
leaq 0x3b5e(%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 0x2f9f(%rip), %rdi      # 0xe848
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
pushq %r14
leaq 0x3b70(%rip), %rax      # 0xf429
pushq %rax
callq 0x93bc
addq $0x10, %rsp
movq 0x28(%r12), %rax
movq %rax, 0x18(%rbx)
jmp 0xb900
movq 0x40(%rbx), %r9
movl 0xc(%rbx), %ecx
movl 0x10(%rbx), %r8d
leaq 0x38f2(%rip), %rdi      # 0xf1d2
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq 0x3a16(%rip), %rax      # 0xf304
pushq %rax
leaq 0x3a04(%rip), %rax      # 0xf2fa
pushq %rax
callq 0x93bc
addq $0x10, %rsp
movq 0x38(%rbx), %rbx
movq 0x38(%r15), %r15
jmp 0xb801
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq