// File: /workspace/github_c_makefile_star2_O2/Yamsman[P]scc/src/ppd.c
// Function: ppd_include
void ppd_include(lexer *lx) {
	char cur = lex_cur(lx);
	s_pos *loc = &lx->tgt->loc;
	while (cur == ' ') cur = lex_advc(lx);

	//Get include type
	char type = cur;
	if (type != '<' && type != '"')
		c_error(loc, "#include expects <fname> or \"fname\"\n");
	cur = lex_advc(lx);

	//Get filename
	int fnlen = 0;
	int bsize = 256;
	char *fname = malloc(bsize);
	char endc = (type == '"') ? '"' : '>';
	while (cur != endc) {
		if (cur == '\n') {
			c_error(loc, "Expected '%c' before end of line\n", endc);
			return;
		} else if (cur == '\0') {
			c_error(loc, "Expected '%c' before end of file\n", endc);
			return;
		}
		fname[fnlen++] = cur;
		cur = lex_advc(lx);
	}
	fname[fnlen] = '\0';
	lex_advc(lx);

	//Attempt to locate and open the included file
	FILE *input_f = NULL;
	char *fdir = malloc(fnlen + sizeof("/usr/include/") + 1);
	fdir[0] = '\0';
	if (type == '"') {
		char *slash = strrchr(fname, '/');
		if (!slash) {
			strcpy(fdir, "./");
			strcat(fdir, fname);
		} else {
			memcpy(fdir, fname, slash - fname);
			fdir[slash-fname] = '\0';
			strcat(fdir, slash);
		}
		if (lex_open_file(lx, fdir)) goto done;
	}
	fdir[0] = '\0';

	//Attempt system include directory
	strcpy(fdir, "/usr/include/");
	strcat(fdir, fname);
	if (!lex_open_file(lx, fdir)) {
		c_error(loc, "Unable to open file '%s': ", fname);
		fflush(stdout);
		perror(NULL);
		free(fdir);
	}
done:	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x6493
movl %eax, %ebp
movq (%r14), %rbx
addq $0x28, %rbx
cmpb $0x20, %bpl
jne 0xae4d
movq %r14, %rdi
callq 0x64ad
movl %eax, %ebp
jmp 0xae3b
movzbl %bpl, %eax
cmpl $0x22, %eax
je 0xae6c
cmpl $0x3c, %eax
je 0xae6c
leaq 0x3017(%rip), %rsi      # 0xde79
movq %rbx, %rdi
xorl %eax, %eax
callq 0x35e4
movq %rbx, (%rsp)
movq %r14, %rdi
callq 0x64ad
movl %eax, %r13d
movl $0x100, %edi            # imm = 0x100
callq 0x3170
movq %rax, %r15
cmpb $0x22, %bpl
pushq $0x22
popq %rax
pushq $0x3e
popq %r12
cmovel %eax, %r12d
xorl %ebx, %ebx
movsbl %r13b, %eax
cmpl %eax, %r12d
je 0xaec8
testb %r13b, %r13b
je 0xaf2b
movzbl %r13b, %eax
cmpl $0xa, %eax
je 0xaf22
movb %r13b, (%r15,%rbx)
incq %rbx
movq %r14, %rdi
callq 0x64ad
movl %eax, %r13d
jmp 0xae99
movl %ebx, %r12d
xorl %ebx, %ebx
movb %bl, (%r15,%r12)
movq %r14, %rdi
callq 0x64ad
addq $0xf, %r12
movq %r12, %rdi
callq 0x3170
movq %rax, %r12
movb %bl, (%rax)
cmpb $0x22, %bpl
jne 0xaf78
pushq $0x2f
popq %rsi
movq %r15, %rdi
callq 0x30e0
testq %rax, %rax
je 0xaf4e
movq %rax, %r13
movq %rax, %rbp
subq %r15, %rbp
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x3150
movb $0x0, (%r12,%rbp)
jmp 0xaf5e
leaq 0x2f75(%rip), %rsi      # 0xde9e
jmp 0xaf32
leaq 0x2f8e(%rip), %rsi      # 0xdec0
movq (%rsp), %rdi
movl %r12d, %edx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x35e4
movb $0x0, 0x2(%r12)
movw $0x2f2e, (%r12)         # imm = 0x2F2E
movq %r15, %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x3210
movq %r14, %rdi
movq %r12, %rsi
callq 0x57b0
testl %eax, %eax
jne 0xafaf
movabsq $0x2f6564756c636e, %rax # imm = 0x2F6564756C636E
movq %rax, 0x6(%r12)
movabsq $0x636e692f7273752f, %rax # imm = 0x636E692F7273752F
movq %rax, (%r12)
movq %r12, %rdi
movq %r15, %rsi
callq 0x3210
movq %r14, %rdi
movq %r12, %rsi
callq 0x57b0
testl %eax, %eax
je 0xafbe
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1c5f(%rip), %rsi      # 0xcc24
movq (%rsp), %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x35e4
movq 0x7ff6(%rip), %rax      # 0x12fd0
movq (%rax), %rdi
callq 0x3180
xorl %edi, %edi
callq 0x31d0
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3030