// File: waltersharpWEI[P]CommentEliminator/main.cpp
// Function: removeComment(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void removeComment(string FilePath) {
    //FILE handle of the input file, read-only
    FILE * Input = fopen(FilePath.c_str(),"r");
    //If fail to open the file, show the message and leave funtion
    if (Input == NULL) {
        cout << "Can not open this file, path:"  << FilePath << "\n";
        return ;
    }
    //This Buffer is used to store the content of entire output file
    //Initialized as empty string
    string Buffer = "";
    //Previous is the last character readed
    //Now is the current character from input file
    char Previous = 0,Now = 0,PoP = 0;
    //0 for code, 1 for string, 2 for one line comment, 3 for multiline comment
    //The
    int Status = 0;
    int es = 0;
    //keep read the input stream until End of File
    //one character each time
    while (fscanf(Input, "%c",&Now) != EOF) {
        switch (Status) {
            //if cursor is in the normal code area
            case 0:{
                if (Previous == '/') {
                    if (Now == '/') {
                        Status = 2;
                    } else if (Now == '*') {
                        Status = 3;
                    } else {
                        Buffer += Previous;
                        Buffer += Now;
                    }
                } else if (Now != '/') {
                    Buffer += Now;
                    if (Previous != '\\' && Previous != '\'' && Now == '"') {
                        Status = 1;
                    }
                }
            }break;
            //if cursor is in a string
            case 1:{
                //if there is a single \ to continue the line, just put it into Buffer,
                //together with the \r or \n in Now
                if (Previous == '\\') {
                    if (es != 1) {
                        Buffer += Previous;
                        Buffer += Now;
                        es = 0;
                    } else {
                        Buffer += Now;
                        if (Now == '"') {
                            Status = 0;
                        }
                        es = 0;
                    }
                    if (Now == '\\') {
                        es = 1;
                    }
                //otherwise just add Now to Buffer
                } else if (Now != '\\') {
                    Buffer += Now;
                    if (Now == '"') {
                        Status = 0;

                    }
                }
            }break;
            //if cursor is in a single line comment
            case 2:{
                //if there is no single \ to continue the line, then stop single lien comment, add /n into Buffer
                if (Previous != '\\' && (Now == '\n' || Now == '\r')) {
                    Buffer += Now;
                    Now = 0;
                    Status = 0;
                }
            }break;
            //if cursor is in a multiple line comment
            case 3:{
                if (Previous == '*' && Now == '/') {
                    Status = 0;
                    Now = 0;
                }
            }break;
            default: {

            }break;
        }
        //update the Previous character, move forward to next character
        PoP = Previous;
        Previous = Now;
    }
    //close the input file
    fclose(Input);
    //open the input file in write mode
    ofstream fout(FilePath.c_str());
    //write the Buffer content into the file
    fout << Buffer;
    //close the file
    fout.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x258(%rbp)
