// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]tundra/src/IncludeScanner.cpp
// Function: t2::ScanCppLine(char const*, t2::MemAllocLinear*)
static IncludeData*
ScanCppLine(const char* start, MemAllocLinear* allocator)
{
	while (isspace(*start))
		++start;

	if (*start++ != '#')
		return nullptr;

	while (isspace(*start))
		++start;
	
	if (0 != strncmp("include", start, 7))
		return nullptr;

	start += 7;

	if (!isspace(*start++))
		return nullptr;

	while (isspace(*start))
		++start;

  IncludeData* dest = LinearAllocate<IncludeData>(allocator);

  char closing_separator;

  switch (*start++)
  {
    case '<':
      closing_separator = '>';
      break;
    case '"':
      closing_separator = '"';
      break;
    default:
      return nullptr;
  }

	const char* str_start = start;
	for (;;)
	{
		char ch = *start++;
		if (ch == closing_separator)
			break;
		if (!ch)
			return nullptr;
	}

	dest->m_StringLen       = (size_t) (start - str_start - 1);
	dest->m_String          = StrDupN(allocator, str_start, dest->m_StringLen);
	dest->m_IsSystemInclude = '>' == closing_separator;
	dest->m_ShouldFollow    = true;
	dest->m_Next            = nullptr;

  return dest;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %edi
callq 0x3070
cmpl $0x0, %eax
je 0x21a1f
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x21a00
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movsbl (%rax), %eax
cmpl $0x23, %eax
je 0x21a43
movq $0x0, -0x8(%rbp)
jmp 0x21bd5
jmp 0x21a45
movq -0x10(%rbp), %rax
movsbl (%rax), %edi
callq 0x3070
cmpl $0x0, %eax
je 0x21a64
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x21a45
movq -0x10(%rbp), %rsi
leaq 0x3caf(%rip), %rdi      # 0x2571e
movl $0x7, %edx
callq 0x3180
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x21a8e
movq $0x0, -0x8(%rbp)
jmp 0x21bd5
movq -0x10(%rbp), %rax
addq $0x7, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movsbl (%rax), %edi
callq 0x3070
cmpl $0x0, %eax
jne 0x21ac3
movq $0x0, -0x8(%rbp)
jmp 0x21bd5
jmp 0x21ac5
movq -0x10(%rbp), %rax
movsbl (%rax), %edi
callq 0x3070
cmpl $0x0, %eax
je 0x21ae4
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x21ac5
movq -0x18(%rbp), %rdi
callq 0x22000
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
incq %rcx
movq %rcx, -0x10(%rbp)
movsbl (%rax), %eax
movl %eax, -0x38(%rbp)
subl $0x22, %eax
je 0x21b1c
jmp 0x21b0c
movl -0x38(%rbp), %eax
subl $0x3c, %eax
jne 0x21b22
jmp 0x21b16
movb $0x3e, -0x21(%rbp)
jmp 0x21b2f
movb $0x22, -0x21(%rbp)
jmp 0x21b2f
movq $0x0, -0x8(%rbp)
jmp 0x21bd5
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x10(%rbp)
movb (%rax), %al
movb %al, -0x31(%rbp)
movsbl -0x31(%rbp), %eax
movsbl -0x21(%rbp), %ecx
cmpl %ecx, %eax
jne 0x21b59
jmp 0x21b6b
cmpb $0x0, -0x31(%rbp)
jne 0x21b69
movq $0x0, -0x8(%rbp)
jmp 0x21bd5
jmp 0x21b37
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
subq %rax, %rcx
subq $0x1, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdx
callq 0x15fb0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movsbl -0x21(%rbp), %ecx
movl $0x3e, %eax
cmpl %ecx, %eax
sete %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x10(%rax)
movq -0x20(%rbp), %rax
movb $0x1, 0x11(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x18(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop