// File: menhits[P]phplus/src/utils/stringUtils.cpp
// Function: str::pad(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, str::StringPadAlignment, 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 pad(const string& in, int size, StringPadAlignment alignment, string pad, string leftCap, string rightCap)
{
	int capWidth=getWidth(leftCap)+getWidth(rightCap);
	int inSize=getWidth(in);
	int padSize=size-(inSize+capWidth);
	
	if (padSize<0) // need to chop
	{
		if (size-capWidth>=1)
		{
			if (alignment==ALIGNMENT_RIGHT)
			{
				return leftCap+"…"+sub(in, inSize-(size-capWidth-1), inSize)+rightCap;
			}
			else
			{
				return leftCap+sub(in, 0, size-capWidth-1)+"…"+rightCap;
			}
		}
		else
		{
			return sub(leftCap+rightCap, 0, size);
		}
	}
	else if (padSize==0) // input size was exactly right
	{
		return leftCap+in+rightCap;
	}
	else // need to pad
	{
		if (alignment==ALIGNMENT_CENTER) // 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==ALIGNMENT_RIGHT) // right align
				return padStr+leftCap+in+rightCap;
			else // left align
				return leftCap+in+rightCap+padStr;
		}
	}
}

// Assembly:
subq $0x2f8, %rsp            # imm = 0x2F8
movq %r9, 0x30(%rsp)
movq %r8, 0x28(%rsp)
movq %rdi, %rax
movq 0x30(%rsp), %rdi
movq %rax, 0x38(%rsp)
movq %rax, %r9
movq %r9, 0x40(%rsp)
movq 0x300(%rsp), %r9
movq %r9, 0x48(%rsp)
movq %rax, 0x2f0(%rsp)
movq %rsi, 0x2e8(%rsp)
movl %edx, 0x2e4(%rsp)
movl %ecx, 0x2e0(%rsp)
movq %r8, 0x2d8(%rsp)
movq %rdi, 0x2d0(%rsp)
callq 0xc7ff0
movq 0x48(%rsp), %rdi
movl %eax, 0x54(%rsp)
callq 0xc7ff0
movl %eax, %ecx
movl 0x54(%rsp), %eax
addl %ecx, %eax
movl %eax, 0x2cc(%rsp)
movq 0x2e8(%rsp), %rdi
callq 0xc7ff0
movl %eax, 0x2c8(%rsp)
movl 0x2e4(%rsp), %eax
movl 0x2c8(%rsp), %ecx
addl 0x2cc(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0x2c4(%rsp)
cmpl $0x0, 0x2c4(%rsp)
jge 0xd033b
movl 0x2e4(%rsp), %eax
subl 0x2cc(%rsp), %eax
cmpl $0x1, %eax
jl 0xd02cd
cmpl $-0x1, 0x2e0(%rsp)
jne 0xd01b7
movq 0x30(%rsp), %rsi
leaq 0x696c(%rip), %rdx      # 0xd6a10
leaq 0x280(%rsp), %rdi
callq 0x1ba50
movq 0x2e8(%rsp), %rsi
movl 0x2c8(%rsp), %ecx
movl 0x2e4(%rsp), %edx
movl 0x2cc(%rsp), %edi
movl %ecx, %eax
subl %edx, %edi
movl %edi, %edx
leal 0x1(%rax,%rdx), %edx
leaq 0x260(%rsp), %rdi
callq 0xcf240
jmp 0xd00e7
leaq 0x2a0(%rsp), %rdi
leaq 0x280(%rsp), %rsi
leaq 0x260(%rsp), %rdx
callq 0x1bf20
jmp 0xd0106
movq 0x48(%rsp), %rdx
movq 0x38(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x2e070
jmp 0xd011f
leaq 0x2a0(%rsp), %rdi
callq 0xb6e8
leaq 0x260(%rsp), %rdi
callq 0xb6e8
leaq 0x280(%rsp), %rdi
callq 0xb6e8
jmp 0xd0808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd01a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd0198
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0xb6e8
leaq 0x260(%rsp), %rdi
callq 0xb6e8
leaq 0x280(%rsp), %rdi
callq 0xb6e8
jmp 0xd0815
movq 0x2e8(%rsp), %rsi
movl 0x2e4(%rsp), %eax
movl 0x2cc(%rsp), %ecx
notl %ecx
addl %eax, %ecx
leaq 0x1f0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
xorl %edx, %edx
callq 0xcf240
movq 0x30(%rsp), %rsi
movq 0x20(%rsp), %rdx
leaq 0x210(%rsp), %rdi
callq 0xad680
jmp 0xd01fe
leaq 0x680b(%rip), %rdx      # 0xd6a10
leaq 0x230(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0xfa60
jmp 0xd021c
movq 0x48(%rsp), %rdx
movq 0x38(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0x2e070
jmp 0xd0235
leaq 0x230(%rsp), %rdi
callq 0xb6e8
leaq 0x210(%rsp), %rdi
callq 0xb6e8
leaq 0x1f0(%rsp), %rdi
callq 0xb6e8
jmp 0xd0808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd02bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd02ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0x230(%rsp), %rdi
callq 0xb6e8
leaq 0x210(%rsp), %rdi
callq 0xb6e8
leaq 0x1f0(%rsp), %rdi
callq 0xb6e8
jmp 0xd0815
movq 0x48(%rsp), %rdx
movq 0x30(%rsp), %rsi
leaq 0x1d0(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xad6d0
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl 0x2e4(%rsp), %ecx
xorl %edx, %edx
callq 0xcf240
jmp 0xd0303
leaq 0x1d0(%rsp), %rdi
callq 0xb6e8
jmp 0xd0808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0xb6e8
jmp 0xd0815
cmpl $0x0, 0x2c4(%rsp)
jne 0xd03b2
movq 0x30(%rsp), %rsi
movq 0x2e8(%rsp), %rdx
leaq 0x1b0(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0xad6d0
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x48(%rsp), %rdx
callq 0x2e070
jmp 0xd037a
leaq 0x1b0(%rsp), %rdi
callq 0xb6e8
jmp 0xd0808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0xb6e8
jmp 0xd0815
cmpl $0x0, 0x2e0(%rsp)
jne 0xd0602
leaq 0x190(%rsp), %rdi
callq 0xb4e0
leaq 0x170(%rsp), %rdi
callq 0xb4e0
movl $0x0, 0x16c(%rsp)
cvtsi2sdl 0x16c(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
cvtsi2sdl 0x2c4(%rsp), %xmm0
movsd 0x65eb(%rip), %xmm1     # 0xd69f0
divsd %xmm1, %xmm0
callq 0xb620
movsd 0x8(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd045c
movq 0x28(%rsp), %rsi
leaq 0x190(%rsp), %rdi
callq 0xb470
jmp 0xd042e
jmp 0xd0430
movl 0x16c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x16c(%rsp)
jmp 0xd03e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd05e3
movl $0x0, 0x168(%rsp)
cvtsi2sdl 0x168(%rsp), %xmm0
movsd %xmm0, (%rsp)
cvtsi2sdl 0x2c4(%rsp), %xmm0
movsd 0x656a(%rip), %xmm1     # 0xd69f0
divsd %xmm1, %xmm0
callq 0xb090
movsd (%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd04c3
movq 0x28(%rsp), %rsi
leaq 0x170(%rsp), %rdi
callq 0xb470
jmp 0xd04ae
jmp 0xd04b0
movl 0x168(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x168(%rsp)
jmp 0xd0467
movq 0x30(%rsp), %rdx
leaq 0x108(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0xad6d0
jmp 0xd04df
movq 0x2e8(%rsp), %rdx
leaq 0x128(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x2e070
jmp 0xd04fe
movq 0x48(%rsp), %rdx
leaq 0x148(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x2e070
jmp 0xd051a
movq 0x38(%rsp), %rdi
leaq 0x148(%rsp), %rsi
leaq 0x170(%rsp), %rdx
callq 0x2e070
jmp 0xd0536
leaq 0x148(%rsp), %rdi
callq 0xb6e8
leaq 0x128(%rsp), %rdi
callq 0xb6e8
leaq 0x108(%rsp), %rdi
callq 0xb6e8
leaq 0x170(%rsp), %rdi
callq 0xb6e8
leaq 0x190(%rsp), %rdi
callq 0xb6e8
jmp 0xd0808
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd05d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd05c9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0x148(%rsp), %rdi
callq 0xb6e8
leaq 0x128(%rsp), %rdi
callq 0xb6e8
leaq 0x108(%rsp), %rdi
callq 0xb6e8
leaq 0x170(%rsp), %rdi
callq 0xb6e8
leaq 0x190(%rsp), %rdi
callq 0xb6e8
jmp 0xd0815
leaq 0xe8(%rsp), %rdi
callq 0xb4e0
movl $0x0, 0xe4(%rsp)
movl 0xe4(%rsp), %eax
cmpl 0x2c4(%rsp), %eax
jge 0xd066c
movq 0x28(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
callq 0xb470
jmp 0xd063e
jmp 0xd0640
movl 0xe4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe4(%rsp)
jmp 0xd061a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd07f9
cmpl $-0x1, 0x2e0(%rsp)
jne 0xd0741
movq 0x30(%rsp), %rdx
leaq 0xa0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0xad6d0
jmp 0xd0696
movq 0x2e8(%rsp), %rdx
leaq 0xc0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x2e070
jmp 0xd06b5
movq 0x48(%rsp), %rdx
movq 0x38(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x2e070
jmp 0xd06ce
leaq 0xc0(%rsp), %rdi
callq 0xb6e8
leaq 0xa0(%rsp), %rdi
callq 0xb6e8
movl $0x1, 0x9c(%rsp)
jmp 0xd07ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd072f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0xb6e8
leaq 0xa0(%rsp), %rdi
callq 0xb6e8
jmp 0xd07f9
movq 0x30(%rsp), %rsi
movq 0x2e8(%rsp), %rdx
leaq 0x58(%rsp), %rdi
callq 0xad6d0
jmp 0xd075a
movq 0x48(%rsp), %rdx
leaq 0x78(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2e070
jmp 0xd0770
movq 0x38(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x2e070
jmp 0xd0789
leaq 0x78(%rsp), %rdi
callq 0xb6e8
leaq 0x58(%rsp), %rdi
callq 0xb6e8
movl $0x1, 0x9c(%rsp)
jmp 0xd07ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
jmp 0xd07de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x258(%rsp)
movl %eax, 0x254(%rsp)
leaq 0x78(%rsp), %rdi
callq 0xb6e8
leaq 0x58(%rsp), %rdi
callq 0xb6e8
jmp 0xd07f9
leaq 0xe8(%rsp), %rdi
callq 0xb6e8
jmp 0xd0808
leaq 0xe8(%rsp), %rdi
callq 0xb6e8
jmp 0xd0815
movq 0x40(%rsp), %rax
addq $0x2f8, %rsp            # imm = 0x2F8
retq
movq 0x258(%rsp), %rdi
callq 0xb680
nopw %cs:(%rax,%rax)