movq %rdi, -0x8(%rbp)
callq 0x20d0
movq %rax, %rdi
leaq 0x6a4f(%rip), %rsi      # 0x9014
callq 0x22a0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x260b
movq 0xb9ec(%rip), %rdi      # 0xdfc8
leaq 0x6a33(%rip), %rsi      # 0x9016
callq 0x2200
movq -0x258(%rbp), %rsi
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
leaq 0x6c23(%rip), %rsi      # 0x9224
callq 0x2200
jmp 0x28d5
leaq -0x31(%rbp), %rdi
movq %rdi, -0x260(%rbp)
callq 0x23d0
movq -0x260(%rbp), %rdx
leaq 0x6bfc(%rip), %rsi      # 0x9225
leaq -0x30(%rbp), %rdi
callq 0x3f80
jmp 0x2634
leaq -0x31(%rbp), %rdi
callq 0x2260
movb $0x0, -0x45(%rbp)
movb $0x0, -0x46(%rbp)
movb $0x0, -0x47(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x69d2(%rip), %rsi      # 0x9034
xorl %eax, %eax
leaq -0x46(%rbp), %rdx
callq 0x2400
movl %eax, -0x264(%rbp)
jmp 0x2675
movl -0x264(%rbp), %eax
cmpl $-0x1, %eax
je 0x2873
movl -0x4c(%rbp), %eax
movq %rax, -0x270(%rbp)
subq $0x3, %rax
ja 0x2860
movq -0x270(%rbp), %rax
leaq 0x695e(%rip), %rcx      # 0x9004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x2260
jmp 0x28ff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x28f6
movsbl -0x45(%rbp), %eax
cmpl $0x2f, %eax
jne 0x272b
movsbl -0x46(%rbp), %eax
cmpl $0x2f, %eax
jne 0x26f5
movl $0x2, -0x4c(%rbp)
jmp 0x2729
movsbl -0x46(%rbp), %eax
cmpl $0x2a, %eax
jne 0x2707
movl $0x3, -0x4c(%rbp)
jmp 0x2727
movsbl -0x45(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x2140
jmp 0x2716
movsbl -0x46(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x2140
jmp 0x2725
jmp 0x2727
jmp 0x2729
jmp 0x2769
movsbl -0x46(%rbp), %eax
cmpl $0x2f, %eax
je 0x2767
movsbl -0x46(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x2140
jmp 0x2743
movsbl -0x45(%rbp), %eax
cmpl $0x5c, %eax
je 0x2765
movsbl -0x45(%rbp), %eax
cmpl $0x27, %eax
je 0x2765
movsbl -0x46(%rbp), %eax
cmpl $0x22, %eax
jne 0x2765
movl $0x1, -0x4c(%rbp)
jmp 0x2767
jmp 0x2769
jmp 0x2862
movsbl -0x45(%rbp), %eax
cmpl $0x5c, %eax
jne 0x27dc
cmpl $0x1, -0x50(%rbp)
je 0x27a4
movsbl -0x45(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x2140
jmp 0x278c
movsbl -0x46(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x2140
jmp 0x279b
movl $0x0, -0x50(%rbp)
jmp 0x27ca
movsbl -0x46(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x2140
jmp 0x27b3
movsbl -0x46(%rbp), %eax
cmpl $0x22, %eax
jne 0x27c3
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movsbl -0x46(%rbp), %eax
cmpl $0x5c, %eax
jne 0x27da
movl $0x1, -0x50(%rbp)
jmp 0x2808
movsbl -0x46(%rbp), %eax
cmpl $0x5c, %eax
je 0x2806
movsbl -0x46(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x2140
jmp 0x27f4
movsbl -0x46(%rbp), %eax
cmpl $0x22, %eax
jne 0x2804
movl $0x0, -0x4c(%rbp)
jmp 0x2806
jmp 0x2808
jmp 0x2862
movsbl -0x45(%rbp), %eax
cmpl $0x5c, %eax
je 0x283f
movsbl -0x46(%rbp), %eax
cmpl $0xa, %eax
je 0x2825
movsbl -0x46(%rbp), %eax
cmpl $0xd, %eax
jne 0x283f
movsbl -0x46(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x2140
jmp 0x2834
movb $0x0, -0x46(%rbp)
movl $0x0, -0x4c(%rbp)
jmp 0x2862
movsbl -0x45(%rbp), %eax
cmpl $0x2a, %eax
jne 0x285e
movsbl -0x46(%rbp), %eax
cmpl $0x2f, %eax
jne 0x285e
movl $0x0, -0x4c(%rbp)
movb $0x0, -0x46(%rbp)
jmp 0x2862
jmp 0x2862
movb -0x45(%rbp), %al
movb %al, -0x47(%rbp)
movb -0x46(%rbp), %al
movb %al, -0x45(%rbp)
jmp 0x2657
movq -0x10(%rbp), %rdi
callq 0x2210
jmp 0x287e
movq -0x258(%rbp), %rdi
callq 0x20d0
movq %rax, %rsi
leaq -0x250(%rbp), %rdi
movl $0x10, %edx
callq 0x2270
jmp 0x28a0
leaq -0x250(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x21b0
jmp 0x28b2
leaq -0x250(%rbp), %rdi
callq 0x2300
jmp 0x28c0
leaq -0x250(%rbp), %rdi
callq 0x2330
leaq -0x30(%rbp), %rdi
callq 0x2130
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x250(%rbp), %rdi
callq 0x2330
leaq -0x30(%rbp), %rdi
callq 0x2130
movq -0x40(%rbp), %rdi
callq 0x23c0
nopl (%rax,%rax)