// File: sokolcom[P]tp-blockchain-task06/uint256_t/uint256_t.cpp
// Function: uint256_t::str[abi:cxx11](unsigned char, unsigned int const&) const
std::string uint256_t::str(uint8_t base, const unsigned int & len) const{
    if ((base < 2) || (base > 36)){
        throw std::invalid_argument("Base must be in the range 2-36");
    }
    std::string out = "";
    if (!(*this)){
        out = "0";
    }
    else{
        std::pair <uint256_t, uint256_t> qr(*this, uint256_0);
        do{
            qr = divmod(qr.first, base);
            out = "0123456789abcdefghijklmnopqrstuvwxyz"[(uint8_t) qr.second] + out;
        } while (qr.first);
    }
    if (out.size() < len){
        out = std::string(len - out.size(), '0') + out;
    }
    return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x150(%rbp)
movb %dl, %al
movq %rdi, %rdx
movq %rdx, -0x148(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
movzbl -0x11(%rbp), %eax
cmpl $0x2, %eax
jl 0x950a
movzbl -0x11(%rbp), %eax
cmpl $0x24, %eax
jle 0x9566
movl $0x10, %edi
callq 0x30e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x158(%rbp)
leaq 0x5b73(%rip), %rsi      # 0xf09b
callq 0x33b0
jmp 0x952f
movq -0x158(%rbp), %rdi
movq 0xca93(%rip), %rsi      # 0x15fd0
movq 0xca7c(%rip), %rdx      # 0x15fc0
callq 0x3360
movq -0x158(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x3190
jmp 0x9822
movb $0x0, -0x2d(%rbp)
leaq -0x2e(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x3390
movq -0x150(%rbp), %rdi
movq -0x160(%rbp), %rdx
leaq 0x5bcb(%rip), %rsi      # 0xf15a
callq 0x5ac0
jmp 0x9596
leaq -0x2e(%rbp), %rdi
callq 0x3250
movq -0x140(%rbp), %rdi
callq 0x7bc0
movb %al, -0x161(%rbp)
jmp 0x95b3
movb -0x161(%rbp), %al
testb $0x1, %al
jne 0x95bf
jmp 0x9604
movq -0x150(%rbp), %rdi
leaq 0x5a55(%rip), %rsi      # 0xf022
callq 0x32d0
jmp 0x95d4
jmp 0x96eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2e(%rbp), %rdi
callq 0x3250
jmp 0x9822
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x9816
movq -0x140(%rbp), %rsi
leaq 0xcc4e(%rip), %rdx      # 0x16260
leaq -0x70(%rbp), %rdi
callq 0xaf80
jmp 0x961d
jmp 0x961f
leaq -0x70(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0x11(%rbp), %rsi
callq 0xb2c0
jmp 0x963c
movq -0x170(%rbp), %rdx
movq -0x140(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
leaq -0xd0(%rbp), %rcx
callq 0x8b90
jmp 0x965f
leaq -0x70(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xb310
leaq -0x50(%rbp), %rdi
callq 0x6fe0
movb %al, -0x171(%rbp)
jmp 0x9680
movq -0x150(%rbp), %rdx
movb -0x171(%rbp), %al
movzbl %al, %eax
leaq 0x5a23(%rip), %rcx      # 0xf0ba
movsbl (%rax,%rcx), %esi
leaq -0xf0(%rbp), %rdi
callq 0x5be0
jmp 0x96a9
movq -0x150(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x3290
leaq -0xf0(%rbp), %rdi
callq 0x3140
leaq -0x70(%rbp), %rdi
callq 0x6fa0
movb %al, -0x172(%rbp)
jmp 0x96d9
movb -0x172(%rbp), %al
testb $0x1, %al
jne 0x961f
jmp 0x96e9
jmp 0x96eb
movq -0x150(%rbp), %rdi
callq 0x3170
movq -0x20(%rbp), %rcx
movl (%rcx), %ecx
cmpq %rcx, %rax
jae 0x97f0
movq -0x150(%rbp), %rdi
movq -0x20(%rbp), %rax
movl (%rax), %eax
movq %rax, -0x190(%rbp)
callq 0x3170
movq %rax, %rcx
movq -0x190(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x188(%rbp)
leaq -0x131(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x3390
movq -0x188(%rbp), %rsi
movq -0x180(%rbp), %rcx
leaq -0x130(%rbp), %rdi
movl $0x30, %edx
callq 0x5d30
jmp 0x9767
movq -0x150(%rbp), %rdx
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x5ce0
jmp 0x9783
movq -0x150(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x3290
leaq -0x110(%rbp), %rdi
callq 0x3140
leaq -0x130(%rbp), %rdi
callq 0x3140
leaq -0x131(%rbp), %rdi
callq 0x3250
jmp 0x97f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0x97e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x3140
leaq -0x131(%rbp), %rdi
callq 0x3250
jmp 0x9816
movb $0x1, -0x2d(%rbp)
testb $0x1, -0x2d(%rbp)
jne 0x9806
movq -0x150(%rbp), %rdi
callq 0x3140
movq -0x148(%rbp), %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0x150(%rbp), %rdi
callq 0x3140
movq -0x28(%rbp), %rdi
callq 0x3380
nopl (%rax,%rax)