// File: /workspace/github_c_makefile_star2_O3/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 0x677e
movl %eax, %ebp
movq (%r14), %rbx
addq $0x28, %rbx
cmpb $0x20, %bpl
jne 0xb65d
movq %r14, %rdi
callq 0x6798
movl %eax, %ebp
jmp 0xb64b
movzbl %bpl, %eax
cmpl $0x22, %eax
je 0xb67c
cmpl $0x3c, %eax
je 0xb67c
leaq 0x3807(%rip), %rsi      # 0xee79
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3250
movq %rbx, (%rsp)
movq %r14, %rdi
callq 0x6798
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 0xb6b9
xorl %r12d, %r12d
jmp 0xb6ea
xorl %ebx, %ebx
testb %r13b, %r13b
je 0xb74c
movzbl %r13b, %eax
cmpl $0xa, %eax
je 0xb743
movb %r13b, (%r15,%rbx)
incq %rbx
movq %r14, %rdi
callq 0x6798
movl %eax, %r13d
movsbl %al, %eax
cmpl %eax, %r12d
jne 0xb6bb
movl %ebx, %r12d
xorl %ebx, %ebx
movb %bl, (%r15,%r12)
movq %r14, %rdi
callq 0x6798
addq $0xf, %r12
movq %r12, %rdi
callq 0x3170
movq %rax, %r12
movb %bl, (%rax)
cmpb $0x22, %bpl
jne 0xb799
movq %r15, %rdi
movl $0x2f, %esi
callq 0x30e0
testq %rax, %rax
je 0xb76f
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 0xb77f
leaq 0x3754(%rip), %rsi      # 0xee9e
jmp 0xb753
leaq 0x376d(%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 0x59da
testl %eax, %eax
jne 0xb7d0
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 0x59da
testl %eax, %eax
je 0xb7df
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 0xb7d0