// File: menhits[P]phplus/src/msclStringFuncs.cpp
// Function: padString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string padString(const string& in, int size, int alignment,  string pad, string leftCap, string rightCap)
{
	int capSize=leftCap.size()+rightCap.size();
	int padSize=size-int(in.size()+capSize);
	
	if (padSize<0) // need to chop
	{
		if (size-capSize>=1)
		{
			return leftCap+in.substr(0, size-capSize-1)+"…"+rightCap;
		}
		else if (size-capSize>=0)
		{
			return leftCap+string("…").substr(0, size-capSize)+rightCap;
		}
		else
		{
			return (leftCap+rightCap).substr(0, size);
		}
	}
	else if (padSize==0) // input size was exactly right
	{
		return leftCap+in+rightCap;
	}
	else // need to pad
	{
		if (alignment==0) // center alignment
		{
			string leftPad, rightPad;
			
			for (int i=0; i<floor(padSize/2.0); i++)
				leftPad+=pad;
			
			for (int i=0; i<ceil(padSize/2.0); i++)
				rightPad+=pad;
			
			return leftPad+leftCap+in+rightCap+rightPad;
		}
		// left or right alignment
		else
		{
			string padStr;
			
			for (int i=0; i<padSize; i++)
				padStr+=pad;
			
			if (alignment>0) // right align
				return leftCap+in+rightCap+padStr;
			else // left align
				return padStr+leftCap+in+rightCap;
		}

	}
}

