// File: /workspace/github_cpp_makefile_star2_O3/tjohnman[P]sfxr-sdl2/build/../src/sdlkit.cpp
// Function: DrawFileSelectScreen(std::__cxx11::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, char*, bool&, bool&, bool)
void DrawFileSelectScreen(std::list<std::string>& files, char* buf, bool& gotFile, bool& done, bool showNewButton)
{
	using namespace std;

	ddkLock();

	ClearScreen(0xC0B090);

	
	int i = 0, j = 0;
	for(list<string>::iterator e = files.begin(); e != files.end(); e++)
	{
		if(40 + 20*i > sdlscreen->h - 50)
		{
			j++;
			i = 0;
		}
		if(Button(30 + 150*j, 40 + 20*i, false, stoupper(*e).c_str(), 31 + i + j))
		{
			gotFile = true;
			sprintf(buf, "%s", e->c_str());
			done = true;
		}
		i++;
	}
	
	if(Button(10, 10, false, "CANCEL", 400))
	{
		gotFile = false;
		done = true;
	}
	
	if(showNewButton && Button(120, 10, false, "NEW FILE", 401))
	{
		string s = new_file(".sfxr");
		if(s != "")
		{
			ioNew(s);
			files = ioList(".", false, true);
			
			for(list<string>::iterator e = files.begin(); e != files.end();)
			{
				if(e->find(".sfxr") == string::npos)
				{
					e = files.erase(e);
					continue;
				}
				
				e++;
			}
		}
	}

	ddkUnlock();

	if(!mouse_left)
		vcurbutton=-1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %r8d, 0x14(%rsp)
movq %rcx, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rsi, 0x68(%rsp)
movq %rdi, %rbx
callq 0x7921
movl $0xc0b090, %edi         # imm = 0xC0B090
callq 0x8f82
movq (%rbx), %r12
movq %rbx, 0x8(%rsp)
cmpq %rbx, %r12
je 0x80eb
xorl %eax, %eax
xorl %r13d, %r13d
leal (%rax,%rax,4), %ecx
leal 0x28(,%rcx,4), %edx
movq 0x6662(%rip), %rcx      # 0xe698
movl 0x14(%rcx), %esi
addl $-0x32, %esi
xorl %ecx, %ecx
movl $0x0, %ebx
cmpl %esi, %edx
setg %dl
jg 0x804c
movl %eax, %ebx
movb %dl, %cl
addl %ecx, %r13d
imull $0x96, %r13d, %r14d
addl $0x1e, %r14d
leal (%rbx,%rbx,4), %eax
leal 0x28(,%rax,4), %r15d
leaq 0x10(%r12), %rbp
leaq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x7c94
movq 0x18(%rsp), %rcx
leal (%rbx,%r13), %r8d
addl $0x1f, %r8d
movl %r14d, %edi
movl %r15d, %esi
xorl %edx, %edx
callq 0x3e96
movl %eax, %r14d
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x80b2
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x22a0
testb %r14b, %r14b
je 0x80d8
movq 0x58(%rsp), %rax
movb $0x1, %r14b
movb %r14b, (%rax)
movq (%rbp), %rsi
movq 0x68(%rsp), %rdi
callq 0x2250
movq 0x60(%rsp), %rax
movb %r14b, (%rax)
incl %ebx
movq (%r12), %r12
movl %ebx, %eax
cmpq 0x8(%rsp), %r12
jne 0x8025
leaq 0x2413(%rip), %rcx      # 0xa505
movl $0xa, %edi
movl $0xa, %esi
xorl %edx, %edx
movl $0x190, %r8d            # imm = 0x190
callq 0x3e96
testb %al, %al
je 0x811d
movq 0x58(%rsp), %rax
movb $0x0, (%rax)
movq 0x60(%rsp), %rax
movb $0x1, (%rax)
cmpb $0x0, 0x14(%rsp)
je 0x827c
leaq 0x23dd(%rip), %rcx      # 0xa50c
movl $0x78, %edi
movl $0xa, %esi
xorl %edx, %edx
movl $0x191, %r8d            # imm = 0x191
callq 0x3e96
testb %al, %al
je 0x827c
leaq 0x48(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x23b7(%rip), %rsi      # 0xa515
leaq 0x23b5(%rip), %rdx      # 0xa51a
leaq 0x38(%rsp), %rdi
callq 0x7778
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x7d41
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x8195
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x22a0
leaq 0x22af(%rip), %rsi      # 0xa44b
leaq 0x18(%rsp), %rdi
callq 0x20e0
testl %eax, %eax
je 0x8261
leaq 0x18(%rsp), %rdi
callq 0x7cfe
leaq 0x38(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x2354(%rip), %rsi      # 0xa51b
leaq 0x234e(%rip), %rdx      # 0xa51c
callq 0x7778
leaq 0x70(%rsp), %rdi
leaq 0x38(%rsp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x7a48
leaq 0x70(%rsp), %r14
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x8c8e
movq %r14, %rdi
callq 0x8904
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x821a
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x22a0
movq 0x8(%rsp), %rax
movq (%rax), %r15
cmpq %rax, %r15
je 0x8261
leaq 0x22e7(%rip), %r14      # 0xa515
leaq 0x10(%r15), %rdi
movl $0x5, %ecx
movq %r14, %rsi
xorl %edx, %edx
callq 0x2470
movq (%r15), %rbx
cmpq $-0x1, %rax
jne 0x8257
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x8cf4
movq %rbx, %r15
cmpq 0x8(%rsp), %rbx
jne 0x822e
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x827c
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x22a0
movq 0x6415(%rip), %rdi      # 0xe698
testb $0x2, (%rdi)
je 0x828d
callq 0x2390
cmpb $0x0, 0x63f8(%rip)      # 0xe68c
jne 0x82a3
leaq 0x4ff3(%rip), %rax      # 0xd290
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x82d4
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x22a0
jmp 0x82d4
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x8305
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x8317
movq 0x48(%rsp), %rsi
jmp 0x830f
movq %rax, %rbx
jmp 0x8317
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x8317
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x22a0
movq %rbx, %rdi
callq 0x24a0