// File: corecodec[P]coremake/coremake.c
// Function: preprocess_uselib
void preprocess_uselib(item* p,item* ref,item* uselib)
{
	item** child;
	if (!p) return;
	for (child=p->child;child!=p->childend;++child)
        if (!((*child)->flags & FLAG_REMOVED))
	    {
		    size_t i;
		    item* use = item_get(*child,"use",0);
		    for (i=0;i<item_childcount(use);++i)
		    {
			    if (stricmp(use->child[i]->value,ref->value)==0)
			    {
                    size_t j;
		            item* src = item_get(ref,"source",0);
		            for (j=0;j<item_childcount(src);++j)
		            {
                        char path[MAX_PATH];
                        strcpy(path,src->child[j]->value);
                        truncfileext(path);
                        if (stricmp(path,"rc")==0)
    			            item_merge(item_get(item_get(*child,"source",0),src->child[j]->value,1),src->child[j],use->child[i]);

			            item_merge(item_get(*child,"reg",0),item_find(src->child[j],"reg"),use->child[i]);
			            item_merge(item_get(*child,"class",0),item_find(src->child[j],"class"),use->child[i]);
		            }

	                item_merge(item_get(*child,"reg",0),item_find(ref,"reg"),use->child[i]);
	                item_merge(item_get(*child,"class",0),item_find(ref,"class"),use->child[i]);
	                item_merge(item_get(*child,"libs",0),item_find(ref,"libs"),use->child[i]);
	                item_merge(item_get(*child,"syslibs",0),item_find(ref,"syslibs"),use->child[i]);
	                item_merge(item_get(*child,"install",0),item_find(ref,"install"),use->child[i]);

	                // add to "include"
	                item_merge(item_get(*child,"include",0),item_find(ref,"expinclude"),use->child[i]);
	                // also merge "subinclude"
	                item_merge(item_get(*child,"subinclude",0),item_find(ref,"subinclude"),use->child[i]);
	                // also merge "sysinclude"
	                item_merge(item_get(*child,"sysinclude",0),item_find(ref,"sysinclude"),use->child[i]);
			        // also merge "libinclude"
			        item_merge(item_get(*child,"libinclude",0),item_find(ref,"libinclude"),use->child[i]);
			        // also merge "uselib"
			        item_merge(item_get(*child,"uselib",0),item_find(ref,"uselib"),use->child[i]);
			        // also merge "rpath"
			        item_merge(item_get(*child,"rpath",0),item_find(ref,"rpath"),use->child[i]);
	                // add to "define"
	                item_merge(item_get(*child,"define",0),item_find(ref,"expdefine"),use->child[i]);

				    item_get(item_get(*child,"uselib",1),uselib->value,1);
				    item_delete(use->child[i]);
				    --i;
			    }
		    }
	    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x4c0, %rsp            # imm = 0x4C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
cmpq $0x0, -0x8(%rbp)
jne 0xe433
jmp 0xea74
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x20(%rcx), %rax
je 0xea74
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl 0x30(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0xea61
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7c98(%rip), %rsi      # 0x1610d
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x30(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x448(%rbp)
movq -0x30(%rbp), %rdi
callq 0x25d0
movq %rax, %rcx
movq -0x448(%rbp), %rax
cmpq %rcx, %rax
jae 0xea5f
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x2050
cmpl $0x0, %eax
jne 0xea4c
movq -0x10(%rbp), %rdi
leaq 0x82d1(%rip), %rsi      # 0x167b3
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x450(%rbp)
movq -0x40(%rbp), %rdi
callq 0x25d0
movq %rax, %rcx
movq -0x450(%rbp), %rax
cmpq %rcx, %rax
jae 0xe67b
leaq -0x440(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
callq 0x2090
leaq -0x440(%rbp), %rdi
callq 0x4b00
leaq -0x440(%rbp), %rdi
leaq 0x8a8b(%rip), %rsi      # 0x16fe0
callq 0x2050
cmpl $0x0, %eax
jne 0xe5bc
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x8246(%rip), %rsi      # 0x167b3
xorl %edx, %edx
callq 0x28d0
movq %rax, %rdi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
movl $0x1, %edx
callq 0x28d0
movq %rax, %rdi
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7ec4(%rip), %rsi      # 0x1648e
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x460(%rbp)
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x7e9f(%rip), %rsi      # 0x1648e
callq 0x27d0
movq -0x460(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7e71(%rip), %rsi      # 0x16492
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x458(%rbp)
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x7e4c(%rip), %rsi      # 0x16492
callq 0x27d0
movq -0x458(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0xe4f5
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7e05(%rip), %rsi      # 0x1648e
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x4c0(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7dec(%rip), %rsi      # 0x1648e
callq 0x27d0
movq -0x4c0(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7dbe(%rip), %rsi      # 0x16492
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x4b8(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7da5(%rip), %rsi      # 0x16492
callq 0x27d0
movq -0x4b8(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x8009(%rip), %rsi      # 0x16728
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x4b0(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7ff0(%rip), %rsi      # 0x16728
callq 0x27d0
movq -0x4b0(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7fbb(%rip), %rsi      # 0x16725
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x4a8(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7fa2(%rip), %rsi      # 0x16725
callq 0x27d0
movq -0x4a8(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7c29(%rip), %rsi      # 0x163de
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x4a0(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7c10(%rip), %rsi      # 0x163de
callq 0x27d0
movq -0x4a0(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7aba(%rip), %rsi      # 0x162ba
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x498(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7b27(%rip), %rsi      # 0x16340
callq 0x27d0
movq -0x498(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7b00(%rip), %rsi      # 0x1634b
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x490(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7ae7(%rip), %rsi      # 0x1634b
callq 0x27d0
movq -0x490(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7ac0(%rip), %rsi      # 0x16356
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x488(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7aa7(%rip), %rsi      # 0x16356
callq 0x27d0
movq -0x488(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7a8b(%rip), %rsi      # 0x1636c
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x480(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7a72(%rip), %rsi      # 0x1636c
callq 0x27d0
movq -0x480(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x79cb(%rip), %rsi      # 0x162f7
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x478(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x79b2(%rip), %rsi      # 0x162f7
callq 0x27d0
movq -0x478(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x7d09(%rip), %rsi      # 0x16680
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x470(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x7cf0(%rip), %rsi      # 0x16680
callq 0x27d0
movq -0x470(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x8613(%rip), %rsi      # 0x16fd5
xorl %edx, %edx
callq 0x28d0
movq %rax, -0x468(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x85f7(%rip), %rsi      # 0x16fd2
callq 0x27d0
movq -0x468(%rbp), %rdi
movq %rax, %rsi
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
callq 0x3b20
movq -0x20(%rbp), %rax
movq (%rax), %rdi
leaq 0x78ea(%rip), %rsi      # 0x162f7
movl $0x1, %edx
callq 0x28d0
movq %rax, %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movl $0x1, %edx
callq 0x28d0
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq -0x28(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3150
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xea4e
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xe488
jmp 0xea61
jmp 0xea63
movq -0x20(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
jmp 0xe43f
addq $0x4c0, %rsp            # imm = 0x4C0
popq %rbp
retq
nopl (%rax)