// File: /workspace/github_c_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x1(%rdi), %r14
movsbq -0x1(%r14), %r12
cmpq $0x9, %r12
je 0xc3d9
movzbl %r12b, %r13d
cmpl $0x20, %r13d
jne 0xc3de
incq %r14
jmp 0xc3c4
testl %r13d, %r13d
jne 0xc426
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)
movl $0x1, %eax
jmp 0xc4c2
leal 0x1(%r12), %eax
cmpb $-0x5f, %al
ja 0xc446
leaq -0x1(%r14), %rbp
leal 0x7f(%r12), %ecx
cmpb $0x1e, %cl
ja 0xc4d1
movb %al, (%rbp)
jmp 0xc449
movl %r12d, %eax
leaq 0x1(%r15), %rcx
movb %al, -0x1(%rcx)
movb (%r14), %dl
leal 0x7f(%rdx), %eax
cmpb $0x1e, %al
ja 0xc45f
incb %dl
movb %dl, (%r14)
leal 0x1(%rdx), %eax
cmpb $-0x5e, %al
jae 0xc473
addb $0x7f, %dl
cmpb $0x1e, %dl
ja 0xc47d
movb %al, (%r14)
jmp 0xc475
movl %edx, %eax
incq %r14
incq %rcx
jmp 0xc44d
movw $0x49, 0x4(%r15)
movl $0x4a4e414b, (%r15)     # imm = 0x4A4E414B
movb $0x0, (%rcx)
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 %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x11d0
movq (%rax), %rcx
movzwl (%rcx,%r12,2), %ecx
btl $0xa, %ecx
jb 0xc550
cmpb $0x30, %r12b
jne 0xc58a
movb $0x30, (%r15)
movzbl (%r14), %edx
movl %edx, %ecx
orl $0x20, %ecx
cmpl $0x78, %ecx
jne 0xc619
incq %r14
addq $0x2, %r15
movq %r15, %rcx
movb %dl, -0x1(%rcx)
movq (%rax), %rdi
movsbq (%r14), %rdx
movzbl %dl, %esi
movzwl (%rdi,%rdx,2), %edi
btl $0xb, %edi
jb 0xc540
leal -0x61(%rsi), %edi
cmpl $0x6, %edi
jb 0xc548
cmpl $0x2e, %esi
je 0xc548
leal -0x47(%rdx), %esi
cmpb $-0x6, %sil
jae 0xc548
jmp 0xc48b
testl %esi, %esi
je 0xc48b
incq %r14
incq %rcx
jmp 0xc50e
movq %rbp, %r14
movq %r15, %rcx
movb %r12b, (%rcx)
incq %rcx
movq (%rax), %rsi
movsbq 0x1(%r14), %r12
incq %r14
cmpq $0x5f, %r12
setne %dl
testb $0x8, (%rsi,%r12,2)
sete %sil
testq %r12, %r12
je 0xc48b
andb %sil, %dl
je 0xc556
jmp 0xc48b
btl $0xb, %ecx
jb 0xc5de
cmpl $0x3b, %r13d
jg 0xc66c
addl $-0x21, %r13d
cmpl $0xe, %r13d
ja 0xc7e0
leaq 0x3c6d(%rip), %rcx      # 0x1021c
movslq (%rcx,%r13,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
incq %r15
movq %r15, %rcx
movl %r12d, %eax
movb %al, -0x1(%rcx)
movb (%r14), %al
incq %r14
incq %rcx
cmpb %r12b, %al
je 0xc5d6
testb %al, %al
jne 0xc5c1
movb %al, -0x1(%rcx)
jmp 0xc48b
movq %rbp, %r14
movq %r15, %rcx
movb %r12b, (%rcx)
incq %rcx
movq (%rax), %rsi
movsbq 0x1(%r14), %r12
incq %r14
cmpq $0x2e, %r12
setne %dl
testb $0x8, 0x1(%rsi,%r12,2)
sete %sil
testq %r12, %r12
je 0xc48b
andb %sil, %dl
je 0xc5e4
jmp 0xc48b
incq %r15
movsbq %dl, %rcx
movq (%rax), %rsi
testb $0x8, 0x1(%rsi,%rcx,2)
jne 0xc68b
cmpb $0x2e, %dl
jne 0xc7e6
movb $0x2e, %dl
movq %r15, %rcx
movb %dl, (%rcx)
incq %rcx
movq (%rax), %rdi
movsbq 0x1(%r14), %rdx
incq %r14
cmpq $0x2e, %rdx
setne %sil
testb $0x8, 0x1(%rdi,%rdx,2)
sete %dil
testq %rdx, %rdx
je 0xc48b
andb %dil, %sil
je 0xc638
jmp 0xc48b
cmpl $0x3d, %r13d
jg 0xc6c2
cmpl $0x3c, %r13d
je 0xc6d2
cmpl $0x3d, %r13d
jne 0xc7e0
movb $0x3d, (%r15)
jmp 0xc7b1
movq %r15, %rcx
movb %dl, (%rcx)
incq %rcx
movq (%rax), %rdi
movsbq 0x1(%r14), %rdx
incq %r14
cmpq $0x2e, %rdx
setne %sil
testb $0x8, 0x1(%rdi,%rdx,2)
sete %dil
testq %rdx, %rdx
je 0xc48b
andb %dil, %sil
je 0xc68e
jmp 0xc48b
cmpl $0x3e, %r13d
je 0xc6d2
cmpl $0x7c, %r13d
jne 0xc7e0
movb %r12b, (%r15)
movb (%r14), %al
cmpb %r12b, %al
setne %cl
cmpb $0x3d, %al
setne %dl
testb %dl, %cl
jne 0xc7e3
incq %r14
movb %al, 0x1(%r15)
jmp 0xc7da
leaq 0x1(%r15), %rcx
movb $0x2f, (%r15)
movzbl (%r14), %eax
cmpq $0x3d, %rax
ja 0xc48b
movabsq $0x2000840000000000, %rdx # imm = 0x2000840000000000
jmp 0xc739
leaq 0x1(%r15), %rcx
movb $0x2d, (%r15)
movzbl (%r14), %eax
cmpq $0x3e, %rax
ja 0xc48b
movabsq $0x6000200000000000, %rdx # imm = 0x6000200000000000
btq %rax, %rdx
jae 0xc48b
incq %r14
movb %al, 0x1(%r15)
jmp 0xc7da
leaq 0x1(%r15), %rcx
movb $0x2a, (%r15)
movzbl (%r14), %edx
cmpq $0x3d, %rdx
ja 0xc783
movabsq $0x2000840000000000, %rsi # imm = 0x2000840000000000
btq %rdx, %rsi
jae 0xc783
incq %r14
movb %dl, 0x1(%r15)
jmp 0xc7da
andb %dil, %sil
jne 0xc48b
movb %dl, (%rcx)
incq %rcx
movq (%rax), %rdi
movsbq 0x1(%r14), %rdx
incq %r14
cmpq $0x5f, %rdx
setne %sil
testb $0x8, (%rdi,%rdx,2)
sete %dil
testq %rdx, %rdx
jne 0xc77a
jmp 0xc48b
movb $0x21, (%r15)
cmpb $0x3d, (%r14)
jne 0xc7e3
incq %r14
movb $0x3d, 0x1(%r15)
jmp 0xc7da
movb $0x2b, (%r15)
movzbl (%r14), %eax
cmpl $0x2b, %eax
je 0xc7d3
cmpl $0x3d, %eax
jne 0xc7e3
incq %r14
movb %al, 0x1(%r15)
addq $0x2, %r15
jmp 0xc7e6
movb %r12b, (%r15)
incq %r15
movq %r15, %rcx
jmp 0xc48b