// File: /workspace/github_c_makefile_star2_O3/takoeight0821[P]hoc_nyan/src/token.c
// Function: next_token
static Token* next_token(void) {
  if (*cur == '\0') {
    return NULL;
  }

  if (start_with("/*", cur)) {
    while (!start_with("*/", cur)) {
      consume();
    }
    consume();
    consume();
    return next_token();
  }

  if (start_with("//", cur)) {
    consume();
    consume();
    while (*cur != '\n') {
      consume();
    }
    return next_token();
  }

  if (bol && *cur == '#') {
    consume();
    if (start_with("define", cur)) {
      Token* token = new_token(TDIRECTIVE, cur);
      token->bol = true;
      cur += strlen("define");
      token->ident = "define";
      return token;
    } else if (start_with("include", cur)) {
      Token* token = new_token(TDIRECTIVE, cur);
      token->bol = true;
      cur += strlen("include");
      token->ident = "include";
      whitespace();
      token->str = read_include_path();
      return token;
    } else if (start_with("ifdef", cur)) {
      Token* token = new_token(TDIRECTIVE, cur);
      token->bol = true;
      cur += strlen("ifdef");
      token->ident = "ifdef";
      return token;
    } else if (start_with("ifndef", cur)) {
      Token* token = new_token(TDIRECTIVE, cur);
      token->bol = true;
      cur += strlen("ifndef");
      token->ident = "ifndef";
      return token;
    } else if (start_with("endif", cur)) {
      Token* token = new_token(TDIRECTIVE, cur);
      token->bol = true;
      cur += strlen("endif");
      token->ident = "endif";
      return token;
    } else {
      print_line(src, cur);
      error("invalid preprocessing directive\n");
    }
  } else if (*cur == '#') {
    print_line(src, cur);
    error("invalid #\n");
  }

  if (strchr(" \t\n\r", *cur)) {
    whitespace();
    return next_token();
  }

  if (strchr("0123456789", *cur)) {
    return integer(cur);
  }

  for (int i = 0; i < (sizeof(punctuators) / sizeof(char*)); i++) {
    if (start_with(punctuators[i], cur)) {
      Token* t = new_reserved(cur, punctuators[i]);
      cur += strlen(punctuators[i]);
      return t;
    }
  }

  for (int i = 0; i < (sizeof(keywords) / sizeof(char*)); i++) {
    if (start_with(keywords[i], cur)) {
      Token* t = new_reserved(cur, keywords[i]);
      cur += strlen(keywords[i]);
      if (isalnum(*cur) || *cur == '_') {
        cur -= strlen(keywords[i]);
      } else {
        return t;
      }
    }
  }

  if ('\"' == *cur) {
    char* start = cur;
    consume();
    StringBuilder* sb = new_sb();
    while (*cur != '\"') {
      sb_putc(sb, read_char());
    }
    consume();
    Token* tok = new_token(TSTRING, start);
    tok->str = sb_run(sb);
    return tok;
  }

  if ('\'' == *cur) {
    consume();
    Token* t = new_token(TINT, cur - 1);
    t->integer = read_char();
    if (*cur != '\'') {
      print_line(src, cur);
      error("expected ' but actual %c\n", *cur);
    }
    consume();
    return t;
  }

  if (isalpha(*cur) || *cur == '_') {
    return ident(cur);
  }

  print_line(src, cur);
  error("invalid character: %c\n", *cur);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x63fd(%rip), %rbx      # 0x131b8
movb (%rbx), %r12b
testb %r12b, %r12b
je 0xd020
movb 0x63f2(%rip), %r13b     # 0x131c0
leaq 0x26d5(%rip), %r14      # 0xf4aa
leaq 0x26d1(%rip), %rdi      # 0xf4ad
movl %r13d, %r15d
cmpb $0x2f, %r12b
jne 0xce4f
movzbl 0x1(%rbx), %eax
cmpl $0x2a, %eax
je 0xcdf2
testl %eax, %eax
jne 0xce4f
movb $0x2a, %cl
xorl %eax, %eax
movb (%rbx,%rax), %dl
testb %dl, %dl
je 0xce86
cmpb %dl, %cl
jne 0xce15
movb 0x1(%rax,%r14), %cl
incq %rax
cmpq $0x2, %rax
jne 0xcdf6
jmp 0xce86
movzbl (%rbx), %ecx
xorl %eax, %eax
cmpl $0xc, %ecx
jg 0xce2b
cmpl $0x9, %ecx
je 0xce43
cmpl $0xa, %ecx
je 0xce37
jmp 0xce35
cmpl $0xd, %ecx
je 0xce37
cmpl $0x20, %ecx
je 0xce43
movb $0x1, %al
movb %al, 0x6383(%rip)       # 0x131c0
movl %eax, %r13d
movl %eax, %r15d
incq %rbx
movq %rbx, 0x636b(%rip)      # 0x131b8
jmp 0xcdf2
movb $0x2f, %cl
xorl %eax, %eax
movb (%rbx,%rax), %dl
testb %dl, %dl
je 0xce6f
cmpb %dl, %cl
jne 0xcf36
movb 0x1(%rax,%rdi), %cl
incq %rax
cmpq $0x2, %rax
jne 0xce53
movzbl %r12b, %ecx
xorl %eax, %eax
cmpl $0xc, %ecx
jg 0xceab
cmpl $0x9, %ecx
je 0xcec3
cmpl $0xa, %ecx
je 0xceb7
jmp 0xceb5
movzbl (%rbx), %ecx
xorl %eax, %eax
cmpl $0xc, %ecx
jg 0xcf47
cmpl $0x9, %ecx
je 0xcf5f
cmpl $0xa, %ecx
je 0xcf53
jmp 0xcf51
cmpl $0xd, %ecx
je 0xceb7
cmpl $0x20, %ecx
je 0xcec3
movb $0x1, %al
movb %al, 0x6303(%rip)       # 0x131c0
movl %eax, %r13d
movl %eax, %r15d
leaq 0x1(%rbx), %rax
movq %rax, 0x62ea(%rip)      # 0x131b8
movzbl 0x1(%rbx), %ecx
xorl %eax, %eax
cmpl $0xc, %ecx
jg 0xcee5
cmpl $0x9, %ecx
je 0xcefd
cmpl $0xa, %ecx
je 0xcef1
jmp 0xceef
cmpl $0xd, %ecx
je 0xcef1
cmpl $0x20, %ecx
je 0xcefd
movb $0x1, %al
movb %al, 0x62c9(%rip)       # 0x131c0
movl %eax, %r13d
movl %eax, %r15d
addq $0x2, %rbx
movzbl (%rbx), %eax
cmpl $0xc, %eax
jle 0xcf15
cmpl $0xd, %eax
je 0xcf24
cmpl $0x20, %eax
je 0xcf31
jmp 0xcf1f
cmpl $0x9, %eax
je 0xcf31
cmpl $0xa, %eax
je 0xcf9d
movb $0x1, %r13b
jmp 0xcf27
xorl %r13d, %r13d
movb %r13b, 0x6292(%rip)     # 0x131c0
movl %r13d, %r15d
incq %rbx
jmp 0xcf01
testb $0x1, %r15b
je 0xcfa6
cmpb $0x23, %r12b
jne 0xcfb0
jmp 0xd4bd
cmpl $0xd, %ecx
je 0xcf53
cmpl $0x20, %ecx
je 0xcf5f
movb $0x1, %al
movb %al, 0x6267(%rip)       # 0x131c0
movl %eax, %r13d
movl %eax, %r15d
leaq 0x1(%rbx), %rax
movq %rax, 0x624e(%rip)      # 0x131b8
movzbl 0x1(%rbx), %ecx
xorl %eax, %eax
cmpl $0xc, %ecx
jg 0xcf81
cmpl $0x9, %ecx
je 0xcf99
cmpl $0xa, %ecx
je 0xcf8d
jmp 0xcf8b
cmpl $0xd, %ecx
je 0xcf8d
cmpl $0x20, %ecx
je 0xcf99
movb $0x1, %al
movb %al, 0x622d(%rip)       # 0x131c0
movl %eax, %r13d
movl %eax, %r15d
addq $0x2, %rbx
movq %rbx, 0x6214(%rip)      # 0x131b8
jmp 0xd014
cmpb $0x23, %r12b
je 0xd0e6
movsbl %r12b, %ebp
movl $0x5, %edx
leaq 0x251c(%rip), %rdi      # 0xf4dc
movl %ebp, %esi
callq 0x20e0
testq %rax, %rax
je 0xd034
incq %rbx
leaq 0x24d7(%rip), %rdi      # 0xf4ad
movzbl %r12b, %eax
cmpl $0xc, %eax
jg 0xcfeb
cmpl $0x9, %eax
je 0xd002
cmpl $0xa, %eax
je 0xcff5
jmp 0xd011
cmpl $0x20, %eax
je 0xd002
cmpl $0xd, %eax
jne 0xd011
movb $0x0, 0x61c4(%rip)      # 0x131c0
xorl %r13d, %r13d
xorl %r15d, %r15d
movq %rbx, 0x61af(%rip)      # 0x131b8
movb (%rbx), %r12b
incq %rbx
jmp 0xcfd6
decq %rbx
movb (%rbx), %r12b
testb %r12b, %r12b
jne 0xcddf
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x24a6(%rip), %rdi      # 0xf4e1
movl $0xb, %edx
movl %ebp, %esi
callq 0x20e0
testq %rax, %rax
je 0xd162
movl $0x1, %edi
movl $0x38, %esi
callq 0x20f0
movq %rax, %rbp
movq 0x6147(%rip), %rax      # 0x131b0
movq %rax, 0x20(%rbp)
movq %rbx, 0x28(%rbp)
notb %r15b
andb $0x1, %r15b
movb %r15b, 0x30(%rbp)
callq 0x2190
movq (%rax), %rax
movsbq %r12b, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
je 0xd022
xorl %ecx, %ecx
movzbl %r12b, %esi
xorl %edx, %edx
cmpl $0xc, %esi
jg 0xd0a8
cmpl $0x9, %esi
je 0xd0ba
cmpl $0xa, %esi
je 0xd0b4
jmp 0xd0b2
cmpl $0xd, %esi
je 0xd0b4
cmpl $0x20, %esi
je 0xd0ba
movb $0x1, %dl
movb %dl, 0x6106(%rip)       # 0x131c0
movsbl %r12b, %edx
leal (%rcx,%rcx,4), %ecx
leal (%rdx,%rcx,2), %ecx
addl $-0x30, %ecx
movsbq 0x1(%rbx), %r12
incq %rbx
testb $0x8, 0x1(%rax,%r12,2)
jne 0xd091
movl %ecx, 0xc(%rbp)
movq %rbx, 0x60d7(%rip)      # 0x131b8
jmp 0xd022
movb $0x1, 0x60d3(%rip)      # 0x131c0
leaq 0x1(%rbx), %r15
movq %r15, 0x60c0(%rip)      # 0x131b8
movb $0x64, %cl
movl $0x1, %eax
leaq 0xf06(%rip), %r14       # 0xe00c
movb (%rbx,%rax), %dl
testb %dl, %dl
je 0xd122
cmpb %dl, %cl
jne 0xd2c3
movb (%rax,%r14), %cl
incq %rax
cmpq $0x7, %rax
jne 0xd106
movl $0x1, %edi
movl $0x38, %esi
callq 0x20f0
movq %rax, %rbp
movl $0x4, 0x8(%rax)
movq 0x606e(%rip), %rax      # 0x131b0
movq %rax, 0x20(%rbp)
movq %r15, 0x28(%rbp)
movb $0x1, 0x30(%rbp)
addq $0x7, %rbx
movq %rbx, 0x605f(%rip)      # 0x131b8
movq %r14, 0x10(%rbp)
jmp 0xd022
xorl %eax, %eax
leaq 0x59b5(%rip), %rcx      # 0x12b20
movq (%rcx,%rax,8), %r14
movb (%r14), %dl
testb %dl, %dl
je 0xd29e
xorl %esi, %esi
movb (%rbx,%rsi), %dil
testb %dil, %dil
je 0xd29e
cmpb %dil, %dl
jne 0xd19f
movb 0x1(%r14,%rsi), %dl
incq %rsi
testb %dl, %dl
jne 0xd17c
jmp 0xd29e
incq %rax
cmpq $0x2e, %rax
jne 0xd16b
movq 0x6001(%rip), %r15      # 0x131b0
notb %r13b
andb $0x1, %r13b
xorl %r14d, %r14d
leaq 0x5ad0(%rip), %rax      # 0x12c90
movq (%rax,%r14,8), %r12
movb (%r12), %al
testb %al, %al
je 0xd1e5
xorl %ecx, %ecx
movb (%rbx,%rcx), %dl
testb %dl, %dl
je 0xd1e5
cmpb %dl, %al
jne 0xd24a
movb 0x1(%r12,%rcx), %al
incq %rcx
testb %al, %al
jne 0xd1ce
movl $0x1, %edi
movl $0x38, %esi
callq 0x20f0
movl $0x3, 0x8(%rax)
movq %r15, 0x20(%rax)
movq %rbx, 0x28(%rax)
movb %r13b, 0x30(%rax)
movq %rax, %rbp
movq %r12, 0x10(%rax)
movq %r12, %rdi
callq 0x2080
movq %rax, %r12
addq %rbx, %rax
movq %rax, 0x5f95(%rip)      # 0x131b8
callq 0x2190
movsbq (%rbx,%r12), %rcx
cmpq $0x5f, %rcx
je 0xd243
movq (%rax), %rax
movzwl (%rax,%rcx,2), %eax
andl $0x8, %eax
je 0xd022
movq %rbx, 0x5f6e(%rip)      # 0x131b8
incq %r14
cmpq $0x2b, %r14
jne 0xd1b9
movzbl (%rbx), %r14d
cmpl $0x27, %r14d
je 0xd435
cmpl $0x22, %r14d
jne 0xd48a
callq 0xd7e9
callq 0xd9db
movq %rax, %r15
movq 0x5f35(%rip), %rax      # 0x131b8
cmpb $0x22, (%rax)
je 0xd3f0
callq 0xd630
movsbl %al, %esi
movq %r15, %rdi
callq 0xda0d
jmp 0xd27c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd5e9
movq %rax, %rbx
movq %r14, %rdi
callq 0x2080
addq %rax, 0x5efd(%rip)      # 0x131b8
movq %rbx, %rax
jmp 0xd025
movb $0x69, %cl
movl $0x1, %eax
leaq 0xd4d(%rip), %r14       # 0xe01e
movb (%rbx,%rax), %dl
testb %dl, %dl
je 0xd2e9
cmpb %dl, %cl
jne 0xd337
movb (%rax,%r14), %cl
incq %rax
cmpq $0x8, %rax
jne 0xd2d1
movl $0x1, %edi
movl $0x38, %esi
callq 0x20f0
movq %rax, %rbp
movl $0x4, 0x8(%rax)
movq 0x5ea7(%rip), %rax      # 0x131b0
movq %rax, 0x20(%rbp)
movq %r15, 0x28(%rbp)
movb $0x1, 0x30(%rbp)
addq $0x8, %rbx
movq %rbx, 0x5e98(%rip)      # 0x131b8
movq %r14, 0x10(%rbp)
callq 0xd823
callq 0xd534
movq %rax, 0x18(%rbp)
jmp 0xd022
movb $0x69, %cl
movl $0x1, %eax
leaq 0xce1(%rip), %r14       # 0xe026
movb (%rbx,%rax), %dl
testb %dl, %dl
je 0xd35d
cmpb %dl, %cl
jne 0xd392
movb (%rax,%r14), %cl
incq %rax
cmpq $0x6, %rax
jne 0xd345
movl $0x1, %edi
movl $0x38, %esi
callq 0x20f0
movq %rax, %rbp
movl $0x4, 0x8(%rax)
movq 0x5e33(%rip), %rax      # 0x131b0
movq %rax, 0x20(%rbp)
movq %r15, 0x28(%rbp)
movb $0x1, 0x30(%rbp)
addq $0x6, %rbx
jmp 0xd152
movb $0x69, %cl
movl $0x1, %eax
leaq 0xc8c(%rip), %r14       # 0xe02c
movb (%rbx,%rax), %dl
testb %dl, %dl
je 0xd122
cmpb %dl, %cl
jne 0xd3c1
movb (%rax,%r14), %cl
incq %rax
cmpq $0x7, %rax
jne 0xd3a0
jmp 0xd122
movb $0x65, %cl
movl $0x1, %eax
leaq 0xc64(%rip), %r14       # 0xe033
movb (%rbx,%rax), %dl
testb %dl, %dl
je 0xd35d
cmpb %dl, %cl
jne 0xd4da
movb (%rax,%r14), %cl
incq %rax
cmpq $0x6, %rax
jne 0xd3cf
jmp 0xd35d
callq 0xd7e9
movl $0x1, %edi
movl $0x38, %esi
callq 0x20f0
movq %rax, %rbp
movl $0x1, 0x8(%rax)
movq 0x5d9b(%rip), %rax      # 0x131b0
movq %rax, 0x20(%rbp)
movq %rbx, 0x28(%rbp)
movb 0x5d9d(%rip), %al       # 0x131c0
xorb $0x1, %al
movb %al, 0x30(%rbp)
movq %r15, %rdi
callq 0xda87
jmp 0xd32e
callq 0xd7e9
movq 0x5d77(%rip), %rbx      # 0x131b8
decq %rbx
movl $0x1, %edi
movl $0x38, %esi
callq 0x20f0
movq %rax, %rbp
movq %r15, 0x20(%rax)
movq %rbx, 0x28(%rax)
movb 0x5d5c(%rip), %al       # 0x131c0
xorb $0x1, %al
movb %al, 0x30(%rbp)
callq 0xd630
movsbl %al, %eax
movl %eax, 0xc(%rbp)
movq 0x5d3d(%rip), %rsi      # 0x131b8
cmpb $0x27, (%rsi)
jne 0xd4f2
callq 0xd7e9
jmp 0xd022
callq 0x2190
cmpb $0x5f, %r14b
je 0xd4a7
movsbq %r14b, %rcx
movq (%rax), %rax
movzwl (%rax,%rcx,2), %eax
andl $0x400, %eax            # imm = 0x400
je 0xd511
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd720
movq 0x5cec(%rip), %rdi      # 0x131b0
movq %rbx, %rsi
callq 0xcc36
leaq 0x1ffe(%rip), %rdi      # 0xf4d1
xorl %eax, %eax
callq 0xd930
movq 0x5ccf(%rip), %rdi      # 0x131b0
movq %r15, %rsi
callq 0xcc36
leaq 0x1fc0(%rip), %rdi      # 0xf4b0
jmp 0xd4d3
movq 0x5cb7(%rip), %rdi      # 0x131b0
callq 0xcc36
movq 0x5cb3(%rip), %rax      # 0x131b8
movsbl (%rax), %esi
leaq 0x1fdd(%rip), %rdi      # 0xf4ec
jmp 0xd52d
movq %r15, %rdi
movq %rbx, %rsi
callq 0xcc36
movq 0x5c95(%rip), %rax      # 0x131b8
movsbl (%rax), %esi
leaq 0x1fd9(%rip), %rdi      # 0xf506
xorl %eax, %eax
callq 0xd930