// File: tjohnman[P]sfxr-sdl2/build/../src/sdlkit.cpp
// Function: new_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
std::string new_file(const std::string& forced_extension)
{
	using namespace std;
	
	string result;
	
	bool done = false;
	SDL_Event e;
	while (!done)
	{
		while(SDL_PollEvent(&e))
		{
			switch (e.type)
			{
				case SDL_QUIT:
					exit(0);
		
				case SDL_KEYDOWN:
					if(e.key.keysym.sym == SDLK_ESCAPE)
					{
						return "";
					}
					if(e.key.keysym.sym == SDLK_RETURN)
					{
						done = true;
						break;
					}
					
					{
						SDL_Keycode c = e.key.keysym.sym;
						if(0x21 <= c && c <= 0x7E)
							result += e.key.keysym.sym;
					}
		
				default: break;
			}
		}
		sdlupdate();
		
		ClearScreen(0xC0B090);
		
		DrawText(font, 90, 150, 0x000000, "TYPE NEW FILE NAME:");
		DrawText(font, 100, 200, 0x000000, "%s", stoupper(result).c_str());

		SDL_Delay(5);
	
		SDL_UpdateWindowSurface(window);
	}
	
	//if(result.size() == 0)
	//	throw runtime_error("New file name is empty string.");
	
	if(result.size() < 6 || result.substr(result.size()-1 - 4, string::npos) != forced_extension)
		result += forced_extension;
	
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0xe0(%rbp)
movq %rdi, %rax
movq %rax, -0xd8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x34b0
movb $0x0, -0x31(%rbp)
movb -0x31(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x8fdf
jmp 0x91a8
jmp 0x8fe1
leaq -0x70(%rbp), %rdi
callq 0x31d0
movl %eax, -0xe4(%rbp)
jmp 0x8ff2
movl -0xe4(%rbp), %eax
cmpl $0x0, %eax
je 0x90e6
movl -0x70(%rbp), %eax
movl %eax, -0xe8(%rbp)
subl $0x100, %eax            # imm = 0x100
je 0x9036
jmp 0x9013
movl -0xe8(%rbp), %eax
subl $0x300, %eax            # imm = 0x300
je 0x903d
jmp 0x90df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x928c
xorl %edi, %edi
callq 0x3430
cmpl $0x1b, -0x5c(%rbp)
jne 0x90a1
leaq -0x7d(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x35d0
movq -0xe0(%rbp), %rdi
movq -0xf0(%rbp), %rdx
leaq 0x53b3(%rip), %rsi      # 0xe41b
callq 0x84b0
jmp 0x906f
leaq -0x7d(%rbp), %rdi
callq 0x33b0
movl $0x1, -0x84(%rbp)
jmp 0x9273
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x7d(%rbp), %rdi
callq 0x33b0
jmp 0x928c
cmpl $0xd, -0x5c(%rbp)
jne 0x90ad
movb $0x1, -0x31(%rbp)
jmp 0x90e1
movl -0x5c(%rbp), %eax
movl %eax, -0x88(%rbp)
movl $0x21, %eax
cmpl -0x88(%rbp), %eax
jg 0x90dd
cmpl $0x7e, -0x88(%rbp)
jg 0x90dd
movsbl -0x5c(%rbp), %esi
leaq -0x30(%rbp), %rdi
callq 0x31f0
jmp 0x90db
jmp 0x90dd
jmp 0x90df
jmp 0x90e1
jmp 0x8fe1
callq 0x88b0
jmp 0x90ed
movl $0xc0b090, %edi         # imm = 0xC0B090
callq 0xcc80
jmp 0x90f9
leaq 0xa268(%rip), %rdi      # 0x13368
leaq 0x53bf(%rip), %r8       # 0xe4c6
xorl %ecx, %ecx
movb %cl, %al
movl $0x5a, %esi
movl $0x96, %edx
callq 0xd150
jmp 0x911c
leaq -0xa8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x8e60
jmp 0x912e
leaq -0xa8(%rbp), %rdi
callq 0x3120
movq %rax, %r9
leaq 0xa224(%rip), %rdi      # 0x13368
leaq 0x538f(%rip), %r8       # 0xe4da
xorl %ecx, %ecx
movb %cl, %al
movl $0x64, %esi
movl $0xc8, %edx
callq 0xd150
jmp 0x9160
leaq -0xa8(%rbp), %rdi
callq 0x31e0
movl $0x5, %edi
callq 0x3240
jmp 0x9178
movq 0xb5b1(%rip), %rdi      # 0x14730
callq 0x33f0
jmp 0x9186
jmp 0x8fd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x31e0
jmp 0x928c
leaq -0x30(%rbp), %rdi
callq 0x3220
movq %rax, %rcx
movb $0x0, -0xc9(%rbp)
movb $0x1, %al
cmpq $0x6, %rcx
movb %al, -0xf1(%rbp)
jb 0x9219
leaq -0x30(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x3220
movq -0x100(%rbp), %rsi
movq %rax, %rdx
addq $-0x5, %rdx
leaq -0xc8(%rbp), %rdi
movq $-0x1, %rcx
callq 0x3370
jmp 0x91fc
movb $0x1, -0xc9(%rbp)
movq -0x10(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0xa1f0
movb %al, -0xf1(%rbp)
movb -0xf1(%rbp), %al
movb %al, -0x101(%rbp)
testb $0x1, -0xc9(%rbp)
jne 0x9230
jmp 0x923c
leaq -0xc8(%rbp), %rdi
callq 0x31e0
movb -0x101(%rbp), %al
testb $0x1, %al
jne 0x9248
jmp 0x9259
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x3450
jmp 0x9257
jmp 0x9259
movq -0xe0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x31c0
movl $0x1, -0x84(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x31e0
movq -0xd8(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x31e0
movq -0x78(%rbp), %rdi
callq 0x35c0
nop