// File: 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
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movb %r8b, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
callq 0x89b0
movl $0xc0b090, %edi         # imm = 0xC0B090
callq 0xcc80
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa100
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa250
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xa220
testb $0x1, %al
jne 0x9310
jmp 0x9448
imull $0x14, -0x28(%rbp), %eax
addl $0x28, %eax
movq 0xb40a(%rip), %rcx      # 0x14728
movl 0x14(%rcx), %ecx
subl $0x32, %ecx
cmpl %ecx, %eax
jle 0x9338
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x2c(%rbp), %eax
imull $0x96, %eax, %eax
addl $0x1e, %eax
movl %eax, -0x134(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, %eax
leal (%rax,%rax,4), %ecx
movl %ecx, %eax
leal 0x28(,%rax,4), %eax
movl %eax, -0x130(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xa280
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x8e60
movq -0x140(%rbp), %rdi
callq 0x3120
movl -0x134(%rbp), %edi
movl -0x130(%rbp), %esi
movq %rax, %rcx
movl -0x28(%rbp), %r8d
movl -0x2c(%rbp), %eax
movl %eax, %edx
movl %r8d, %eax
leal 0x1f(%rax,%rdx), %r8d
xorl %edx, %edx
callq 0x56f0
movb %al, -0x129(%rbp)
jmp 0x93b8
leaq -0x60(%rbp), %rdi
callq 0x31e0
movb -0x129(%rbp), %al
testb $0x1, %al
jne 0x93cd
jmp 0x942b
movq -0x18(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xa2a0
movq %rax, %rdi
callq 0x3120
movq -0x148(%rbp), %rdi
movq %rax, %rdx
leaq 0x50d9(%rip), %rsi      # 0xe4da
movb $0x0, %al
callq 0x30c0
movq -0x20(%rbp), %rax
movb $0x1, (%rax)
jmp 0x942b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x31e0
jmp 0x9740
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
callq 0xa2c0
movq %rax, -0x78(%rbp)
jmp 0x92ed
movl $0xa, %esi
xorl %edx, %edx
leaq 0x5087(%rip), %rcx      # 0xe4dd
movl $0x190, %r8d            # imm = 0x190
movl %esi, %edi
callq 0x56f0
testb $0x1, %al
jne 0x9469
jmp 0x9477
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x20(%rbp), %rax
movb $0x1, (%rax)
testb $0x1, -0x21(%rbp)
je 0x971c
movl $0x78, %edi
movl $0xa, %esi
xorl %edx, %edx
leaq 0x5050(%rip), %rcx      # 0xe4e4
movl $0x191, %r8d            # imm = 0x191
callq 0x56f0
testb $0x1, %al
jne 0x94a8
jmp 0x971c
leaq -0xb9(%rbp), %rdi
movq %rdi, -0x150(%rbp)
callq 0x35d0
movq -0x150(%rbp), %rdx
leaq 0x5024(%rip), %rsi      # 0xe4ed
leaq -0xb8(%rbp), %rdi
callq 0x84b0
jmp 0x94d7
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x8fa0
jmp 0x94ec
leaq -0xb8(%rbp), %rdi
callq 0x31e0
leaq -0xb9(%rbp), %rdi
callq 0x33b0
leaq 0x4f10(%rip), %rsi      # 0xe41b
leaq -0x98(%rbp), %rdi
callq 0xa2f0
movb %al, -0x151(%rbp)
jmp 0x951f
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x952e
jmp 0x9700
leaq -0x98(%rbp), %rdi
callq 0x8f30
jmp 0x953c
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x160(%rbp)
callq 0x35d0
movq -0x160(%rbp), %rdx
leaq 0x4f96(%rip), %rsi      # 0xe4f3
leaq -0xf8(%rbp), %rdi
callq 0x84b0
jmp 0x956b
leaq -0xd8(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x8b90
jmp 0x9587
movq -0x8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0xa320
leaq -0xd8(%rbp), %rdi
callq 0xa150
leaq -0xf8(%rbp), %rdi
callq 0x31e0
leaq -0xf9(%rbp), %rdi
callq 0x33b0
movq -0x8(%rbp), %rdi
callq 0xa100
movq %rax, -0x108(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa250
movq %rax, -0x110(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xa220
testb $0x1, %al
jne 0x95f7
jmp 0x96fe
leaq -0x108(%rbp), %rdi
callq 0xa2a0
movq %rax, %rdi
leaq 0x4ee0(%rip), %rsi      # 0xe4ed
xorl %eax, %eax
movl %eax, %edx
callq 0x3630
cmpq $-0x1, %rax
jne 0x96e4
movq -0x8(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xa130
movq -0x168(%rbp), %rdi
movq -0x120(%rbp), %rsi
callq 0xa350
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
movq %rax, -0x108(%rbp)
jmp 0x95cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x9691
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x31e0
leaq -0xb9(%rbp), %rdi
callq 0x33b0
jmp 0x9740
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x970e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x96d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x31e0
leaq -0xf9(%rbp), %rdi
callq 0x33b0
jmp 0x970e
leaq -0x108(%rbp), %rdi
xorl %esi, %esi
callq 0xa2c0
movq %rax, -0x128(%rbp)
jmp 0x95cb
jmp 0x9700
leaq -0x98(%rbp), %rdi
callq 0x31e0
jmp 0x971c
leaq -0x98(%rbp), %rdi
callq 0x31e0
jmp 0x9740
callq 0x8a50
testb $0x1, 0xaff4(%rip)      # 0x1471c
jne 0x9737
leaq 0x9c07(%rip), %rax      # 0x13338
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x35c0
nopl (%rax)