// Assembly:
subq $0x308, %rsp            # imm = 0x308
movq %r9, 0x38(%rsp)
movq %r8, 0x30(%rsp)
movq %rdi, %rax
movq 0x38(%rsp), %rdi
movq %rax, 0x40(%rsp)
movq %rax, %r9
movq %r9, 0x48(%rsp)
movq 0x310(%rsp), %r9
movq %r9, 0x50(%rsp)
movq %rax, 0x300(%rsp)
movq %rsi, 0x2f8(%rsp)
movl %edx, 0x2f4(%rsp)
movl %ecx, 0x2f0(%rsp)
movq %r8, 0x2e8(%rsp)
movq %rdi, 0x2e0(%rsp)
callq 0xb2a0
movq 0x50(%rsp), %rdi
movq %rax, 0x58(%rsp)
callq 0xb2a0
movq %rax, %rcx
movq 0x58(%rsp), %rax
addq %rcx, %rax
movl %eax, 0x2dc(%rsp)
movl 0x2f4(%rsp), %eax
movl %eax, 0x64(%rsp)
movq 0x2f8(%rsp), %rdi
callq 0xb2a0
movq %rax, %rcx
movl 0x64(%rsp), %eax
movslq 0x2dc(%rsp), %rdx
addq %rdx, %rcx
subl %ecx, %eax
movl %eax, 0x2d8(%rsp)
cmpl $0x0, 0x2d8(%rsp)
jge 0xa8faa
movl 0x2f4(%rsp), %eax
subl 0x2dc(%rsp), %eax
cmpl $0x1, %eax
jl 0xa8dca
movq 0x2f8(%rsp), %rsi
movl 0x2f4(%rsp), %ecx
movl 0x2dc(%rsp), %eax
notl %eax
addl %ecx, %eax
movslq %eax, %rcx
xorl %eax, %eax
movl %eax, %edx
leaq 0x278(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0xb3a0
movq 0x38(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0x298(%rsp), %rdi
callq 0xad680
jmp 0xa8cfb
leaq 0x2dd0e(%rip), %rdx     # 0xd6a10
leaq 0x2b8(%rsp), %rdi
leaq 0x298(%rsp), %rsi
callq 0xfa60
jmp 0xa8d19
movq 0x50(%rsp), %rdx
movq 0x40(%rsp), %rdi
leaq 0x2b8(%rsp), %rsi
callq 0x2e070
jmp 0xa8d32
leaq 0x2b8(%rsp), %rdi
callq 0xb6e8
leaq 0x298(%rsp), %rdi
callq 0xb6e8
leaq 0x278(%rsp), %rdi
callq 0xb6e8
jmp 0xa9483
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa8db8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa8dab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x2b8(%rsp), %rdi
callq 0xb6e8
leaq 0x298(%rsp), %rdi
callq 0xb6e8
leaq 0x278(%rsp), %rdi
callq 0xb6e8
jmp 0xa9490
movl 0x2f4(%rsp), %eax
subl 0x2dc(%rsp), %eax
cmpl $0x0, %eax
jl 0xa8f39
leaq 0x207(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xb690
movq 0x20(%rsp), %rdx
leaq 0x2dc11(%rip), %rsi     # 0xd6a10
leaq 0x208(%rsp), %rdi
callq 0xb4c0
jmp 0xa8e0e
movl 0x2f4(%rsp), %eax
movl 0x2dc(%rsp), %ecx
subl %ecx, %eax
movslq %eax, %rcx
xorl %eax, %eax
movl %eax, %edx
leaq 0x228(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0xb3a0
jmp 0xa8e3c
movq 0x38(%rsp), %rsi
leaq 0x248(%rsp), %rdi
leaq 0x228(%rsp), %rdx
callq 0xad680
jmp 0xa8e58
movq 0x50(%rsp), %rdx
movq 0x40(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0x2e070
jmp 0xa8e71
leaq 0x248(%rsp), %rdi
callq 0xb6e8
leaq 0x228(%rsp), %rdi
callq 0xb6e8
leaq 0x208(%rsp), %rdi
callq 0xb6e8
leaq 0x207(%rsp), %rdi
callq 0xb3f0
jmp 0xa9483
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa8f27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa8f1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa8f0d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x248(%rsp), %rdi
callq 0xb6e8
leaq 0x228(%rsp), %rdi
callq 0xb6e8
leaq 0x208(%rsp), %rdi
callq 0xb6e8
leaq 0x207(%rsp), %rdi
callq 0xb3f0
jmp 0xa9490
movq 0x50(%rsp), %rdx
movq 0x38(%rsp), %rsi
leaq 0x1e0(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xad6d0
movq 0x40(%rsp), %rdi
movq 0x18(%rsp), %rsi
movslq 0x2f4(%rsp), %rcx
xorl %eax, %eax
movl %eax, %edx
callq 0xb3a0
jmp 0xa8f72
leaq 0x1e0(%rsp), %rdi
callq 0xb6e8
jmp 0xa9483
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x1e0(%rsp), %rdi
callq 0xb6e8
jmp 0xa9490
cmpl $0x0, 0x2d8(%rsp)
jne 0xa9021
movq 0x38(%rsp), %rsi
movq 0x2f8(%rsp), %rdx
leaq 0x1c0(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0xad6d0
movq 0x40(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x50(%rsp), %rdx
callq 0x2e070
jmp 0xa8fe9
leaq 0x1c0(%rsp), %rdi
callq 0xb6e8
jmp 0xa9483
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0xb6e8
jmp 0xa9490
cmpl $0x0, 0x2f0(%rsp)
jne 0xa9271
leaq 0x1a0(%rsp), %rdi
callq 0xb4e0
leaq 0x180(%rsp), %rdi
callq 0xb4e0
movl $0x0, 0x17c(%rsp)
cvtsi2sdl 0x17c(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
cvtsi2sdl 0x2d8(%rsp), %xmm0
movsd 0x2d97c(%rip), %xmm1    # 0xd69f0
divsd %xmm1, %xmm0
callq 0xb620
movsd 0x8(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xa90cb
movq 0x30(%rsp), %rsi
leaq 0x1a0(%rsp), %rdi
callq 0xb470
jmp 0xa909d
jmp 0xa909f
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0xa9054
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa9252
movl $0x0, 0x178(%rsp)
cvtsi2sdl 0x178(%rsp), %xmm0
movsd %xmm0, (%rsp)
cvtsi2sdl 0x2d8(%rsp), %xmm0
movsd 0x2d8fb(%rip), %xmm1    # 0xd69f0
divsd %xmm1, %xmm0
callq 0xb090
movsd (%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xa9132
movq 0x30(%rsp), %rsi
leaq 0x180(%rsp), %rdi
callq 0xb470
jmp 0xa911d
jmp 0xa911f
movl 0x178(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x178(%rsp)
jmp 0xa90d6
movq 0x38(%rsp), %rdx
leaq 0x118(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0xad6d0
jmp 0xa914e
movq 0x2f8(%rsp), %rdx
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x2e070
jmp 0xa916d
movq 0x50(%rsp), %rdx
leaq 0x158(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x2e070
jmp 0xa9189
movq 0x40(%rsp), %rdi
leaq 0x158(%rsp), %rsi
leaq 0x180(%rsp), %rdx
callq 0x2e070
jmp 0xa91a5
leaq 0x158(%rsp), %rdi
callq 0xb6e8
leaq 0x138(%rsp), %rdi
callq 0xb6e8
leaq 0x118(%rsp), %rdi
callq 0xb6e8
leaq 0x180(%rsp), %rdi
callq 0xb6e8
leaq 0x1a0(%rsp), %rdi
callq 0xb6e8
jmp 0xa9483
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa9245
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa9238
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x158(%rsp), %rdi
callq 0xb6e8
leaq 0x138(%rsp), %rdi
callq 0xb6e8
leaq 0x118(%rsp), %rdi
callq 0xb6e8
leaq 0x180(%rsp), %rdi
callq 0xb6e8
leaq 0x1a0(%rsp), %rdi
callq 0xb6e8
jmp 0xa9490
leaq 0xf8(%rsp), %rdi
callq 0xb4e0
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
cmpl 0x2d8(%rsp), %eax
jge 0xa92db
movq 0x30(%rsp), %rsi
leaq 0xf8(%rsp), %rdi
callq 0xb470
jmp 0xa92ad
jmp 0xa92af
movl 0xf4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xf4(%rsp)
jmp 0xa9289
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa9474
cmpl $0x0, 0x2f0(%rsp)
jle 0xa93b0
movq 0x38(%rsp), %rsi
movq 0x2f8(%rsp), %rdx
leaq 0xb0(%rsp), %rdi
callq 0xad6d0
jmp 0xa9305
movq 0x50(%rsp), %rdx
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x2e070
jmp 0xa9321
movq 0x40(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
callq 0x2e070
jmp 0xa933d
leaq 0xd0(%rsp), %rdi
callq 0xb6e8
leaq 0xb0(%rsp), %rdi
callq 0xb6e8
movl $0x1, 0xac(%rsp)
jmp 0xa9465
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa939e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0xb6e8
leaq 0xb0(%rsp), %rdi
callq 0xb6e8
jmp 0xa9474
movq 0x38(%rsp), %rdx
leaq 0x68(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0xad6d0
jmp 0xa93c9
movq 0x2f8(%rsp), %rdx
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2e070
jmp 0xa93e5
movq 0x50(%rsp), %rdx
movq 0x40(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x2e070
jmp 0xa93fe
leaq 0x88(%rsp), %rdi
callq 0xb6e8
leaq 0x68(%rsp), %rdi
callq 0xb6e8
movl $0x1, 0xac(%rsp)
jmp 0xa9465
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0xa9459
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xb6e8
leaq 0x68(%rsp), %rdi
callq 0xb6e8
jmp 0xa9474
leaq 0xf8(%rsp), %rdi
callq 0xb6e8
jmp 0xa9483
leaq 0xf8(%rsp), %rdi
callq 0xb6e8
jmp 0xa9490
movq 0x48(%rsp), %rax
addq $0x308, %rsp            # imm = 0x308
retq
movq 0x270(%rsp), %rdi
callq 0xb680
nopl (%rax)