// File: /workspace/github_cpp_makefile_star2_O2/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, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movl %edx, %edi
callq 0x4844
movq %rax, %r14
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
callq 0x2170
movq %r15, 0x8(%rsp)
movq 0x78(%rsp), %rax
movb (%rax), %al
movb %al, 0x7(%rsp)
cmpb $0x2d, %al
jne 0x3437
leaq 0x78(%rsp), %rdi
pushq $0x1
popq %rdx
xorl %esi, %esi
callq 0x2030
pushq $0x3
popq %r12
leaq 0xe8(%rsp), %rbx
pushq $0x30
popq %rbp
leaq 0x78(%rsp), %r15
movq 0x80(%rsp), %rax
xorl %edx, %edx
divq %r12
testq %rdx, %rdx
je 0x347f
movq %rbx, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x3b86
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2150
movq %rbx, %rdi
callq 0x2218
jmp 0x344b
leaq 0xe8(%rsp), %rdi
leaq 0x78(%rsp), %rdx
callq 0x396e
leaq 0x138(%rsp), %r13
leaq 0xe8(%rsp), %r12
leaq 0x98(%rsp), %r15
leaq 0x50(%rsp), %rbp
leaq 0x10(%rsp), %rbx
movq %r14, 0x70(%rsp)
movq 0x118(%rsp), %rsi
cmpq 0xf8(%rsp), %rsi
je 0x3767
cmpq 0x120(%rsp), %rsi
jne 0x34ec
movq 0x130(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
addq $-0x20, %rsi
movq %r13, %rdi
callq 0x2170
movq %r12, %rdi
callq 0x3f04
movq %r15, %rdi
movq %r13, %rdx
callq 0x3aae
movq 0xc8(%rsp), %rsi
cmpq 0xa8(%rsp), %rsi
je 0x3752
cmpq 0xd0(%rsp), %rsi
jne 0x353f
movq 0xe0(%rsp), %rax
movq -0x8(%rax), %rsi
movl $0x200, %eax            # imm = 0x200
addq %rax, %rsi
addq $-0x20, %rsi
movq %rbp, %rdi
callq 0x2170
movq %r15, %rdi
callq 0x3f04
movq 0x50(%rsp), %rax
movb (%rax), %cl
cmpb $0x30, %cl
jne 0x3570
cmpb $0x30, 0x1(%rax)
jne 0x35c1
cmpb $0x30, 0x2(%rax)
jne 0x35c1
jmp 0x3745
jle 0x35c1
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
leaq 0x30(%rsp), %rbp
movq 0x50(%rsp), %rcx
movq %rbp, %rdi
movq %rax, %rdx
callq 0x3b62
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3f64
movq %rbp, %rdi
callq 0x2218
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3be4
movq 0x50(%rsp), %rax
cmpb $0x30, (%rax)
jg 0x35cd
movq 0x18(%rsp), %rcx
cmpq 0x10(%rsp), %rcx
je 0x35f2
cmpb $0x30, 0x1(%rax)
jg 0x35d9
cmpb $0x31, 0x2(%rax)
jl 0x35f2
movq (%r14), %rax
movq %r14, %rdi
callq *0x38(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3be4
movq 0x50(%rsp), %rax
movb 0x1(%rax), %cl
cmpb $0x30, %cl
leaq 0x30(%rsp), %rbp
je 0x363c
cmpb $0x32, %cl
jl 0x369b
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movq 0x50(%rsp), %rcx
incq %rcx
movq %rbp, %rdi
movq %rax, %rdx
callq 0x3b62
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3f64
movq %rbp, %rdi
callq 0x2218
movq 0x50(%rsp), %rax
cmpb $0x31, 0x2(%rax)
jl 0x36cb
cmpb $0x30, 0x1(%rax)
jne 0x366c
movq 0x18(%rsp), %rax
cmpq 0x10(%rsp), %rax
je 0x366c
movq (%r14), %rax
movq %r14, %rdi
callq *0x40(%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3be4
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
leaq 0x30(%rsp), %rbp
movq 0x50(%rsp), %rcx
addq $0x2, %rcx
movq %rbp, %rdi
movq %rax, %rdx
callq 0x3b62
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3f64
jmp 0x36c3
movq (%r14), %rax
movq %r14, %rdi
callq *0x18(%rax)
movq 0x50(%rsp), %rcx
addq $0x2, %rcx
movq %rbp, %rdi
movq %rax, %rdx
callq 0x3b62
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x3f64
movq %rbp, %rdi
callq 0x2218
movq (%r14), %rax
movq %r14, %rdi
callq *0x28(%rax)
movq %rbp, %rdi
movq %rax, %rsi
callq 0x3c10
movq %r15, %rdi
callq 0x42cc
shlq $0x5, %rax
addq 0x30(%rsp), %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3be4
movq %r15, %r14
movq %r13, %r15
xorl %r13d, %r13d
movswq %r13w, %rbp
movq %r12, %rdi
callq 0x42cc
cmpq %rbp, %rax
jbe 0x372b
movq 0x38(%rsp), %rsi
addq $-0x20, %rsi
movq %rbx, %rdi
callq 0x3be4
incl %r13d
jmp 0x3704
leaq 0x30(%rsp), %rdi
callq 0x3c64
movq %r15, %r13
movq %r14, %r15
movq 0x70(%rsp), %r14
leaq 0x50(%rsp), %rbp
movq %rbp, %rdi
callq 0x2218
jmp 0x350b
movq %r15, %rdi
callq 0x3d72
movq %r13, %rdi
callq 0x2218
jmp 0x34b8
cmpb $0x2d, 0x7(%rsp)
jne 0x3793
movq 0x10(%rsp), %rbx
cmpq %rbx, 0x18(%rsp)
je 0x3793
movq (%r14), %rax
movq %r14, %rdi
callq *0x48(%rax)
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x3c86
leaq 0x1883(%rip), %rsi      # 0x501d
leaq 0x98(%rsp), %rdx
movq 0x8(%rsp), %rdi
callq 0x3294
xorl %r12d, %r12d
leaq 0x1854(%rip), %rbx      # 0x500a
leaq 0x98(%rsp), %r15
movswq %r12w, %r12
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r12, %rax
jbe 0x380f
movq %r12, %rax
shlq $0x5, %rax
cmpq $0x0, 0x8(%rsi,%rax)
je 0x380a
addq %rax, %rsi
movq %r15, %rdi
movq %rbx, %rdx
callq 0x3d1e
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2200
movq %r15, %rdi
callq 0x2218
incl %r12d
jmp 0x37be
movq 0x8(%rsp), %r15
movq 0x8(%r15), %rcx
testq %rcx, %rcx
je 0x3854
decq %rcx
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x2130
leaq 0x98(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2150
movq %rbx, %rdi
callq 0x2218
testq %r14, %r14
jne 0x3868
jmp 0x3871
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq (%rax), %rsi
movq %r15, %rdi
callq 0x20a0
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
leaq 0xe8(%rsp), %rdi
callq 0x3d72
leaq 0x78(%rsp), %rdi
callq 0x2218
leaq 0x10(%rsp), %rdi
callq 0x3c64
movq %r15, %rax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x38e3
jmp 0x38cf
jmp 0x38cf
jmp 0x38d9
jmp 0x38d9
jmp 0x38e3
jmp 0x38b5
movq %rax, %rbx
jmp 0x395b
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x2218
jmp 0x38d2
movq %rax, %rbx
movq 0x8(%rsp), %rdi
jmp 0x393f
movq %rax, %rbx
jmp 0x3944
movq %rax, %rbx
jmp 0x3937
movq %rax, %rbx
jmp 0x3951
jmp 0x38ee
jmp 0x38ee
jmp 0x38ee
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2218
jmp 0x3920
jmp 0x390e
jmp 0x390e
jmp 0x390e
jmp 0x390e
jmp 0x3913
movq %rax, %rbx
jmp 0x392a
jmp 0x390e
movq %rax, %rbx
jmp 0x3920
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3c64
leaq 0x50(%rsp), %rdi
callq 0x2218
leaq 0x98(%rsp), %rdi
callq 0x3d72
leaq 0x138(%rsp), %rdi
callq 0x2218
leaq 0xe8(%rsp), %rdi
callq 0x3d72
leaq 0x78(%rsp), %rdi
callq 0x2218
leaq 0x10(%rsp), %rdi
callq 0x3c64
movq %rbx, %rdi
callq 0x21d0
nop