// File: /workspace/github_cpp_makefile_star2_O2/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 0xa263
movq %rsi, %r12
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rbx
movq %rsi, 0x20(%rsp)
movq 0x10(%rsp), %rax
cmpq 0x20(%rax), %rbx
je 0xa263
movq (%rbx), %rdi
testb $0x40, 0x30(%rdi)
jne 0xa25a
leaq 0x62fd(%rip), %rsi      # 0x100dc
xorl %edx, %edx
callq 0x26a2
movq %rax, %r15
xorl %r13d, %r13d
movq %rbx, 0x18(%rsp)
movq %rax, 0x8(%rsp)
testq %r15, %r15
je 0x9e09
movq 0x20(%r15), %rax
subq 0x18(%r15), %rax
sarq $0x3, %rax
jmp 0x9e0b
xorl %eax, %eax
cmpq %rax, %r13
jae 0xa25a
movq 0x18(%r15), %rax
movq (%rax,%r13,8), %rax
movq (%rax), %rdi
movq (%r12), %rsi
callq 0x2070
testl %eax, %eax
jne 0xa252
movq %r12, %rdi
leaq 0x6865(%rip), %rsi      # 0x1069f
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
xorl %ebp, %ebp
testq %r14, %r14
je 0x9e59
movq 0x20(%r14), %rax
subq 0x18(%r14), %rax
sarq $0x3, %rax
jmp 0x9e5b
xorl %eax, %eax
cmpq %rax, %rbp
jae 0x9f5c
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 0x3940
movq %r12, %rdi
leaq 0x703e(%rip), %rsi      # 0x10ecc
callq 0x2070
testl %eax, %eax
jne 0x9ed6
movq (%rbx), %rdi
leaq 0x67fe(%rip), %rsi      # 0x1069f
xorl %edx, %edx
callq 0x26a2
movq 0x18(%r14), %rcx
movq (%rcx,%rbp,8), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
pushq $0x1
popq %rdx
callq 0x26a2
movq 0x18(%r14), %rcx
movq (%rcx,%rbp,8), %rsi
movq 0x18(%r15), %rcx
movq (%rcx,%r13,8), %rdx
movq %rax, %rdi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x657f(%rip), %rbx      # 0x1045f
movq %rbx, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r12
movq 0x18(%r14), %rax
movq (%rax,%rbp,8), %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rbx
callq 0x262e
movq 0x18(%r15), %rcx
movq (%rcx,%r13,8), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x6544(%rip), %r15      # 0x10463
movq %r15, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r12
movq 0x18(%r14), %rax
movq (%rax,%rbp,8), %rdi
movq %r15, %rsi
movq 0x8(%rsp), %r15
callq 0x262e
movq 0x18(%r15), %rcx
movq (%rcx,%r13,8), %rdx
movq %r12, %rdi
movq %rax, %rsi
callq 0x30f9
incq %rbp
jmp 0x9e46
movq (%rbx), %rdi
leaq 0x64f9(%rip), %rbx      # 0x1045f
movq %rbx, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq 0x20(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq 0x18(%rsp), %rbx
callq 0x262e
movq 0x18(%r15), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x64be(%rip), %r15      # 0x10463
movq %r15, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x6635(%rip), %r15      # 0x10614
movq %r15, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x65f8(%rip), %r15      # 0x10611
movq %r15, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x635c(%rip), %r15      # 0x103af
movq %r15, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x61fe(%rip), %rsi      # 0x1028b
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
leaq 0x6270(%rip), %rsi      # 0x10311
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x6254(%rip), %r15      # 0x1031c
movq %r15, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x6225(%rip), %r15      # 0x10327
movq %r15, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x6201(%rip), %r15      # 0x1033d
movq %r15, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x6152(%rip), %r15      # 0x102c8
movq %r15, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
movq %r15, %rsi
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x63bc(%rip), %rbp      # 0x1056c
movq %rbp, %rsi
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
movq %rbp, %rsi
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
leaq 0x6cd7(%rip), %rsi      # 0x10ec1
xorl %edx, %edx
callq 0x26a2
movq %rax, %r14
movq %r12, %rdi
leaq 0x6cc0(%rip), %rsi      # 0x10ebe
callq 0x262e
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movq (%rcx,%r13,8), %rdx
movq %r14, %rdi
movq %rax, %rsi
callq 0x30f9
movq (%rbx), %rdi
movq %r15, %rsi
movq 0x8(%rsp), %r15
pushq $0x1
popq %rbp
movl %ebp, %edx
callq 0x26a2
movq 0x28(%rsp), %rcx
movq (%rcx), %rsi
movq %rax, %rdi
movl %ebp, %edx
callq 0x26a2
movq 0x18(%r15), %rax
movq (%rax,%r13,8), %rdi
callq 0x2be9
decq %r13
incq %r13
jmp 0x9df6
addq $0x8, %rbx
jmp 0x9dbc
addq $0x438, %rsp            # imm = 0x438
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq