// File: /workspace/github_cpp_makefile_star2_O1/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 0x7935
movl $0xc0b090, %edi         # imm = 0xC0B090
callq 0x8fce
movq (%rbx), %r12
movq %rbx, 0x8(%rsp)
cmpq %rbx, %r12
je 0x8120
xorl %eax, %eax
xorl %r13d, %r13d
leal (%rax,%rax,4), %ecx
leal 0x28(,%rcx,4), %edx
movq 0x661d(%rip), %rcx      # 0xe688
movl 0x14(%rcx), %esi
addl $-0x32, %esi
xorl %ecx, %ecx
movl $0x0, %ebx
cmpl %esi, %edx
setg %dl
jg 0x8081
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 0x7ca8
movq 0x18(%rsp), %rcx
leal (%rbx,%r13), %r8d
addl $0x1f, %r8d
movl %r14d, %edi
movl %r15d, %esi
xorl %edx, %edx
callq 0x3e90
movl %eax, %r14d
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x80e7
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x22a0
testb %r14b, %r14b
je 0x810d
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 0x805a
leaq 0x23ce(%rip), %rcx      # 0xa4f5
movl $0xa, %edi
movl $0xa, %esi
xorl %edx, %edx
movl $0x190, %r8d            # imm = 0x190
callq 0x3e90
testb %al, %al
je 0x8152
movq 0x58(%rsp), %rax
movb $0x0, (%rax)
movq 0x60(%rsp), %rax
movb $0x1, (%rax)
cmpb $0x0, 0x14(%rsp)
je 0x82b1
leaq 0x2398(%rip), %rcx      # 0xa4fc
movl $0x78, %edi
movl $0xa, %esi
xorl %edx, %edx
movl $0x191, %r8d            # imm = 0x191
callq 0x3e90
testb %al, %al
je 0x82b1
leaq 0x48(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2372(%rip), %rsi      # 0xa505
leaq 0x2370(%rip), %rdx      # 0xa50a
leaq 0x38(%rsp), %rdi
callq 0x7794
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x7d54
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x81ca
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x22a0
leaq 0x226a(%rip), %rsi      # 0xa43b
leaq 0x18(%rsp), %rdi
callq 0x20e0
testl %eax, %eax
je 0x8296
leaq 0x18(%rsp), %rdi
callq 0x7d12
leaq 0x38(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x230f(%rip), %rsi      # 0xa50b
leaq 0x2309(%rip), %rdx      # 0xa50c
callq 0x7794
leaq 0x70(%rsp), %rdi
leaq 0x38(%rsp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x7a5c
leaq 0x70(%rsp), %r14
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x8cd4
movq %r14, %rdi
callq 0x894e
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x824f
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x22a0
movq 0x8(%rsp), %rax
movq (%rax), %r15
cmpq %rax, %r15
je 0x8296
leaq 0x22a2(%rip), %r14      # 0xa505
leaq 0x10(%r15), %rdi
movl $0x5, %ecx
movq %r14, %rsi
xorl %edx, %edx
callq 0x2470
movq (%r15), %rbx
cmpq $-0x1, %rax
jne 0x828c
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x8d3e
movq %rbx, %r15
cmpq 0x8(%rsp), %rbx
jne 0x8263
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x82b1
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x22a0
movq 0x63d0(%rip), %rdi      # 0xe688
testb $0x2, (%rdi)
je 0x82c2
callq 0x2390
cmpb $0x0, 0x63b3(%rip)      # 0xe67c
jne 0x82d8
leaq 0x4fbe(%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 0x8309
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x22a0
jmp 0x8309
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x833a
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0x834c
movq 0x48(%rsp), %rsi
jmp 0x8344
movq %rax, %rbx
jmp 0x834c
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x834c
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x22a0
movq %rbx, %rdi
callq 0x24a0