// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x438, %rsp            # imm = 0x438
movq %rdx, 0x28(%rsp)
movq %rdi, 0x10(%rsp)
testq %rdi, %rdi
je 0xb580
movq 0x10(%rsp), %rax
movq 0x18(%rax), %r15
cmpq 0x20(%rax), %r15
je 0xb580
movq %rsi, %r12
movq %rsi, 0x20(%rsp)
movq (%r15), %rdi
testb $0x40, 0x30(%rdi)
jne 0xb56d
leaq 0x6fee(%rip), %rsi      # 0x120dc
xorl %edx, %edx
callq 0x2745
movq %rax, %r13
xorl %ebx, %ebx
movq %r15, 0x18(%rsp)
movq %rax, 0x8(%rsp)
testq %r13, %r13
je 0xb117
movq 0x20(%r13), %rax
subq 0x18(%r13), %rax
sarq $0x3, %rax
jmp 0xb119
xorl %eax, %eax
cmpq %rax, %rbx
jae 0xb56d
movq 0x18(%r13), %rax
movq (%rax,%rbx,8), %rax
movq (%rax), %rdi
movq (%r12), %rsi
callq 0x2070
testl %eax, %eax
jne 0xb565
movq %r12, %rdi
leaq 0x7555(%rip), %rsi      # 0x1269d
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
xorl %ebp, %ebp
testq %r14, %r14
je 0xb167
movq 0x20(%r14), %rax
subq 0x18(%r14), %rax
sarq $0x3, %rax
jmp 0xb169
xorl %eax, %eax
cmpq %rax, %rbp
jae 0xb26c
movq 0x18(%r14), %rax
movq (%rax,%rbp,8), %rax
movq (%rax), %rsi
leaq 0x30(%rsp), %r12
movq %r12, %rdi
callq 0x20b0
movq %r12, %rdi
callq 0x3cdc
movq %r12, %rdi
leaq 0x7d2e(%rip), %rsi      # 0x12eca
callq 0x2070
testl %eax, %eax
jne 0xb1e6
movq (%r15), %rdi
leaq 0x74ee(%rip), %rsi      # 0x1269d
xorl %edx, %edx
callq 0x2745
movq 0x18(%r14), %rcx
movq (%rcx,%rbp,8), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
movl $0x1, %edx
callq 0x2745
movq 0x18(%r14), %rcx
movq (%rcx,%rbp,8), %rsi
movq 0x18(%r13), %rcx
movq (%rcx,%rbx,8), %rdx
movq %rax, %rdi
callq 0x334b
movq (%r15), %rdi
leaq 0x726d(%rip), %r15      # 0x1245d
movq %r15, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r12
movq 0x18(%r14), %rax
movq (%rax,%rbp,8), %rdi
movq %r15, %rsi
movq 0x18(%rsp), %r15
callq 0x26b0
movq 0x18(%r13), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x7232(%rip), %r13      # 0x12461
movq %r13, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r12
movq 0x18(%r14), %rax
movq (%rax,%rbp,8), %rdi
movq %r13, %rsi
movq 0x8(%rsp), %r13
callq 0x26b0
movq 0x18(%r13), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x334b
incq %rbp
jmp 0xb154
movq (%r15), %rdi
leaq 0x71e7(%rip), %r15      # 0x1245d
movq %r15, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq 0x18(%rsp), %r15
callq 0x26b0
movq 0x18(%r13), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x71ac(%rip), %r13      # 0x12461
movq %r13, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x7323(%rip), %r13      # 0x12612
movq %r13, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x72e6(%rip), %r13      # 0x1260f
movq %r13, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x704a(%rip), %r13      # 0x123ad
movq %r13, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x6eec(%rip), %rsi      # 0x12289
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
leaq 0x6f5e(%rip), %rsi      # 0x1230f
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x6f42(%rip), %r13      # 0x1231a
movq %r13, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x6f13(%rip), %r13      # 0x12325
movq %r13, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x6eef(%rip), %r13      # 0x1233b
movq %r13, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x6e40(%rip), %r13      # 0x122c6
movq %r13, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
movq %r13, %rsi
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x70aa(%rip), %rbp      # 0x1256a
movq %rbp, %rsi
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
movq %rbp, %rsi
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
leaq 0x79c5(%rip), %rsi      # 0x12ebf
xorl %edx, %edx
callq 0x2745
movq %rax, %r14
movq %r12, %rdi
leaq 0x79ae(%rip), %rsi      # 0x12ebc
callq 0x26b0
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%rbx,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x334b
movq (%r15), %rdi
movq %r13, %rsi
movq 0x8(%rsp), %r13
movl $0x1, %edx
callq 0x2745
movq 0x28(%rsp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
movl $0x1, %edx
callq 0x2745
movq 0x18(%r13), %rax
movq (%rax,%rbx,8), %rdi
callq 0x2da0
decq %rbx
incq %rbx
jmp 0xb104
addq $0x8, %r15
movq 0x10(%rsp), %rax
cmpq 0x20(%rax), %r15
jne 0xb0da
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq