// File: /workspace/github_c_makefile_star2_O2/ejunjsh[P]mycc/scan.c
// Function: scan
int scan(struct token *t) {
  int c, tokentype;

  // 如果有个向前看的token，返回这个token
  if (Peektoken.token != 0) {
    t->token = Peektoken.token;
    t->tokstr = Peektoken.tokstr;
    t->intvalue = Peektoken.intvalue;
    Peektoken.token = 0;
    return (1);
  }

  // 跳过空格
  c = skip();

  // 判断token是什么样的token
  switch (c) {
    case EOF:
      t->token = T_EOF;
      return (0);
    case '+':
      if ((c = next()) == '+') {
	    t->token = T_INC;
      } else if (c == '=') {
	    t->token = T_ASPLUS;
      } else {
        putback(c);
        t->token = T_PLUS;
      }
      break;
    case '-':
      if ((c = next()) == '-') {
	    t->token = T_DEC;
      } else if (c == '>') {
	    t->token = T_ARROW;
      } else if (c == '=') {
	    t->token = T_ASMINUS;
      } else if (isdigit(c)) {	// 负数
	    t->intvalue = -scanint(c);
	    t->token = T_INTLIT;
      } else {
        putback(c);
        t->token = T_MINUS;
      }
      break;
    case '*':
      if ((c = next()) == '=') {
	    t->token = T_ASSTAR;
      } else {
        putback(c);
        t->token = T_STAR;
      }
      break;
    case '/':
      if ((c = next()) == '=') {
	    t->token = T_ASSLASH;
      } else {
        putback(c);
        t->token = T_SLASH;
      }
      break;
    case '%':
      if ((c = next()) == '=') {
	    t->token = T_ASMOD;
      } else {
        putback(c);
        t->token = T_MOD;
      }
      break;
    case ';':
      t->token = T_SEMI;
      break;
    case '{':
      t->token = T_LBRACE;
      break;
    case '}':
      t->token = T_RBRACE;
      break;
    case '(':
      t->token = T_LPAREN;
      break;
    case ')':
      t->token = T_RPAREN;
      break;
    case '[':
      t->token = T_LBRACKET;
      break;
    case ']':
      t->token = T_RBRACKET;
      break;
    case '~':
      t->token = T_INVERT;
      break;
    case '^':
      t->token = T_XOR;
      break;
    case ',':
      t->token = T_COMMA;
      break;
    case '.':
      t->token = T_DOT;
      break;
    case ':':
      t->token = T_COLON;
      break;
    case '?':
      t->token = T_QUESTION;
      break;
    case '=':
      if ((c = next()) == '=') {
	    t->token = T_EQ;
      } else {
        putback(c);
        t->token = T_ASSIGN;
      }
      break;
    case '!':
      if ((c = next()) == '=') {
	    t->token = T_NE;
      } else {
        putback(c);
        t->token = T_LOGNOT;
      }
      break;
    case '<':
      if ((c = next()) == '=') {
	    t->token = T_LE;
      } else if (c == '<') {
	    t->token = T_LSHIFT;
      } else {
        putback(c);
        t->token = T_LT;
      }
      break;
    case '>':
      if ((c = next()) == '=') {
	    t->token = T_GE;
      } else if (c == '>') {
	    t->token = T_RSHIFT;
      } else {
        putback(c);
        t->token = T_GT;
      }
      break;
    case '&':
      if ((c = next()) == '&') {
	    t->token = T_LOGAND;
      } else {
        putback(c);
        t->token = T_AMPER;
      }
      break;
    case '|':
      if ((c = next()) == '|') {
	    t->token = T_LOGOR;
      } else {
        putback(c);
        t->token = T_OR;
      }
      break;
    case '\'':
      // 如果是单引号，那就是要扫描字符了
      t->intvalue = scanch();
      t->token = T_INTLIT;
      if (next() != '\'')
	    fatal("Expected '\\'' at end of char literal");
      break;
    case '"':
      // 扫描字符串
      scanstr(Text);
      t->token = T_STRLIT;
      break;
    default:
      // 如果是数字，就扫描为字面量整型
      if (isdigit(c)) {
        t->intvalue = scanint(c);
        t->token = T_INTLIT;
        break;
      } else if (isalpha(c) || '_' == c) {
        // 读入关键字或标识符
        scanident(c, Text, TEXTLEN);

        // 如果是关键字，返回关键字的token
        if ((tokentype = keyword(Text)) != 0) {
            t->token = tokentype;
            break;
        }

        // 如果不是关键字，那就肯定是标识符
        t->token = T_IDENT;
        break;
      }

      // 到这里，就代表不是认识的token了，报错
      fatalc("Unrecognised character", c);
  }

  // 找到token啦
  t->tokstr = Tstring[t->token];
  return (1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x7cac(%rip), %rax      # 0xe3b8
movl (%rax), %ecx
testl %ecx, %ecx
je 0x672a
movl %ecx, (%rbx)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rbx)
movl 0x10(%rax), %ecx
movl %ecx, 0x10(%rbx)
andl $0x0, (%rax)
jmp 0x6edb
leaq 0x3edf(%rip), %r15      # 0xa610
callq 0x6eed
movl %eax, %r14d
leal -0x9(%r14), %eax
cmpl $0x36, %eax
ja 0x6764
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
callq 0x6eed
cmpl $0x3d, %eax
jne 0x6a41
movl $0xe, (%rbx)
jmp 0x6ec9
leal -0x7b(%r14), %eax
cmpl $0x3, %eax
jbe 0x679c
cmpl $-0x1, %r14d
je 0x69ba
cmpl $0x5b, %r14d
je 0x69fe
cmpl $0x5d, %r14d
je 0x69cf
cmpl $0x5e, %r14d
jne 0x67b7
movl $0xb, (%rbx)
jmp 0x6ec9
leaq 0x3f49(%rip), %rcx      # 0xa6ec
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x37, (%rbx)
jmp 0x6ec9
callq 0x21b0
movq %rax, %r15
movq (%rax), %rax
movslq %r14d, %rcx
movzwl (%rax,%rcx,2), %eax
movzwl %ax, %ecx
btl $0xb, %ecx
jb 0x6a09
cmpl $0x5f, %r14d
je 0x6ac9
andl $0x400, %ecx            # imm = 0x400
jne 0x6ac9
leaq 0x403f(%rip), %rdi      # 0xa832
movl %r14d, %esi
callq 0x65c8
jmp 0x6ec9
callq 0x6eed
cmpl $0x3e, %eax
je 0x6b83
cmpl $0x3d, %eax
jne 0x6b8e
movl $0x12, (%rbx)
jmp 0x6ec9
movl $0x7, (%rbx)
jmp 0x6ec9
callq 0x70a8
movl %eax, 0x10(%rbx)
movl $0x33, (%rbx)
callq 0x6eed
cmpl $0x27, %eax
je 0x6ec9
leaq 0x3fbd(%rip), %rdi      # 0xa80d
callq 0x6515
jmp 0x6ec9
callq 0x6eed
cmpl $0x3d, %eax
jne 0x6a2d
movl $0x4, (%rbx)
jmp 0x6ec9
movl $0x3d, (%rbx)
jmp 0x6ec9
callq 0x6eed
cmpl $0x3d, %eax
je 0x6ba2
cmpl $0x2b, %eax
jne 0x6bad
movl $0x1a, (%rbx)
jmp 0x6ec9
movl $0x39, (%rbx)
jmp 0x6ec9
movl $0x3a, (%rbx)
jmp 0x6ec9
callq 0x6eed
cmpl $0x3d, %eax
jne 0x6a55
movl $0x6, (%rbx)
jmp 0x6ec9
callq 0x6eed
cmpl $0x26, %eax
jne 0x6a69
movl $0x9, (%rbx)
jmp 0x6ec9
callq 0x6eed
cmpl $0x3d, %eax
jne 0x6a7d
movl $0xd, (%rbx)
jmp 0x6ec9
callq 0x6eed
cmpl $0x3e, %eax
je 0x6beb
movl %eax, %r14d
cmpl $0x3d, %eax
je 0x6be0
cmpl $0x2d, %r14d
jne 0x6bf6
movl $0x1b, (%rbx)
jmp 0x6ec9
xorl %r14d, %r14d
leaq 0x7a96(%rip), %r15      # 0xe3d0
cmpq $0x1ff, %r14            # imm = 0x1FF
je 0x6a1f
callq 0x70a8
cmpl $0x22, %eax
je 0x6aa5
movb %al, (%r15,%r14)
incq %r14
jmp 0x693a
movl $0x3e, (%rbx)
jmp 0x6ec9
callq 0x6eed
cmpl $0x3c, %eax
je 0x6bc1
cmpl $0x3d, %eax
jne 0x6bcc
movl $0x11, (%rbx)
jmp 0x6ec9
callq 0x6eed
cmpl $0x3d, %eax
jne 0x6a91
movl $0x5, (%rbx)
jmp 0x6ec9
movl $0x35, (%rbx)
jmp 0x6ec9
movl $0x40, (%rbx)
jmp 0x6ec9
andl $0x0, (%rbx)
xorl %eax, %eax
jmp 0x6ede
movl $0x38, (%rbx)
jmp 0x6ec9
movl $0x3c, (%rbx)
jmp 0x6ec9
movl $0x1c, (%rbx)
jmp 0x6ec9
callq 0x6eed
cmpl $0x7c, %eax
jne 0x6ab5
movl $0x8, (%rbx)
jmp 0x6ec9
movl $0x3b, (%rbx)
jmp 0x6ec9
movl %r14d, %edi
callq 0x7019
movl %eax, 0x10(%rbx)
movl $0x33, (%rbx)
jmp 0x6ec9
leaq 0x3ef7(%rip), %rdi      # 0xa91d
callq 0x6515
jmp 0x6aaa
leaq 0x793c(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0x17, (%rbx)
jmp 0x6ec9
leaq 0x7928(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0x1d, (%rbx)
jmp 0x6ec9
leaq 0x7914(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0x19, (%rbx)
jmp 0x6ec9
leaq 0x7900(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0xc, (%rbx)
jmp 0x6ec9
leaq 0x78ec(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0x1, (%rbx)
jmp 0x6ec9
leaq 0x78d8(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0x18, (%rbx)
jmp 0x6ec9
movb $0x0, (%r15,%r14)
movl $0x34, (%rbx)
jmp 0x6ec9
leaq 0x78b4(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0xa, (%rbx)
jmp 0x6ec9
xorl %r13d, %r13d
leaq 0x3e62(%rip), %r12      # 0xa935
movzwl %ax, %ecx
btl $0xa, %ecx
movslq %r13d, %rax
jb 0x6aed
cmpl $0x5f, %r14d
je 0x6aed
andl $0x800, %ecx            # imm = 0x800
je 0x6b2a
cmpl $0x1ff, %r13d           # imm = 0x1FF
jne 0x6b06
movq %r12, %rdi
callq 0x6515
movl $0x1ff, %r13d           # imm = 0x1FF
jmp 0x6b16
jge 0x6b16
incl %r13d
leaq 0x78be(%rip), %rcx      # 0xe3d0
movb %r14b, (%rcx,%rax)
callq 0x6eed
movl %eax, %r14d
movq (%r15), %rax
movslq %r14d, %rcx
movzwl (%rax,%rcx,2), %eax
jmp 0x6ad3
leaq 0x783f(%rip), %rcx      # 0xe370
movl %r14d, (%rcx)
leaq 0x7895(%rip), %rcx      # 0xe3d0
movb $0x0, (%rcx,%rax)
movzbl (%rcx), %eax
addl $-0x62, %eax
cmpl $0x15, %eax
ja 0x6e9c
leaq 0x3ba7(%rip), %rcx      # 0xa6fc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x786b(%rip), %rdi      # 0xe3d0
leaq 0x3c78(%rip), %rsi      # 0xa7e4
pushq $0x6
popq %rdx
callq 0x2130
testl %eax, %eax
jne 0x6e9c
pushq $0x2c
jmp 0x6ec6
movl $0x14, (%rbx)
jmp 0x6ec9
leaq 0x77db(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0x10, (%rbx)
jmp 0x6ec9
movl $0x2, (%rbx)
jmp 0x6ec9
leaq 0x77bc(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0x15, (%rbx)
jmp 0x6ec9
movl $0x13, (%rbx)
jmp 0x6ec9
leaq 0x779d(%rip), %rcx      # 0xe370
movl %eax, (%rcx)
movl $0xf, (%rbx)
jmp 0x6ec9
movl $0x3, (%rbx)
jmp 0x6ec9
movl $0x3f, (%rbx)
jmp 0x6ec9
callq 0x21b0
movq (%rax), %rax
movslq %r14d, %rcx
testb $0x8, 0x1(%rax,%rcx,2)
jne 0x6c1d
leaq 0x7761(%rip), %rax      # 0xe370
movl %r14d, (%rax)
movl $0x16, (%rbx)
jmp 0x6ec9
movl %r14d, %edi
callq 0x7019
negl %eax
jmp 0x6a11
leaq 0x779d(%rip), %rdi      # 0xe3d0
leaq 0x3ff5(%rip), %rsi      # 0xac2f
pushq $0x6
popq %rdx
callq 0x2130
testl %eax, %eax
jne 0x6e9c
pushq $0x28
jmp 0x6ec6
leaq 0x7778(%rip), %rax      # 0xe3d0
cmpl $0x726f66, (%rax)       # imm = 0x726F66
jne 0x6e9c
pushq $0x25
jmp 0x6ec6
leaq 0x775e(%rip), %rdi      # 0xe3d0
leaq 0x3b5c(%rip), %rsi      # 0xa7d5
pushq $0x6
popq %rdx
callq 0x2130
testl %eax, %eax
jne 0x6e9c
pushq $0x24
jmp 0x6ec6
leaq 0x7739(%rip), %r14      # 0xe3d0
leaq 0x3b2f(%rip), %rsi      # 0xa7cd
pushq $0x3
popq %rdx
movq %r14, %rdi
callq 0x2130
testl %eax, %eax
je 0x6ea4
cmpl $0x746e69, (%r14)       # imm = 0x746E69
jne 0x6e9c
pushq $0x20
jmp 0x6ec6
leaq 0x7704(%rip), %rdi      # 0xe3d0
leaq 0x3aec(%rip), %rsi      # 0xa7bf
pushq $0x5
popq %rdx
callq 0x2130
testl %eax, %eax
jne 0x6e9c
pushq $0x1e
jmp 0x6ec6
leaq 0x76df(%rip), %rdi      # 0xe3d0
leaq 0x3ad8(%rip), %rsi      # 0xa7d0
pushq $0x5
popq %rdx
callq 0x2130
testl %eax, %eax
je 0x6ea8
leaq 0x76c1(%rip), %rdi      # 0xe3d0
leaq 0x3ac9(%rip), %rsi      # 0xa7df
pushq $0x5
popq %rdx
callq 0x2130
testl %eax, %eax
je 0x6eb4
leaq 0x76a3(%rip), %rdi      # 0xe3d0
leaq 0x3ee0(%rip), %rsi      # 0xac14
pushq $0x7
popq %rdx
callq 0x2130
testl %eax, %eax
jne 0x6e9c
pushq $0x2b
jmp 0x6ec6
movabsq $0x746c7561666564, %rax # imm = 0x746C7561666564
leaq 0x7674(%rip), %rcx      # 0xe3d0
cmpq %rax, (%rcx)
jne 0x6e9c
pushq $0x30
jmp 0x6ec6
leaq 0x765d(%rip), %rdi      # 0xe3d0
leaq 0x3a79(%rip), %rsi      # 0xa7f3
pushq $0x5
popq %rdx
callq 0x2130
testl %eax, %eax
je 0x6eac
leaq 0x763f(%rip), %rdi      # 0xe3d0
leaq 0x3a2c(%rip), %rsi      # 0xa7c4
pushq $0x5
popq %rdx
callq 0x2130
testl %eax, %eax
je 0x6eb8
leaq 0x7621(%rip), %rdi      # 0xe3d0
leaq 0x3a34(%rip), %rsi      # 0xa7ea
pushq $0x9
popq %rdx
callq 0x2130
testl %eax, %eax
jne 0x6e9c
pushq $0x2d
jmp 0x6ec6
leaq 0x75fc(%rip), %rdi      # 0xe3d0
leaq 0x3b55(%rip), %rsi      # 0xa930
pushq $0x5
popq %rdx
callq 0x2130
testl %eax, %eax
jne 0x6e9c
pushq $0x21
jmp 0x6ec6
leaq 0x75d7(%rip), %rdi      # 0xe3d0
leaq 0x3be7(%rip), %rsi      # 0xa9e7
pushq $0x7
popq %rdx
callq 0x2130
testl %eax, %eax
jne 0x6e9c
pushq $0x26
jmp 0x6ec6
movabsq $0x66656465707974, %rax # imm = 0x66656465707974
leaq 0x75a8(%rip), %rcx      # 0xe3d0
cmpq %rax, (%rcx)
jne 0x6e9c
pushq $0x2a
jmp 0x6ec6
leaq 0x7595(%rip), %rdi      # 0xe3d0
leaq 0x31d9(%rip), %rsi      # 0xa01b
pushq $0x7
popq %rdx
callq 0x2130
testl %eax, %eax
je 0x6eb0
leaq 0x757b(%rip), %rdi      # 0xe3d0
leaq 0x3dc1(%rip), %rsi      # 0xac1d
pushq $0x7
popq %rdx
callq 0x2130
testl %eax, %eax
je 0x6ebc
leaq 0x7561(%rip), %rdi      # 0xe3d0
leaq 0x3db0(%rip), %rsi      # 0xac26
pushq $0x7
popq %rdx
callq 0x2130
testl %eax, %eax
je 0x6ec0
leaq 0x7547(%rip), %rdi      # 0xe3d0
leaq 0x3c4e(%rip), %rsi      # 0xaade
pushq $0x7
popq %rdx
callq 0x2130
testl %eax, %eax
je 0x6ec4
movl $0x36, (%rbx)
jmp 0x6ec9
pushq $0x22
jmp 0x6ec6
pushq $0x23
jmp 0x6ec6
pushq $0x2f
jmp 0x6ec6
pushq $0x31
jmp 0x6ec6
pushq $0x29
jmp 0x6ec6
pushq $0x1f
jmp 0x6ec6
pushq $0x32
jmp 0x6ec6
pushq $0x27
jmp 0x6ec6
pushq $0x2e
popq %rax
movl %eax, (%rbx)
movslq (%rbx), %rax
leaq 0x722d(%rip), %rcx      # 0xe100
movq (%rcx,%rax,8), %rax
movq %rax, 0x8(%rbx)
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq