// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/parse/use.c
// Function: readuse
void
readuse(Node *use, Stab *st, Vis vis)
{
	size_t i;
	FILE *fd;
	char *t, *p;
	char buf[512];

	/* local (quoted) uses are always relative to the output */
	fd = NULL;
	p = NULL;
	if (use->use.islocal) {
		fd = NULL;
		if (objdir) {
			snprintf(buf,sizeof buf, "%s/%s/%s.use", objdir, localincpath, use->use.name);
			p = strdup(buf);
			fd = fopen(p, "r");
		}
		if (!fd) {
			snprintf(buf,sizeof buf, "%s/%s.use", localincpath, use->use.name);
			p = strdup(buf);
			fd = fopen(p, "r");
		}
		if (!fd) {
			fprintf(stderr, "could not open usefile %s\n", buf);
			exit(1);
		}
	/* nonlocal (barename) uses are always searched on the include path */
	} else {
		for (i = 0; i < nincpaths; i++) {
			snprintf(buf, sizeof buf, "lib%s.use", use->use.name);
			t = strjoin(incpaths[i], "/");
			p = strjoin(t, buf);
			fd = fopen(p, "r");
			if (fd) {
				free(t);
				break;
			}
			free(p);

			t = strjoin(incpaths[i], "/");
			p = strjoin(t, use->use.name);
			fd = fopen(p, "r");
			if (fd) {
				free(t);
				break;
			}
			free(p);
		}
		if (!fd) {
			fprintf(stderr, "could not open usefile %s in search path:\n", use->use.name);
			for (i = 0; i < nincpaths; i++)
				fprintf(stderr, "\t%s\n", incpaths[i]);
			exit(1);
		}
	}

	if (!loaduse(p, fd, st, vis))
		fatal(use, "unable to load %s (full path: %s)", use->use.name, p);
	free(p);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movl %edx, %ebx
movq %rsi, %rbp
movq %rdi, %r13
cmpl $0x0, 0x18(%rdi)
je 0x23e14
leaq 0x3a460(%rip), %rax     # 0x5e1d0
movq (%rax), %rcx
testq %rcx, %rcx
je 0x23dc0
leaq 0x3a4f1(%rip), %rax     # 0x5e270
movq (%rax), %r8
movq 0x20(%r13), %r9
leaq 0x10311(%rip), %rdx     # 0x3409e
leaq 0x20(%rsp), %r14
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdi
xorl %eax, %eax
callq 0x4150
movq %r14, %rdi
callq 0x4340
movq %rax, %r15
leaq 0xeed0(%rip), %rsi      # 0x32c83
movq %rax, %rdi
callq 0x42e0
testq %rax, %rax
jne 0x23e0c
leaq 0x3a4a9(%rip), %rax     # 0x5e270
movq (%rax), %rcx
movq 0x20(%r13), %r8
leaq 0x102cc(%rip), %rdx     # 0x340a1
leaq 0x20(%rsp), %r14
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdi
xorl %eax, %eax
callq 0x4150
movq %r14, %rdi
callq 0x4340
movq %rax, %r15
leaq 0xee88(%rip), %rsi      # 0x32c83
movq %rax, %rdi
callq 0x42e0
testq %rax, %rax
je 0x23fab
movq %rax, %r12
jmp 0x23f20
movq %rbp, 0x18(%rsp)
movl %ebx, 0x14(%rsp)
leaq 0x3a444(%rip), %rbp     # 0x5e268
leaq 0x3a435(%rip), %r14     # 0x5e260
leaq 0x9d18(%rip), %rbx      # 0x2db4a
movq $0x0, (%rsp)
movq %r13, 0x8(%rsp)
movq (%rsp), %rax
cmpq (%rbp), %rax
jae 0x23f4e
movq 0x20(%r13), %rcx
movl $0x200, %esi            # imm = 0x200
leaq 0x20(%rsp), %r12
movq %r12, %rdi
leaq 0x10261(%rip), %rdx     # 0x340c6
xorl %eax, %eax
callq 0x4150
movq (%r14), %rax
movq (%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq %rbx, %rsi
callq 0x2aac4
movq %rax, %r13
movq %rax, %rdi
movq %r12, %rsi
callq 0x2aac4
movq %rax, %r15
movq %rax, %rdi
leaq 0xede9(%rip), %rsi      # 0x32c83
callq 0x42e0
testq %rax, %rax
jne 0x23f07
movq %r15, %rdi
callq 0x4040
movq (%r14), %rax
movq (%rsp), %rcx
movq (%rax,%rcx,8), %rdi
movq %rbx, %rsi
callq 0x2aac4
movq %rax, %r13
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rsi
movq %r13, %rdi
callq 0x2aac4
movq %rax, %r15
movq %rax, %rdi
leaq 0xeda3(%rip), %rsi      # 0x32c83
callq 0x42e0
testq %rax, %rax
jne 0x23f07
movq %r15, %rdi
callq 0x4040
incq (%rsp)
movq 0x8(%rsp), %r13
leaq 0x9c48(%rip), %rbx      # 0x2db4a
jmp 0x23e3f
movq %rax, %r12
movq %r13, %rdi
callq 0x4040
movq 0x8(%rsp), %r13
movl 0x14(%rsp), %ebx
movq 0x18(%rsp), %rbp
movq %r15, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movl %ebx, %ecx
callq 0x231af
testl %eax, %eax
je 0x23f93
movq %r15, %rdi
callq 0x4040
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1d09b(%rip), %r15     # 0x40ff0
movq (%r15), %rdi
movq 0x20(%r13), %rdx
leaq 0x1016d(%rip), %rsi     # 0x340d0
xorl %eax, %eax
callq 0x4240
leaq 0x1018a(%rip), %rbx     # 0x340fb
xorl %r12d, %r12d
cmpq (%rbp), %r12
jae 0x23fc8
movq (%r15), %rdi
movq (%r14), %rax
movq (%rax,%r12,8), %rdx
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4240
incq %r12
jmp 0x23f74
movq 0x20(%r13), %rdx
leaq 0x10162(%rip), %rsi     # 0x34100
movq %r13, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x120fd
movq 0x1d03e(%rip), %rax     # 0x40ff0
movq (%rax), %rdi
leaq 0x100ef(%rip), %rsi     # 0x340ab
leaq 0x20(%rsp), %rdx
xorl %eax, %eax
callq 0x4240
pushq $0x1
popq %rdi
callq 0x4320