// File: /workspace/github_c_makefile_star2_O1/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 0x6759
movl %eax, %ebp
movq (%r14), %rbx
addq $0x28, %rbx
cmpb $0x20, %bpl
jne 0xb6dd
movq %r14, %rdi
callq 0x6776
movl %eax, %ebp
jmp 0xb6cb
movzbl %bpl, %eax
cmpl $0x22, %eax
je 0xb6fc
cmpl $0x3c, %eax
je 0xb6fc
leaq 0x3787(%rip), %rsi      # 0xee79
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3250
movq %rbx, (%rsp)
movq %r14, %rdi
callq 0x6776
movl %eax, %r13d
movl $0x100, %edi            # imm = 0x100
callq 0x3170
movq %rax, %r15
cmpb $0x22, %bpl
movl $0x22, %eax
movl $0x3e, %r12d
cmovel %eax, %r12d
movsbl %r13b, %eax
cmpl %eax, %r12d
jne 0xb739
xorl %r12d, %r12d
jmp 0xb76a
xorl %ebx, %ebx
testb %r13b, %r13b
je 0xb7cc
movzbl %r13b, %eax
cmpl $0xa, %eax
je 0xb7c3
movb %r13b, (%r15,%rbx)
incq %rbx
movq %r14, %rdi
callq 0x6776
movl %eax, %r13d
movsbl %al, %eax
cmpl %eax, %r12d
jne 0xb73b
movl %ebx, %r12d
xorl %ebx, %ebx
movb %bl, (%r15,%r12)
movq %r14, %rdi
callq 0x6776
addq $0xf, %r12
movq %r12, %rdi
callq 0x3170
movq %rax, %r12
movb %bl, (%rax)
cmpb $0x22, %bpl
jne 0xb819
movq %r15, %rdi
movl $0x2f, %esi
callq 0x30e0
testq %rax, %rax
je 0xb7ef
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 0xb7ff
leaq 0x36d4(%rip), %rsi      # 0xee9e
jmp 0xb7d3
leaq 0x36ed(%rip), %rsi      # 0xeec0
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 0x3250
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 0x5956
testl %eax, %eax
jne 0xb850
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 0x5956
testl %eax, %eax
je 0xb85f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x344c
jmp 0xb850