// File: menhits[P]phplus/src/utils/stringUtils.cpp
// Function: str::tabsToSpaces(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)
string tabsToSpaces(const string& in, int tabWidth)
{
	int widthSinceNewline=0;
	string out;
	int bytePos=0;
	int start=0;
	
	while (bytePos<(int)in.size())
	{
		if (subMatches(in, bytePos, "\t"))
		{
			out+=in.substr(start, bytePos-start);
			string spacer;
			int spaces=tabWidth-(widthSinceNewline%tabWidth);
			for (int i=0; i<spaces; i++)
				spacer+=" ";
			out+=spacer;
			widthSinceNewline+=spaces;
			nextGlyph(bytePos, in);
			start=bytePos;
		}
		else
		{
			widthSinceNewline++;
			if (subMatches(in, bytePos, "\n"))
			{
				widthSinceNewline=0;
			}
			nextGlyph(bytePos, in);
		}
	}
	
	out+=in.substr(start, bytePos-start);
	
	return out;
}

// Assembly:
subq $0x148, %rsp            # imm = 0x148
movq %rdi, 0x48(%rsp)
movq %rdi, %rax
movq %rax, 0x50(%rsp)
movq %rdi, 0x140(%rsp)
movq %rsi, 0x138(%rsp)
movl %edx, 0x134(%rsp)
movl $0x0, 0x130(%rsp)
movb $0x0, 0x12f(%rsp)
callq 0xb4e0
movl $0x0, 0x128(%rsp)
movl $0x0, 0x124(%rsp)
movl 0x128(%rsp), %eax
movl %eax, 0x44(%rsp)
movq 0x138(%rsp), %rdi
callq 0xb2a0
movq %rax, %rcx
movl 0x44(%rsp), %eax
cmpl %ecx, %eax
jge 0xd0c14
movq 0x138(%rsp), %rax
movq %rax, 0x28(%rsp)
movl 0x128(%rsp), %eax
movl %eax, 0x34(%rsp)
leaq 0xff(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0xb690
movq 0x38(%rsp), %rdx
leaq 0x1138(%rip), %rsi      # 0xd1a1e
leaq 0x100(%rsp), %rdi
callq 0xb4c0
jmp 0xd08f5
movl 0x34(%rsp), %esi
movq 0x28(%rsp), %rdi
leaq 0x100(%rsp), %rdx
callq 0x9e650
movb %al, 0x27(%rsp)
jmp 0xd0911
leaq 0x100(%rsp), %rdi
callq 0xb6e8
leaq 0xff(%rsp), %rdi
callq 0xb3f0
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0xd0938
jmp 0xd0b14
movq 0x138(%rsp), %rsi
movslq 0x124(%rsp), %rdx
movl %edx, %ecx
movl 0x128(%rsp), %eax
subl %ecx, %eax
movslq %eax, %rcx
leaq 0xc8(%rsp), %rdi
callq 0xb3a0
jmp 0xd0965
movq 0x48(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xb470
jmp 0xd0979
leaq 0xc8(%rsp), %rdi
callq 0xb6e8
leaq 0xa8(%rsp), %rdi
callq 0xb4e0
movl 0x134(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x130(%rsp), %eax
cltd
idivl 0x134(%rsp)
movl 0x20(%rsp), %eax
subl %edx, %eax
movl %eax, 0xa4(%rsp)
movl $0x0, 0xa0(%rsp)
movl 0xa0(%rsp), %eax
cmpl 0xa4(%rsp), %eax
jge 0xd0ab2
leaq 0x108c(%rip), %rsi      # 0xd1a6c
leaq 0xa8(%rsp), %rdi
callq 0xb360
jmp 0xd09ef
jmp 0xd09f1
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
jmp 0xd09c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xd0a3b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x100(%rsp), %rdi
callq 0xb6e8
leaq 0xff(%rsp), %rdi
callq 0xb3f0
jmp 0xd0ca4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xd0ca4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0xb6e8
jmp 0xd0ca4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xb6e8
jmp 0xd0ca4
movq 0x48(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xb470
jmp 0xd0ac6
movl 0xa4(%rsp), %ecx
movl 0x130(%rsp), %eax
addl %ecx, %eax
movl %eax, 0x130(%rsp)
movq 0x138(%rsp), %rsi
leaq 0x128(%rsp), %rdi
callq 0xc8050
jmp 0xd0af4
movl 0x128(%rsp), %eax
movl %eax, 0x124(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xb6e8
jmp 0xd0c0f
movl 0x130(%rsp), %eax
incl %eax
movl %eax, 0x130(%rsp)
movq 0x138(%rsp), %rax
movq %rax, 0x8(%rsp)
movl 0x128(%rsp), %eax
movl %eax, 0x14(%rsp)
leaq 0x7f(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0xb690
movq 0x18(%rsp), %rdx
leaq 0x13a1(%rip), %rsi      # 0xd1ef8
leaq 0x80(%rsp), %rdi
callq 0xb4c0
jmp 0xd0b66
movl 0x14(%rsp), %esi
movq 0x8(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x9e650
movb %al, 0x7(%rsp)
jmp 0xd0b82
leaq 0x80(%rsp), %rdi
callq 0xb6e8
leaq 0x7f(%rsp), %rdi
callq 0xb3f0
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0xd0ba3
jmp 0xd0bf6
movl $0x0, 0x130(%rsp)
jmp 0xd0bf6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xd0be7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x80(%rsp), %rdi
callq 0xb6e8
leaq 0x7f(%rsp), %rdi
callq 0xb3f0
jmp 0xd0ca4
movq 0x138(%rsp), %rsi
leaq 0x128(%rsp), %rdi
callq 0xc8050
jmp 0xd0c0d
jmp 0xd0c0f
jmp 0xd0889
movq 0x138(%rsp), %rsi
movslq 0x124(%rsp), %rdx
movl %edx, %ecx
movl 0x128(%rsp), %eax
subl %ecx, %eax
movslq %eax, %rcx
leaq 0x58(%rsp), %rdi
callq 0xb3a0
jmp 0xd0c3e
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0xb470
jmp 0xd0c4f
leaq 0x58(%rsp), %rdi
callq 0xb6e8
movb $0x1, 0x12f(%rsp)
testb $0x1, 0x12f(%rsp)
jne 0xd0c97
jmp 0xd0c8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x58(%rsp), %rdi
callq 0xb6e8
jmp 0xd0ca4
movq 0x48(%rsp), %rdi
callq 0xb6e8
movq 0x50(%rsp), %rax
addq $0x148, %rsp            # imm = 0x148
retq
movq 0x48(%rsp), %rdi
callq 0xb6e8
movq 0xf0(%rsp), %rdi
callq 0xb680
nopl (%rax,%rax)