// File: /workspace/github_c_makefile_star2_O2/aquaxis[P]synverll/src/token.c
// Function: get_token
int get_token(char *line, char *token)
{
    char *p,*ptk,str;
    char *pp;

    // ポインタの初期化
    p   = line;
    ptk = token;

    // 空白かタブの場合、読み飛ばす
    while(*p == ' ' || *p == '\t') ++p;
    // バッファが空の場合は終了する
    if(*p == '\0'){
		pp = malloc(strlen(p)+1);	// 残りの文字列をlineに戻す
		strcpy(pp,p);
		strcpy(line,pp);
		free(pp);
        token[0] = '\0';
        return 1;
    }

    if(iskanji(p)){                // 漢字の判定
        do{
            *ptk++ = *p++;          // 1バイト目
            if(!iskanji(p)){       // 2バイト目
                //printf("can't decode 2Byte Character(KANJI).\n");
                //exit(1);
            }
            //*ptk++ = *p++;
        }while(iskanji(p) && *p != '\0');
        strcpy(token, "KANJI");     // 漢字を検出した場合はポインタを戻して、NULL文字とする
    }else if(isalpha(*p)){          // 1文字目は英字、2文字目以降は英数字
        do{
            *ptk++ = *p++;
        }while((isalnum(*p) || *p == '_') && *p !='\0');    // 2文字目以降は英数字、又は"_"である
    }else if(*p == '0'){                                    // 数字(0で始まる数字)
        *ptk++ = *p++;
        if(*p == 'x' || *p == 'X'){
            do{
                *ptk++ = *p++;
            }while((isdigit(*p) || *p =='.' ||
                            (*p >= 'a' && *p <= 'f') ||
                            (*p >= 'A' && *p <= 'F')) && *p !='\0');
        }else if(isdigit(*p)){
            do{
                *ptk++ = *p++;
            }while((isdigit(*p) || *p =='.') && *p !='\0');
        }else if(*p == '.'){	// 小数点以下の数値
            do{
                *ptk++ = *p++;
            }while((isdigit(*p) || *p =='.') && *p !='\0');
        }
    }else if(isdigit(*p)){      // 数字(0以外で始まる数字)
        do{
            *ptk++ = *p++;
        }while((isdigit(*p) || *p =='.') && *p !='\0');
    }else if(*p == '\'' || *p == '"'){  // 文字・文字列定数: ', ", '', "",
        str = *p;
        do{
            *ptk++ = *p++;
        }while(*p != str && *p !='\0');
        *ptk++ = *p++;
    }else if(*p == '*'){    // 乗算、コメント: *, *=, **, */
        str = *p;
        *ptk++ = *p++;
        if(*p == str || *p == '/' || *p == '='){
            *ptk++ = *p++;
        }else{
			// ポインター
			do{
				*ptk++ = *p++;
			}while((isalnum(*p) || *p == '_') && *p !='\0');    // 2文字目以降は英数字、又は"_"である
		}
    }else if(*p == '+'){    // 加算: +, ++, +=
        str = *p;
        *ptk++ = *p++;
        if(*p == str || *p == '='){
            *ptk++ = *p++;
        }
    }else if(*p == '-'){    // 減算: -, --, ->, -=
        str = *p;
        *ptk++ = *p++;
        if(*p == str || *p == '>' || *p == '='){
            *ptk++ = *p++;
        }
    }else if(*p == '/'){    // 除算、コメント: /, /=, //, /*
        str = *p;
        *ptk++ = *p++;
        if(*p == str || *p == '*' || *p == '='){
            *ptk++ = *p++;
        }
    }else if(*p == '&' || *p == '|'){   // 論理演算子: &, |, &&, ||, &=, |=
        str = *p;
        *ptk++ = *p++;
        if(*p == str || *p == '='){
            *ptk++ = *p++;
        }
    }else if(*p == '>' || *p == '<'){   // 比較、シフト: >, <, >>, <<, >=, <=
        str = *p;
        *ptk++ = *p++;
        if(*p == str || *p == '='){
            *ptk++ = *p++;
        }
    }else if(*p == '!'){    // 等しくない: !, !=
        str = *p;
        *ptk++ = *p++;
        if(*p == '='){
            *ptk++ = *p++;
        }
    }else if(*p == '='){    // 等しい: =, ==
        str = *p;
        *ptk++ = *p++;
        if(*p == str){
            *ptk++ = *p++;
        }
    }else{    // その他の文字
		*ptk++ = *p++;
	}
    *ptk = '\0';            // 文字の終端
    pp = malloc(strlen(p)+1);	// 残りの文字列をlineに戻す
    strcpy(pp,p);
    strcpy(line,pp);
    free(pp);
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x1(%rdi), %r14
movzbl -0x1(%r14), %eax
cmpl $0x9, %eax
je 0xbe23
cmpl $0x20, %eax
jne 0xbe28
incq %r14
jmp 0xbe14
testl %eax, %eax
jne 0xbe6d
decq %r14
movq %r14, %rdi
callq 0x1090
leaq 0x1(%rax), %rdi
callq 0x1130
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x1060
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1060
movq %r12, %rdi
callq 0x1030
movb $0x0, (%r15)
pushq $0x1
popq %rax
jmp 0xbf00
leaq -0x1(%r14), %r12
movq %r12, %rdi
callq 0xbdc0
testl %eax, %eax
je 0xbf0c
movb (%r12), %al
leaq 0x1(%r15), %rcx
movq %r14, %rdx
movq %rdx, %r14
movq %rcx, %r12
movb %al, -0x1(%rcx)
movq %rdx, %rdi
callq 0xbdc0
movq %r14, %rdi
callq 0xbdc0
testl %eax, %eax
je 0xbeb9
movb (%r14), %al
leaq 0x1(%r14), %rdx
leaq 0x1(%r12), %rcx
testb %al, %al
jne 0xbe8c
movw $0x49, 0x4(%r15)
movl $0x4a4e414b, (%r15)     # imm = 0x4A4E414B
movb $0x0, (%r12)
movq %r14, %rdi
callq 0x1090
leaq 0x1(%rax), %rdi
callq 0x1130
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x1060
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1060
movq %r15, %rdi
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
callq 0x11d0
movq (%rax), %rdx
movsbq (%r12), %rcx
movzwl (%rdx,%rcx,2), %edx
btl $0xa, %edx
jb 0xbf9b
cmpb $0x30, %cl
jne 0xbfd5
movb $0x30, (%r15)
movzbl (%r14), %ecx
movl %ecx, %edx
orl $0x20, %edx
cmpl $0x78, %edx
jne 0xc05d
incq %r14
addq $0x2, %r15
movabsq $0x1f8000000000001, %rdx # imm = 0x1F8000000000001
movq %r15, %r12
movb %cl, -0x1(%r12)
movq (%rax), %rdi
movsbq (%r14), %rcx
movzbl %cl, %esi
movzwl (%rdi,%rcx,2), %edi
btl $0xb, %edi
jb 0xbf8b
addl $-0x2e, %esi
cmpl $0x38, %esi
ja 0xbf7d
btq %rsi, %rdx
jb 0xbf93
leal -0x47(%rcx), %esi
cmpb $-0x6, %sil
jae 0xbf93
jmp 0xbec7
testl %esi, %esi
je 0xbec7
incq %r14
incq %r12
jmp 0xbf56
movq %r12, %r14
movq %r15, %r12
movb %cl, (%r12)
incq %r12
movq (%rax), %rsi
movsbq 0x1(%r14), %rcx
incq %r14
cmpq $0x5f, %rcx
setne %dl
testb $0x8, (%rsi,%rcx,2)
sete %sil
testq %rcx, %rcx
je 0xbec7
andb %sil, %dl
je 0xbfa1
jmp 0xbec7
btl $0xb, %edx
jb 0xc022
movzbl %cl, %edx
leal -0x21(%rdx), %esi
cmpl $0xe, %esi
ja 0xc0b1
leaq 0x320b(%rip), %rdx      # 0xf1fc
movslq (%rdx,%rsi,4), %rsi
addq %rdx, %rsi
jmpq *%rsi
incq %r15
movq %r15, %r12
movl %ecx, %eax
movb %al, -0x1(%r12)
movb (%r14), %al
incq %r14
incq %r12
cmpb %cl, %al
je 0xc018
testb %al, %al
jne 0xc002
movb %al, -0x1(%r12)
jmp 0xbec7
movq %r12, %r14
movq %r15, %r12
movb %cl, (%r12)
incq %r12
movq (%rax), %rsi
movsbq 0x1(%r14), %rcx
incq %r14
cmpq $0x2e, %rcx
setne %dl
testb $0x8, 0x1(%rsi,%rcx,2)
sete %sil
testq %rcx, %rcx
je 0xbec7
andb %sil, %dl
je 0xc028
jmp 0xbec7
incq %r15
movsbq %cl, %rdx
movq (%rax), %rsi
testb $0x8, 0x1(%rsi,%rdx,2)
jne 0xc0ed
cmpb $0x2e, %cl
jne 0xc227
movb $0x2e, %cl
movq %r15, %r12
movb %cl, (%r12)
incq %r12
movq (%rax), %rsi
movsbq 0x1(%r14), %rcx
incq %r14
cmpq $0x2e, %rcx
setne %dl
testb $0x8, 0x1(%rsi,%rcx,2)
sete %sil
testq %rcx, %rcx
je 0xbec7
andb %sil, %dl
je 0xc07c
jmp 0xbec7
cmpl $0x3c, %edx
je 0xc0c9
cmpl $0x3d, %edx
je 0xc20c
cmpl $0x3e, %edx
je 0xc0c9
cmpl $0x7c, %edx
jne 0xc125
movb %cl, (%r15)
movb (%r14), %al
cmpb %cl, %al
setne %cl
cmpb $0x3d, %al
setne %dl
testb %dl, %cl
jne 0xc224
incq %r14
movb %al, 0x1(%r15)
jmp 0xc21e
movq %r15, %r12
movb %cl, (%r12)
incq %r12
movq (%rax), %rsi
movsbq 0x1(%r14), %rcx
incq %r14
cmpq $0x2e, %rcx
setne %dl
testb $0x8, 0x1(%rsi,%rcx,2)
sete %sil
testq %rcx, %rcx
je 0xbec7
andb %sil, %dl
je 0xc0f0
jmp 0xbec7
movb %cl, (%r15)
jmp 0xc224
movb $0x2b, (%r15)
movzbl (%r14), %eax
cmpl $0x2b, %eax
je 0xc143
cmpl $0x3d, %eax
jne 0xc224
incq %r14
movb %al, 0x1(%r15)
jmp 0xc21e
leaq 0x1(%r15), %r12
movb $0x2a, (%r15)
movzbl (%r14), %ecx
cmpq $0x3d, %rcx
ja 0xc186
movabsq $0x2000840000000000, %rdx # imm = 0x2000840000000000
btq %rcx, %rdx
jae 0xc186
incq %r14
movb %cl, 0x1(%r15)
jmp 0xc21e
andb %sil, %dl
jne 0xbec7
movb %cl, (%r12)
incq %r12
movq (%rax), %rsi
movsbq 0x1(%r14), %rcx
incq %r14
cmpq $0x5f, %rcx
setne %dl
testb $0x8, (%rsi,%rcx,2)
sete %sil
testq %rcx, %rcx
jne 0xc17d
jmp 0xbec7
leaq 0x1(%r15), %r12
movb $0x2d, (%r15)
movzbl (%r14), %eax
cmpq $0x3e, %rax
ja 0xbec7
movabsq $0x6000200000000000, %rcx # imm = 0x6000200000000000
jmp 0xc1f9
movb $0x21, (%r15)
jmp 0xc210
leaq 0x1(%r15), %r12
movb $0x2f, (%r15)
movzbl (%r14), %eax
cmpq $0x3d, %rax
ja 0xbec7
movabsq $0x2000840000000000, %rcx # imm = 0x2000840000000000
btq %rax, %rcx
jae 0xbec7
incq %r14
movb %al, 0x1(%r15)
jmp 0xc21e
movb $0x3d, (%r15)
cmpb $0x3d, (%r14)
jne 0xc224
incq %r14
movb $0x3d, 0x1(%r15)
addq $0x2, %r15
jmp 0xc227
incq %r15
movq %r15, %r12
jmp 0xbec7