// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %r8, %r13
movl %ecx, 0x10(%rsp)
movl %edx, %r12d
movq %rsi, %rbp
movq %rdi, 0x58(%rsp)
movq 0x100(%rsp), %r14
movq %r9, (%rsp)
movq %r9, %rdi
callq 0x4fb48
movl %eax, %ebx
movq %r14, %rdi
callq 0x4fb48
movl %eax, %r15d
addl %ebx, %r15d
movq %rbp, 0x8(%rsp)
movq %rbp, %rdi
callq 0x4fb48
movl %eax, %ebx
leal (%rbx,%r15), %eax
movl %r12d, %r14d
subl %eax, %r14d
js 0x53665
jne 0x536f5
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x441eb
movq 0x58(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq 0x100(%rsp), %rdx
callq 0x184b5
jmp 0x53995
movl %r12d, %r13d
subl %r15d, %r13d
jle 0x53779
cmpl $-0x1, 0x10(%rsp)
movq 0x58(%rsp), %r15
je 0x538d4
decl %r13d
leaq 0x60(%rsp), %rbx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
movl %r13d, %ecx
callq 0x531d9
leaq 0x38(%rsp), %rdi
movq (%rsp), %rsi
movq %rbx, %rdx
callq 0x441c7
leaq 0x5b15(%rip), %rdx      # 0x591c8
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0xc882
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
movq 0x100(%rsp), %rdx
callq 0x184b5
leaq 0x18(%rsp), %rdi
callq 0xa558
leaq 0x38(%rsp), %rdi
callq 0xa558
leaq 0x60(%rsp), %rdi
jmp 0x5399a
movl 0x10(%rsp), %ebp
testl %ebp, %ebp
movq 0x58(%rsp), %r15
leaq 0x28(%rsp), %rax
je 0x537ac
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x18(%rsp), %rbx
subl $0x1, %r14d
jb 0x5372f
movq %rbx, %rdi
movq %r13, %rsi
callq 0xa540
jmp 0x5371c
cmpl $-0x1, %ebp
je 0x53945
leaq 0x60(%rsp), %rdi
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x441eb
leaq 0x38(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movq 0x100(%rsp), %rdx
callq 0x184b5
leaq 0x38(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %r15, %rdi
callq 0x184b5
jmp 0x53981
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
movq (%rsp), %rsi
movq 0x100(%rsp), %rdx
callq 0x441eb
movq 0x58(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movl %r12d, %ecx
callq 0x531d9
jmp 0x53995
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ebp, %ebp
movb %bpl, (%rax)
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %bpl, (%rax)
cvtsi2sd %r14d, %xmm0
mulsd 0x59d8(%rip), %xmm0     # 0x591b0
movsd %xmm0, 0x80(%rsp)
callq 0xa4c0
movsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rbx
cvtsi2sd %ebp, %xmm0
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x53810
movq %rbx, %rdi
movq %r13, %rsi
callq 0xa540
incl %ebp
jmp 0x537f1
movsd 0x80(%rsp), %xmm0
callq 0xa070
movsd %xmm0, 0x10(%rsp)
xorl %ebp, %ebp
leaq 0x38(%rsp), %rbx
cvtsi2sd %ebp, %xmm0
movsd 0x10(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x5384a
movq %rbx, %rdi
movq %r13, %rsi
callq 0xa540
incl %ebp
jmp 0x5382b
leaq 0x88(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movq (%rsp), %rdx
callq 0x441eb
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x184b5
leaq 0x60(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
movq 0x100(%rsp), %rdx
callq 0x184b5
leaq 0x60(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %r15, %rdi
callq 0x184b5
leaq 0x60(%rsp), %rdi
callq 0xa558
leaq 0xa8(%rsp), %rdi
callq 0xa558
leaq 0x88(%rsp), %rdi
callq 0xa558
leaq 0x38(%rsp), %rdi
jmp 0x53990
leaq 0x58ed(%rip), %rdx      # 0x591c8
leaq 0x38(%rsp), %rdi
movq (%rsp), %rsi
callq 0x11fb8
movl %ebx, %edx
subl %r13d, %edx
incl %edx
leaq 0x60(%rsp), %rdi
movq 0x8(%rsp), %rsi
movl %ebx, %ecx
callq 0x531d9
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x60(%rsp), %rdx
callq 0x1205e
leaq 0x18(%rsp), %rsi
movq %r15, %rdi
movq 0x100(%rsp), %rdx
callq 0x184b5
leaq 0x18(%rsp), %rdi
callq 0xa558
leaq 0x60(%rsp), %rdi
callq 0xa558
leaq 0x38(%rsp), %rdi
jmp 0x5399a
leaq 0x60(%rsp), %rdi
leaq 0x18(%rsp), %rsi
movq (%rsp), %rdx
callq 0x441eb
leaq 0x38(%rsp), %rdi
leaq 0x60(%rsp), %rsi
movq 0x8(%rsp), %rdx
callq 0x184b5
leaq 0x38(%rsp), %rsi
movq %r15, %rdi
movq 0x100(%rsp), %rdx
callq 0x184b5
leaq 0x38(%rsp), %rdi
callq 0xa558
leaq 0x60(%rsp), %rdi
callq 0xa558
leaq 0x18(%rsp), %rdi
callq 0xa558
movq %r15, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x53a1d
jmp 0x53a2c
jmp 0x53a75
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xa558
jmp 0x539cf
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0xa558
jmp 0x539de
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
jmp 0x53a7d
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0xa558
jmp 0x539fa
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0xa558
jmp 0x53a0c
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0xa558
jmp 0x53a69
jmp 0x53a66
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xa558
jmp 0x53a2f
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x53a6e
jmp 0x53a75
jmp 0x53a75
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xa558
jmp 0x53a4c
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xa558
jmp 0x53a5b
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x53a7d
jmp 0x53a75
jmp 0x53a66
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xa558
jmp 0x53a78
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xa558
movq %rbx, %rdi
callq 0xa500