// File: 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
movq %rsp, %rbp
subq $0x3d0, %rsp            # imm = 0x3D0
movq %rdi, -0x298(%rbp)
movq %rdi, %rax
movq %rax, -0x290(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x7b70
movl -0x14(%rbp), %edi
callq 0xaf70
movq %rax, -0x280(%rbp)
jmp 0x6c1c
movq -0x288(%rbp), %rsi
movq -0x280(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x30a0
jmp 0x6c39
movb $0x0, -0x69(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x68(%rbp), %rdi
callq 0x3330
movq %rax, -0x2a0(%rbp)
jmp 0x6c53
movq -0x2a0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x6c9e
movb $0x1, -0x69(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x68(%rbp), %rdi
movl $0x1, %edx
callq 0x3050
jmp 0x6c7a
jmp 0x6c9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x7782
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x7779
jmp 0x6ca0
leaq -0x68(%rbp), %rdi
callq 0x3110
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
je 0x6cee
leaq -0x90(%rbp), %rdi
movl $0x30, %esi
leaq -0x68(%rbp), %rdx
callq 0x7b90
jmp 0x6cd0
leaq -0x68(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x3220
leaq -0x90(%rbp), %rdi
callq 0x3348
jmp 0x6ca0
movq -0x288(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x77a0
jmp 0x6d07
jmp 0x6d09
leaq -0xe0(%rbp), %rdi
callq 0x7c90
movb %al, -0x2a1(%rbp)
jmp 0x6d1d
movb -0x2a1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x6d2e
jmp 0x7493
leaq -0xe0(%rbp), %rdi
callq 0x7cb0
movq %rax, -0x2b0(%rbp)
jmp 0x6d43
movq -0x2b0(%rbp), %rsi
leaq -0x100(%rbp), %rdi
callq 0x30a0
jmp 0x6d58
leaq -0xe0(%rbp), %rdi
callq 0x7cd0
jmp 0x6d66
movq -0x288(%rbp), %rsi
leaq -0x150(%rbp), %rdi
leaq -0x100(%rbp), %rdx
callq 0x79d0
jmp 0x6d82
jmp 0x6d84
leaq -0x150(%rbp), %rdi
callq 0x7c90
movb %al, -0x2b1(%rbp)
jmp 0x6d98
movb -0x2b1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x6da9
jmp 0x7459
leaq -0x150(%rbp), %rdi
callq 0x7cb0
movq %rax, -0x2c0(%rbp)
jmp 0x6dbe
movq -0x2c0(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x30a0
jmp 0x6dd3
leaq -0x150(%rbp), %rdi
callq 0x7cd0
jmp 0x6de1
xorl %eax, %eax
movl %eax, %esi
leaq -0x170(%rbp), %rdi
callq 0x3330
movq %rax, -0x2c8(%rbp)
jmp 0x6dfa
movq -0x2c8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x6eb2
leaq -0x170(%rbp), %rdi
movl $0x1, %esi
callq 0x3330
movq %rax, -0x2d0(%rbp)
jmp 0x6e27
movq -0x2d0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x6eb2
leaq -0x170(%rbp), %rdi
movl $0x2, %esi
callq 0x3330
movq %rax, -0x2d8(%rbp)
jmp 0x6e50
movq -0x2d8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x6eb2
movl $0x6, -0x174(%rbp)
jmp 0x7429
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x776d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x7482
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x7476
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x744b
xorl %eax, %eax
movl %eax, %esi
leaq -0x170(%rbp), %rdi
callq 0x3330
movq %rax, -0x2e0(%rbp)
jmp 0x6ecb
movq -0x2e0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jle 0x6f95
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, -0x2e8(%rbp)
jmp 0x6ef4
xorl %eax, %eax
movl %eax, %esi
leaq -0x170(%rbp), %rdi
callq 0x3330
movq %rax, -0x2f0(%rbp)
jmp 0x6f0d
movq -0x2f0(%rbp), %rcx
movq -0x2e8(%rbp), %rdx
movq -0x288(%rbp), %rsi
leaq -0x198(%rbp), %rdi
callq 0x7b20
jmp 0x6f30
leaq -0x30(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x7cf0
jmp 0x6f42
leaq -0x198(%rbp), %rdi
callq 0x3348
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x30(%rax), %rax
callq *%rax
movq %rax, -0x2f8(%rbp)
jmp 0x6f64
movq -0x2f8(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x7d20
jmp 0x6f76
jmp 0x6f95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x3348
jmp 0x744b
xorl %eax, %eax
movl %eax, %esi
leaq -0x170(%rbp), %rdi
callq 0x3330
movq %rax, -0x300(%rbp)
jmp 0x6fae
movq -0x300(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jg 0x6fcc
leaq -0x30(%rbp), %rdi
callq 0x7d90
cmpq $0x0, %rax
je 0x7048
leaq -0x170(%rbp), %rdi
movl $0x1, %esi
callq 0x3330
movq %rax, -0x308(%rbp)
jmp 0x6fe6
movq -0x308(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jg 0x701e
leaq -0x170(%rbp), %rdi
movl $0x2, %esi
callq 0x3330
movq %rax, -0x310(%rbp)
jmp 0x700f
movq -0x310(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jle 0x7048
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x38(%rax), %rax
callq *%rax
movq %rax, -0x318(%rbp)
jmp 0x7034
movq -0x318(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x7d20
jmp 0x7046
jmp 0x7048
leaq -0x170(%rbp), %rdi
movl $0x1, %esi
callq 0x3330
movq %rax, -0x320(%rbp)
jmp 0x7062
movq -0x320(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
je 0x709e
leaq -0x170(%rbp), %rdi
movl $0x1, %esi
callq 0x3330
movq %rax, -0x328(%rbp)
jmp 0x708b
movq -0x328(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x31, %eax
jle 0x727f
leaq -0x170(%rbp), %rdi
movl $0x1, %esi
callq 0x3330
movq %rax, -0x330(%rbp)
jmp 0x70b8
movq -0x330(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x31, %eax
jle 0x715b
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq %rax, -0x338(%rbp)
jmp 0x70e1
leaq -0x170(%rbp), %rdi
movl $0x1, %esi
callq 0x3330
movq %rax, -0x340(%rbp)
jmp 0x70fb
movq -0x340(%rbp), %rcx
movq -0x338(%rbp), %rdx
movq -0x288(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x7b20
jmp 0x711e
leaq -0x30(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x7cf0
jmp 0x7130
leaq -0x1b8(%rbp), %rdi
callq 0x3348
jmp 0x715b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x3348
jmp 0x744b
leaq -0x170(%rbp), %rdi
movl $0x2, %esi
callq 0x3330
movq %rax, -0x348(%rbp)
jmp 0x7175
movq -0x348(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jle 0x727a
leaq -0x170(%rbp), %rdi
movl $0x1, %esi
callq 0x3330
movq %rax, -0x350(%rbp)
jmp 0x71a2
movq -0x350(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x71ea
leaq -0x30(%rbp), %rdi
callq 0x7d90
cmpq $0x0, %rax
jbe 0x71ea
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x40(%rax), %rax
callq *%rax
movq %rax, -0x358(%rbp)
jmp 0x71d6
movq -0x358(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x7d20
jmp 0x71e8
jmp 0x71ea
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, -0x360(%rbp)
jmp 0x7200
leaq -0x170(%rbp), %rdi
movl $0x2, %esi
callq 0x3330
movq %rax, -0x368(%rbp)
jmp 0x721a
movq -0x368(%rbp), %rcx
movq -0x360(%rbp), %rdx
movq -0x288(%rbp), %rsi
leaq -0x1d8(%rbp), %rdi
callq 0x7b20
jmp 0x723d
leaq -0x30(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x7cf0
jmp 0x724f
leaq -0x1d8(%rbp), %rdi
callq 0x3348
jmp 0x727a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x3348
jmp 0x744b
jmp 0x730f
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movq %rax, -0x370(%rbp)
jmp 0x7295
leaq -0x170(%rbp), %rdi
movl $0x2, %esi
callq 0x3330
movq %rax, -0x378(%rbp)
jmp 0x72af
movq -0x378(%rbp), %rcx
movq -0x370(%rbp), %rdx
movq -0x288(%rbp), %rsi
leaq -0x1f8(%rbp), %rdi
callq 0x7b20
jmp 0x72d2
leaq -0x30(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x7cf0
jmp 0x72e4
leaq -0x1f8(%rbp), %rdi
callq 0x3348
jmp 0x730f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0x3348
jmp 0x744b
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movq %rax, -0x380(%rbp)
jmp 0x7325
movq -0x380(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x7db0
jmp 0x733a
leaq -0x150(%rbp), %rdi
callq 0x7ec0
movq %rax, -0x388(%rbp)
jmp 0x734f
movq -0x388(%rbp), %rsi
leaq -0x210(%rbp), %rdi
callq 0x7ea0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x7d20
jmp 0x7370
movw $0x0, -0x212(%rbp)
movswq -0x212(%rbp), %rax
movq %rax, -0x398(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0x7ec0
movq %rax, -0x390(%rbp)
jmp 0x739d
movq -0x398(%rbp), %rax
movq -0x390(%rbp), %rcx
cmpq %rcx, %rax
jae 0x7413
leaq -0x210(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0x7d90
movq -0x3a0(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x7ea0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x7d20
jmp 0x73e3
jmp 0x73e5
movw -0x212(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x212(%rbp)
jmp 0x7379
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x7ee0
jmp 0x744b
leaq -0x210(%rbp), %rdi
callq 0x7ee0
movl $0x0, -0x174(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x3348
movl -0x174(%rbp), %eax
testl %eax, %eax
je 0x7446
jmp 0x7441
jmp 0x6d84
jmp 0x6d84
leaq -0x170(%rbp), %rdi
callq 0x3348
jmp 0x7476
leaq -0x150(%rbp), %rdi
callq 0x7f40
leaq -0x100(%rbp), %rdi
callq 0x3348
jmp 0x6d09
leaq -0x150(%rbp), %rdi
callq 0x7f40
leaq -0x100(%rbp), %rdi
callq 0x3348
jmp 0x776d
leaq -0x30(%rbp), %rdi
callq 0x7d90
cmpq $0x0, %rax
je 0x750f
testb $0x1, -0x69(%rbp)
je 0x750f
leaq -0x30(%rbp), %rdi
callq 0x8170
movq %rax, -0x228(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x228(%rbp), %rsi
callq 0x81a0
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x48(%rax), %rax
callq *%rax
movq %rax, -0x3a8(%rbp)
jmp 0x74e1
movq -0x3a8(%rbp), %rdx
movq -0x220(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x7f60
movq %rax, -0x3b0(%rbp)
jmp 0x7501
movq -0x3b0(%rbp), %rax
movq %rax, -0x230(%rbp)
movb $0x0, -0x231(%rbp)
leaq -0x232(%rbp), %rdi
movq %rdi, -0x3b8(%rbp)
callq 0x32e0
movq -0x298(%rbp), %rdi
movq -0x3b8(%rbp), %rdx
leaq 0x4adf(%rip), %rsi      # 0xc01d
callq 0x6750
jmp 0x7545
leaq -0x232(%rbp), %rdi
callq 0x31f0
movw $0x0, -0x234(%rbp)
movswq -0x234(%rbp), %rax
movq %rax, -0x3c0(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x7d90
movq %rax, %rcx
movq -0x3c0(%rbp), %rax
cmpq %rcx, %rax
jae 0x7658
movswq -0x234(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x81e0
movq %rax, %rdi
callq 0x3270
cmpq $0x0, %rax
je 0x763f
movswq -0x234(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x81e0
movq %rax, %rsi
leaq 0x4a47(%rip), %rdx      # 0xc00a
leaq -0x258(%rbp), %rdi
callq 0x8200
jmp 0x75d1
movq -0x298(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x3240
jmp 0x75e6
leaq -0x258(%rbp), %rdi
callq 0x3348
jmp 0x763f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x232(%rbp), %rdi
callq 0x31f0
jmp 0x776d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x7761
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x3348
jmp 0x7761
jmp 0x7641
movw -0x234(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x234(%rbp)
jmp 0x755a
movq -0x298(%rbp), %rdi
callq 0x3270
cmpq $0x0, %rax
je 0x76b6
movq -0x298(%rbp), %rdi
callq 0x3110
movq -0x298(%rbp), %rsi
movq %rax, %rcx
decq %rcx
xorl %eax, %eax
movl %eax, %edx
leaq -0x278(%rbp), %rdi
callq 0x31b0
jmp 0x7695
movq -0x298(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x3220
leaq -0x278(%rbp), %rdi
callq 0x3348
jmp 0x76ef
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq %rax, -0x3c8(%rbp)
jmp 0x76cc
movq -0x3c8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7ea0
movq -0x298(%rbp), %rdi
movq %rax, %rsi
callq 0x3030
jmp 0x76ed
jmp 0x76ef
movq -0x38(%rbp), %rax
movq %rax, -0x3d0(%rbp)
cmpq $0x0, %rax
je 0x770d
movq -0x3d0(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movb $0x1, -0x231(%rbp)
movl $0x1, -0x174(%rbp)
testb $0x1, -0x231(%rbp)
jne 0x7733
movq -0x298(%rbp), %rdi
callq 0x3348
leaq -0xe0(%rbp), %rdi
callq 0x7f40
leaq -0x68(%rbp), %rdi
callq 0x3348
leaq -0x30(%rbp), %rdi
callq 0x7ee0
movq -0x290(%rbp), %rax
addq $0x3d0, %rsp            # imm = 0x3D0
popq %rbp
retq
movq -0x298(%rbp), %rdi
callq 0x3348
leaq -0xe0(%rbp), %rdi
callq 0x7f40
leaq -0x68(%rbp), %rdi
callq 0x3348
leaq -0x30(%rbp), %rdi
callq 0x7ee0
movq -0x40(%rbp), %rdi
callq 0x32d0
nopw %cs:(%rax,%rax)