// File: /workspace/github_cpp_makefile_star2_O2/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 $0x98, %rsp
movl %r8d, 0x4(%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r13
callq 0x71cb
movl $0xc0b090, %edi         # imm = 0xC0B090
callq 0x86c4
movq $0x0, 0x18(%rsp)
leaq 0x60(%rsp), %r12
movq %r13, %r8
xorl %eax, %eax
movq %r13, 0x28(%rsp)
movq (%r8), %r8
cmpq %r13, %r8
je 0x77c4
imull $0x14, %eax, %edx
addl $0x28, %edx
movq 0x6fa9(%rip), %rcx      # 0xe6b8
movl 0x14(%rcx), %esi
addl $-0x32, %esi
xorl %ebx, %ebx
xorl %ecx, %ecx
cmpl %esi, %edx
setg %dl
jg 0x7722
movl %eax, %ebx
movb %dl, %cl
movq 0x18(%rsp), %r13
addl %ecx, %r13d
imull $0x96, %r13d, %r14d
addl $0x1e, %r14d
imull $0x14, %ebx, %r15d
addl $0x28, %r15d
movq %r8, 0x30(%rsp)
leaq 0x10(%r8), %rbp
movq %r12, %rdi
movq %rbp, %rsi
callq 0x7415
movq 0x60(%rsp), %rcx
movq %r13, 0x18(%rsp)
movq %rbx, 0x38(%rsp)
leal (%rbx,%r13), %r8d
addl $0x1f, %r8d
movl %r14d, %edi
movl %r15d, %esi
xorl %edx, %edx
callq 0x4c5a
movl %eax, %r14d
movq %r12, %r15
movq %r12, %rdi
callq 0x3140
testb %r14b, %r14b
je 0x77ab
movq 0x8(%rsp), %rax
movb $0x1, %r14b
movb %r14b, (%rax)
movq (%rbp), %rsi
movq 0x20(%rsp), %rdi
callq 0x3280
movq 0x10(%rsp), %rax
movb %r14b, (%rax)
movq 0x38(%rsp), %rax
incl %eax
movq 0x28(%rsp), %r13
movq %r15, %r12
movq 0x30(%rsp), %r8
jmp 0x76f6
leaq 0x1d2a(%rip), %rcx      # 0x94f5
pushq $0xa
popq %rdi
movl %edi, %esi
xorl %edx, %edx
movl $0x190, %r8d            # imm = 0x190
callq 0x4c5a
testb %al, %al
je 0x77f1
movq 0x8(%rsp), %rax
movb $0x0, (%rax)
movq 0x10(%rsp), %rax
movb $0x1, (%rax)
cmpb $0x0, 0x4(%rsp)
je 0x7908
leaq 0x1cf9(%rip), %rcx      # 0x94fc
pushq $0x78
popq %rdi
pushq $0xa
popq %rsi
xorl %edx, %edx
movl $0x191, %r8d            # imm = 0x191
callq 0x4c5a
testb %al, %al
je 0x7908
leaq 0x1ce0(%rip), %rsi      # 0x9505
leaq 0x40(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x6fea
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x7499
leaq 0x40(%rsp), %rdi
callq 0x3140
leaq 0x1be4(%rip), %rsi      # 0x943b
leaq 0x60(%rsp), %rdi
callq 0x7e27
testb %al, %al
je 0x78fe
leaq 0x60(%rsp), %rdi
callq 0x7468
leaq 0x1c91(%rip), %rsi      # 0x950b
leaq 0x40(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0x6fea
leaq 0x80(%rsp), %rdi
leaq 0x40(%rsp), %rsi
pushq $0x1
popq %rcx
xorl %edx, %edx
callq 0x72ea
leaq 0x80(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x83ec
movq %r14, %rdi
callq 0x7ea4
leaq 0x40(%rsp), %rdi
callq 0x3140
movq (%r13), %r15
leaq 0x1c35(%rip), %r14      # 0x9505
cmpq %r13, %r15
je 0x78fe
leaq 0x10(%r15), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x3530
cmpq $-0x1, %rax
je 0x78ee
movq (%r15), %r15
jmp 0x78d0
movq %r13, %rdi
movq %r15, %rsi
callq 0x7e32
movq %rax, %r15
jmp 0x78d0
leaq 0x60(%rsp), %rdi
callq 0x3140
callq 0x7222
cmpb $0x0, 0x6d98(%rip)      # 0xe6ac
jne 0x7920
leaq 0x599b(%rip), %rax      # 0xd2b8
orl $-0x1, (%rax)
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x3140
jmp 0x7957
jmp 0x7954
jmp 0x7954
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x795c
movq %rax, %rbx
jmp 0x7961
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3140
movq %rbx, %rdi
callq 0x34d0