// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %rcx, %rbx
movl %edx, -0x2c(%rbp)
movq %rsi, -0x40(%rbp)
movq %rdi, %r12
xorl %eax, %eax
testq %rcx, %rcx
je 0xa8fe
movq 0x38(%rcx), %rcx
incl %eax
jmp 0xa8f1
xorl %ecx, %ecx
movq %r14, %rdx
testq %rdx, %rdx
je 0xa910
movq 0x38(%rdx), %rdx
incl %ecx
jmp 0xa903
leaq 0x3a67(%rip), %rdx      # 0xe37e
leaq 0x2b97(%rip), %rsi      # 0xd4b5
cmpb $0x0, -0x2c(%rbp)
cmovneq %rdx, %rsi
movq %rsi, -0x38(%rbp)
cmpl %ecx, %eax
jae 0xa93e
leaq 0x3a73(%rip), %r15      # 0xe3a8
leaq 0x3a49(%rip), %rsi      # 0xe385
jmp 0xa94e
jbe 0xa993
leaq 0x3a8e(%rip), %r15      # 0xe3d5
leaq 0x3a63(%rip), %rsi      # 0xe3b1
leaq 0xf47b(%rip), %r14      # 0x19dd0
movq %r14, %rdi
movq -0x38(%rbp), %rdx
xorl %eax, %eax
callq 0x31a0
movl 0xc(%rbx), %ecx
movl 0x10(%rbx), %r8d
leaq 0x2ed7(%rip), %rdi      # 0xd848
pushq $-0x1
popq %rdx
xorl %esi, %esi
movq %r12, %r9
pushq %r14
pushq %r15
callq 0x873c
popq %rax
popq %rcx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbx, %rbx
je 0xa984
movl 0x4(%r14), %r13d
movl 0x8(%r14), %r12d
movq 0x40(%rbx), %rsi
movq -0x40(%rbp), %rdi
callq 0x9323
testq %rax, %rax
je 0xaa56
movq %rax, %r15
cmpb $0x0, -0x2c(%rbp)
je 0xa9cd
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
movq %r15, %rdi
callq 0xa858
movq 0x28(%r15), %rax
movl 0x18(%rax), %esi
testl %esi, %esi
je 0xaa50
movl 0x1c(%rax), %edx
cmpl %r13d, %esi
jne 0xa9e5
cmpl %r12d, %edx
je 0xaa50
leaq -0x60(%rbp), %rdi
callq 0xb0b9
leaq -0x80(%rbp), %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0xb0b9
leaq 0xf3cc(%rip), %r12      # 0x19dd0
movq %r12, %rdi
leaq 0x39d1(%rip), %rsi      # 0xe3df
movq -0x38(%rbp), %rdx
leaq -0x60(%rbp), %rcx
movq %rdx, %r8
leaq -0x80(%rbp), %r9
xorl %eax, %eax
callq 0x31a0
movl 0xc(%rbx), %ecx
movl 0x10(%rbx), %r8d
movq 0x40(%rbx), %r9
leaq 0x2e12(%rip), %rdi      # 0xd848
xorl %esi, %esi
pushq $-0x1
popq %rdx
pushq %r12
leaq 0x39e5(%rip), %rax      # 0xe429
pushq %rax
callq 0x873c
popq %rax
popq %rcx
movq 0x28(%r15), %rax
movq %rax, 0x18(%rbx)
jmp 0xaa65
movq 0x40(%rbx), %rdi
movl 0xc(%rbx), %esi
movl 0x10(%rbx), %edx
callq 0x9955
movq 0x38(%rbx), %rbx
movq 0x38(%r14), %r14
jmp 0xa993