// File: /workspace/github_cpp_makefile_star2_O3/menhits[P]phplus/src/msclStringFuncs.cpp
// Function: getUniqueString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::function<bool (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)>, bool)
string getUniqueString(string hint, std::function<bool (string)> checker, bool alwaysAppendRandom)
{
	string out=hint;
	
	int attempts=0;
	bool invalid=out.empty() || !checker(out) || alwaysAppendRandom;
	
	while (invalid)
	{
		if (alwaysAppendRandom || attempts>=10)
		{
			out=hint+"_";
			
			if (attempts>20)
			{
				throw PhplusError("could not find unique random name", INTERNAL_ERROR);
			}
			
			for (int i=0; i<3; i++)
				out+=getRandChar();
		}
		else
		{
			string suffix=to_string(attempts);
			
			out=hint+"_"+suffix;
		}
		attempts++;
		invalid=!checker(out);
	}
	
	return out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movl %ecx, 0x4(%rsp)
movq %rdx, %r14
movq %rsi, %rcx
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, 0x50(%rsp)
movq %rax, (%rdi)
movq (%rsi), %rsi
movq %rcx, 0x28(%rsp)
movq 0x8(%rcx), %rdx
addq %rsi, %rdx
callq 0xde0c
movq 0x8(%rbx), %rdx
testq %rdx, %rdx
je 0x5ea01
leaq 0xb0(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rbx), %rsi
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0xde0c
cmpq $0x0, 0x10(%r14)
je 0x5ecd6
leaq 0xa0(%rsp), %rsi
movq %r14, %rdi
callq *0x18(%r14)
movl %eax, %ebp
xorb $0x1, %bpl
orb 0x4(%rsp), %bpl
movq 0xa0(%rsp), %rdi
cmpq %r12, %rdi
je 0x5e9f8
callq 0xa2b0
testb %bpl, %bpl
je 0x5ec49
leaq 0x18(%rsp), %r13
xorl %r12d, %r12d
leaq 0x8(%rsp), %r15
movl $0x84210843, %ebp       # imm = 0x84210843
movq %r14, 0x58(%rsp)
cmpl $0xa, %r12d
setae %al
orb 0x4(%rsp), %al
cmpb $0x1, %al
jne 0x5eadb
movq %r13, 0x8(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xde0c
movq %r15, %rdi
leaq 0x1d795(%rip), %rsi     # 0x7c1e6
callq 0xa560
movq %rbx, %rdi
movq %r15, %rsi
callq 0xa370
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x5ea70
callq 0xa2b0
cmpl $0x14, %r12d
ja 0x5ec63
movl $0x3, %r13d
imull $0x41c64e6d, 0x3b866(%rip), %ecx # imm = 0x41C64E6D
addl $0x3039, %ecx           # imm = 0x3039
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movl %ecx, 0x3b854(%rip)     # 0x9a2f0
movq %rcx, %rax
imulq %rbp, %rax
shrq $0x25, %rax
movl %eax, %edx
shll $0x6, %edx
addl %eax, %eax
subl %edx, %eax
addl %ecx, %eax
cmpl $0x19, %eax
ja 0x5eabb
addb $0x61, %al
jmp 0x5eac6
cmpl $0x33, %eax
ja 0x5eac4
addb $0x27, %al
jmp 0x5eac6
addb $-0x4, %al
movsbl %al, %esi
movq %rbx, %rdi
callq 0xa290
decl %r13d
jne 0x5ea80
jmp 0x5ebeb
movq %r13, 0x8(%rsp)
movl $0x1, %esi
movq %r15, %rdi
movl $0x2d, %edx
callq 0xa330
movq 0x8(%rsp), %rdi
movl $0x1, %esi
movl %r12d, %edx
callq 0x50ca9
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x28(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0xde0c
movq %r15, %rdi
leaq 0x1d6b2(%rip), %rsi     # 0x7c1e6
callq 0xa560
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r15, %rdi
callq 0xa110
leaq 0x90(%rsp), %r15
movq %r15, 0x80(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x5eb7f
movq %rdx, 0x80(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x90(%rsp)
jmp 0x5eb86
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, 0x88(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
leaq 0x80(%rsp), %rsi
callq 0xa370
movq 0x80(%rsp), %rdi
cmpq %r15, %rdi
je 0x5ebc3
callq 0xa2b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5ebd7
callq 0xa2b0
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
movq 0x58(%rsp), %r14
je 0x5ebeb
callq 0xa2b0
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x60(%rsp), %rdi
callq 0xde0c
cmpq $0x0, 0x10(%r14)
je 0x5ec5e
movq %r14, %rdi
leaq 0x60(%rsp), %rsi
callq *0x18(%r14)
movl %eax, %r13d
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x5ec33
callq 0xa2b0
incl %r12d
testb %r13b, %r13b
leaq 0x18(%rsp), %r13
leaq 0x8(%rsp), %r15
je 0x5ea18
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xa140
movl $0x38, %edi
callq 0xa1b0
movq %rax, %r15
leaq 0xe8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x1d62b(%rip), %rsi     # 0x7c2af
leaq 0x1d645(%rip), %rdx     # 0x7c2d0
leaq 0xd8(%rsp), %rdi
callq 0xdfa8
xorps %xmm0, %xmm0
leaq 0xc0(%rsp), %rcx
movaps %xmm0, (%rcx)
movb $0x1, %bpl
leaq 0xd8(%rsp), %rsi
movq %r15, %rdi
movl $0x3, %edx
callq 0x203f4
xorl %ebp, %ebp
leaq 0x38971(%rip), %rsi     # 0x97638
leaq -0x4a1a8(%rip), %rdx    # 0x14b26
movq %r15, %rdi
callq 0xa4f0
callq 0xa140
jmp 0x5ed8e
movq %rax, %r14
movq 0xa0(%rsp), %rdi
cmpq %r12, %rdi
jne 0x5ed87
jmp 0x5ed91
movq %rax, %r14
movq 0xc8(%rsp), %rdi
testq %rdi, %rdi
je 0x5ed0e
callq 0xdce4
movq 0xd8(%rsp), %rdi
cmpq %r12, %rdi
je 0x5ed20
callq 0xa2b0
testb %bpl, %bpl
jne 0x5ed2a
jmp 0x5ed91
movq %rax, %r14
movq %r15, %rdi
callq 0xa240
jmp 0x5ed91
jmp 0x5ed8e
jmp 0x5ed3f
jmp 0x5ed8e
movq %rax, %r14
jmp 0x5ed56
movq %rax, %r14
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x5ed56
callq 0xa2b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
jmp 0x5ed82
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
jne 0x5ed87
jmp 0x5ed91
jmp 0x5ed8e
jmp 0x5ed75
movq %rax, %r14
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x5ed91
callq 0xa2b0
jmp 0x5ed91
movq %rax, %r14
movq (%rbx), %rdi
cmpq 0x50(%rsp), %rdi
je 0x5eda0
callq 0xa2b0
movq %r14, %rdi
callq 0xa510