// File: /workspace/github_cpp_makefile_star2_O3/thuydx55[P]C-Number-to-Word/NumberRepresentation/Number.cpp
// Function: Number::getTextRepresentation[abi:cxx11](LanguageType)
string Number::getTextRepresentation(LanguageType type) {
    vector<string> words;
    Language* lang = Language::getLanguage(type);

    string tempNumStr = string(mNumStr);
    bool isNegative = false;

    if (tempNumStr[0] == '-') {
        isNegative = true;
        tempNumStr.erase(0,1);
    }

    while(tempNumStr.size() % 3)
        tempNumStr = '0' + tempNumStr;

    stack<string> bigGroups = divideStringToBigGroup(tempNumStr);
    while(!bigGroups.empty()) {
        string bigGroup = bigGroups.top();
        bigGroups.pop();

        // cout << bigGroup << endl;

        stack<string> groups = divideStringToSmallGroup(bigGroup);

        while(!groups.empty()) {
            string subNumber = groups.top();
            groups.pop();

            // cout << subNumber << endl;

            if (subNumber[0] == '0' && subNumber[1] == '0' && subNumber[2] == '0')
                continue;

            if (subNumber[0] > '0') {
                words.push_back(getElement(lang->getOnes(), subNumber[0]));
                words.push_back(lang->getHundred());
            }

            if ((subNumber[0] > '0' || words.size()) && (subNumber[1] > '0' || subNumber[2] > '0'))
                words.push_back(lang->getConnectiveHundredsAndNext());

            if (subNumber[1] == '0' || subNumber[1] > '1') {
                if (subNumber[1] > '1')
                    words.push_back(getElement(lang->getTens(), subNumber[1]));
                if (subNumber[2] > '0') {
                    if (subNumber[1] == '0' && words.size() > 0)
                        words.push_back(lang->getConnectiveTensAndOnes());
                    words.push_back(getElement(lang->getOnes(), subNumber[2]));
                }
            }
            else {
                words.push_back(getElement(lang->getTeens(), subNumber[2]));
            }
            const vector<string> powers = lang->getPowers();
            words.push_back(powers[groups.size()]);
            for (short i = 0; i < bigGroups.size(); i++) {
                words.push_back(powers[powers.size()-1]);
            }
        }
    }
    if (words.size() && isNegative)
        words.insert(words.begin(), lang->getNegative());
    string result = "";
    for (short i = 0; i < words.size(); ++i)
    {
        if (words[i].length())
            result += words[i] + " ";
    }

    // Remove last space
    if (result.length())
        result = result.substr(0, result.size()-1);
    else
        result = lang->getOnes()[0];

    delete lang;

    return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %rbx
movq %rdi, %r15
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
movl %edx, %edi
callq 0x5494
movq %rax, %r14
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x3724
movq 0x78(%rsp), %rax
movb (%rax), %al
movb %al, 0xf(%rsp)
cmpb $0x2d, %al
jne 0x3962
leaq 0x78(%rsp), %rdi
movl $0x1, %edx
xorl %esi, %esi
callq 0x2040
movq %r15, 0x50(%rsp)
movabsq $-0x5555555555555555, %r12 # imm = 0xAAAAAAAAAAAAAAAB
movq 0x80(%rsp), %rax
imulq %r12, %rax
movabsq $0x5555555555555556, %r13 # imm = 0x5555555555555556
cmpq %r13, %rax
jb 0x39ea
leaq 0x118(%rsp), %rbp
leaq 0x108(%rsp), %rbx
leaq 0x78(%rsp), %r15
movq %rbx, %rdi
movl $0x30, %esi
movq %r15, %rdx
callq 0x44ad
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2160
movq 0x108(%rsp), %rdi
cmpq %rbp, %rdi
je 0x39d9
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x80(%rsp), %rax
imulq %r12, %rax
cmpq %r13, %rax
jae 0x39a1
leaq 0x108(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x4156
movq 0x138(%rsp), %rax
cmpq 0x118(%rsp), %rax
je 0x3e4f
leaq 0x68(%rsp), %r15
leaq 0x20(%rsp), %rbp
leaq 0xe8(%rsp), %r13
leaq 0x30(%rsp), %r12
leaq 0x10(%rsp), %rbx
cmpq 0x140(%rsp), %rax
jne 0x3a4c
movq 0x150(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
leaq 0xf8(%rsp), %rcx
movq %rcx, 0xe8(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x3724
leaq 0x108(%rsp), %rdi
callq 0x4922
leaq 0x98(%rsp), %rdi
movq %r13, %rdx
callq 0x438a
movq 0xc8(%rsp), %rax
cmpq 0xa8(%rsp), %rax
je 0x3dff
cmpq 0xd0(%rsp), %rax
jne 0x3ac0
movq 0xe0(%rsp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq %r15, 0x58(%rsp)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
leaq 0x58(%rsp), %rdi
callq 0x3724
leaq 0x98(%rsp), %rdi
callq 0x4922
movq 0x58(%rsp), %rdi
movb (%rdi), %al
cmpb $0x30, %al
jne 0x3b0b
cmpb $0x30, 0x1(%rdi)
jne 0x3b86
cmpb $0x30, 0x2(%rdi)
jne 0x3b86
jmp 0x3de4
jle 0x3b86
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq 0x58(%rsp), %rcx
movsbq (%rcx), %rcx
movq (%rax), %rax
shlq $0x5, %rcx
movq %rbp, 0x10(%rsp)
movq -0x600(%rax,%rcx), %rsi
movq -0x5f8(%rax,%rcx), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x3724
movq %r12, %rdi
movq %rbx, %rsi
callq 0x49ae
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3b68
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2130
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x452e
movq 0x58(%rsp), %rdi
cmpb $0x30, (%rdi)
jg 0x3b92
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x3bb7
cmpb $0x30, 0x1(%rdi)
jg 0x3b9e
cmpb $0x31, 0x2(%rdi)
jl 0x3bb7
movq (%r14), %rax
movq %r14, %rdi
callq *0x38(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x452e
movq 0x58(%rsp), %rdi
movb 0x1(%rdi), %al
cmpb $0x30, %al
je 0x3c27
cmpb $0x32, %al
jl 0x3c9e
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movq 0x58(%rsp), %rcx
movsbq 0x1(%rcx), %rcx
movq (%rax), %rax
shlq $0x5, %rcx
movq %rbp, 0x10(%rsp)
movq -0x600(%rax,%rcx), %rsi
movq -0x5f8(%rax,%rcx), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x3724
movq %r12, %rdi
movq %rbx, %rsi
callq 0x49ae
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3c22
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x58(%rsp), %rdi
cmpb $0x31, 0x2(%rdi)
jl 0x3cfa
cmpb $0x30, 0x1(%rdi)
jne 0x3c57
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
je 0x3c57
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %r12, %rdi
movq %rax, %rsi
callq 0x452e
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq 0x58(%rsp), %rcx
movsbq 0x2(%rcx), %rcx
movq (%rax), %rax
shlq $0x5, %rcx
movq %rbp, 0x10(%rsp)
movq -0x600(%rax,%rcx), %rsi
movq -0x5f8(%rax,%rcx), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x3724
movq %r12, %rdi
movq %rbx, %rsi
callq 0x49ae
jmp 0x3ce3
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq 0x58(%rsp), %rcx
movsbq 0x2(%rcx), %rcx
movq (%rax), %rax
shlq $0x5, %rcx
movq %rbp, 0x10(%rsp)
movq -0x600(%rax,%rcx), %rsi
movq -0x5f8(%rax,%rcx), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x3724
movq %r12, %rdi
movq %rbx, %rsi
callq 0x49ae
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3cfa
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2130
movq (%r14), %rax
movq %r14, %rdi
callq *0x28(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x456c
movq 0xe0(%rsp), %rax
movq %rax, %rsi
subq 0xc0(%rsp), %rsi
shrq $0x3, %rsi
cmpq $0x1, %rax
adcq $-0x1, %rsi
movq 0xc8(%rsp), %rax
subq 0xd0(%rsp), %rax
movq 0xb8(%rsp), %rcx
subq 0xa8(%rsp), %rcx
addq %rax, %rcx
shlq $0x9, %rsi
addq 0x10(%rsp), %rsi
addq %rcx, %rsi
movq %r12, %rdi
callq 0x452e
xorl %r13d, %r13d
movswq %r13w, %rax
movq 0x150(%rsp), %rcx
movq %rcx, %rdx
subq 0x130(%rsp), %rdx
shrq $0x3, %rdx
cmpq $0x1, %rcx
adcq $-0x1, %rdx
shlq $0x4, %rdx
movq 0x138(%rsp), %rcx
subq 0x140(%rsp), %rcx
movq 0x128(%rsp), %rsi
sarq $0x5, %rcx
subq 0x118(%rsp), %rsi
sarq $0x5, %rsi
addq %rcx, %rsi
addq %rdx, %rsi
cmpq %rax, %rsi
jbe 0x3dd7
movq 0x18(%rsp), %rsi
addq $-0x20, %rsi
movq %r12, %rdi
callq 0x452e
incl %r13d
jmp 0x3d67
movq %rbx, %rdi
callq 0x45f6
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x3a8c
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2130
jmp 0x3a8c
leaq 0x98(%rsp), %rdi
callq 0x472c
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x3e31
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x138(%rsp), %rax
cmpq 0x118(%rsp), %rax
leaq 0xe8(%rsp), %r13
jne 0x3a2e
cmpb $0x2d, 0xf(%rsp)
jne 0x3e7b
movq 0x30(%rsp), %rbx
cmpq %rbx, 0x38(%rsp)
je 0x3e7b
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
leaq 0x30(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4654
movq 0x50(%rsp), %rdi
leaq 0x10(%rdi), %r12
movq %r12, (%rdi)
leaq 0x218f(%rip), %rdx      # 0x601d
movq %rdx, %rsi
callq 0x37ba
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
cmpq %rax, %rcx
je 0x3f52
movw $0x1, %bp
leaq 0xa8(%rsp), %r13
xorl %esi, %esi
leaq 0x98(%rsp), %rbx
leaq 0x2144(%rip), %r15      # 0x600a
shlq $0x5, %rsi
movq 0x8(%rax,%rsi), %rdx
testq %rdx, %rdx
je 0x3f39
addq %rsi, %rax
movq %r13, 0x98(%rsp)
movq (%rax), %rsi
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x3724
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2200
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq 0x50(%rsp), %rdi
callq 0x2060
movq 0x98(%rsp), %rdi
cmpq %r13, %rdi
je 0x3f2f
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movswq %bp, %rsi
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x5, %rdx
incl %ebp
cmpq %rsi, %rdx
ja 0x3ec6
movq 0x50(%rsp), %r15
movq 0x8(%r15), %rcx
testq %rcx, %rcx
je 0x3faf
decq %rcx
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2140
leaq 0x98(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2160
movq (%rbx), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x3fa8
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2130
testq %r14, %r14
jne 0x3fc3
jmp 0x3fcc
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq (%rax), %rsi
movq %r15, %rdi
callq 0x20b0
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
leaq 0x108(%rsp), %rdi
callq 0x472c
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x3ffb
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2130
leaq 0x30(%rsp), %rdi
callq 0x45f6
movq %r15, %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x407e
jmp 0x4032
jmp 0x4032
jmp 0x4071
jmp 0x4071
jmp 0x407e
jmp 0x4028
movq %rax, %rbx
jmp 0x4143
jmp 0x4037
movq %rax, %rbx
jmp 0x4057
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r13, %rdi
je 0x4057
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2130
movq 0x50(%rsp), %rax
movq (%rax), %rdi
cmpq %r12, %rdi
je 0x4114
movq (%r12), %rsi
jmp 0x410c
movq %rax, %rbx
jmp 0x4114
movq %rax, %rbx
jmp 0x40ef
movq %rax, %rbx
jmp 0x4121
jmp 0x408c
jmp 0x408c
jmp 0x408c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %rbp, %rdi
je 0x40cb
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x2130
jmp 0x40cb
jmp 0x40b9
jmp 0x40b9
jmp 0x40b9
jmp 0x40b9
jmp 0x40be
movq %rax, %rbx
jmp 0x40e2
jmp 0x40b9
movq %rax, %rbx
jmp 0x40cb
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x45f6
movq 0x58(%rsp), %rdi
cmpq %r15, %rdi
je 0x40e2
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2130
leaq 0x98(%rsp), %rdi
callq 0x472c
movq 0xe8(%rsp), %rdi
leaq 0xf8(%rsp), %rax
cmpq %rax, %rdi
je 0x4114
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x2130
leaq 0x108(%rsp), %rdi
callq 0x472c
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x4143
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2130
leaq 0x30(%rsp), %rdi
callq 0x45f6
movq %rbx, %rdi
callq 0x21d0
nop