// File: /workspace/github_cpp_makefile_star2_O3/magmastonealex[P]fbkeyboard/src/fbkeyboard.cpp
// Function: run(int, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool)
int run(int width, int height, int dpi, std::string fbdev, std::string tsdev, std::string prompt, bool password) {

	std::string kbfile = "tst.ppm";

  	Display screen(width, height, dpi);
  	screen.setString(prompt);
  	screen.refresh();
  	screen.write("out.ppm");
  	system((std::string("fbsplash -s out.ppm -d ") + fbdev).c_str());
  	std::string todisplay = "";
  	std::string toreturn = "";
  	Input inputSource(tsdev);
	while(1) {
		Touch t = inputSource.getNextEvent();
		char touched = screen.keyAt(t.x, t.y);
		switch(touched) {
			case 0:
				break;
			case 0x08:
				if(toreturn.length() > 0)
					toreturn.pop_back();
				break;
			case 0x0a:
				std::cout << toreturn << std::endl;
				return 0;
				break;
			default:
				toreturn += touched;
				if(password)
					todisplay += (char)0x05;
				else
					todisplay += touched;
				break;
		}
	  	screen.setString(toreturn);
	  	screen.refresh();
	  	screen.write("out.ppm");
	  	system("fbsplash -s out.ppm -d /dev/fb0");
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3f8, %rsp            # imm = 0x3F8
movq %r9, %r15
movq %r8, %rbx
movq %rcx, %r14
movl %edx, %ebp
movl %esi, %r12d
movl %edi, %r13d
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xa18(%rip), %rsi       # 0x419b
leaq 0xa18(%rip), %rdx       # 0x41a2
leaq 0x40(%rsp), %rdi
callq 0x3de0
leaq 0x100(%rsp), %rdi
movl %r13d, %esi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x242c
leaq 0xf0(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq 0xe0(%rsp), %rdi
callq 0x3d4a
leaq 0x100(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x2f8c
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x37ff
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x100(%rsp), %rdi
callq 0x2cf0
leaq 0xd0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x984(%rip), %rsi       # 0x41a3
leaq 0x984(%rip), %rdx       # 0x41aa
leaq 0xc0(%rsp), %rdi
callq 0x3de0
leaq 0x100(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x2650
movq 0xc0(%rsp), %rdi
cmpq %r15, %rdi
je 0x3865
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x936(%rip), %rsi       # 0x41ab
leaq 0x946(%rip), %rdx       # 0x41c2
movq %rsp, %rdi
callq 0x3de0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rsp, %rdi
callq 0x20a0
leaq 0x200(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x38c3
movq %rdx, 0x1f0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x200(%rsp)
jmp 0x38ca
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, 0x1f8(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x1f0(%rsp), %rdi
callq 0x2150
movq 0x1f0(%rsp), %rdi
cmpq %r14, %rdi
je 0x390f
movq 0x200(%rsp), %rsi
incq %rsi
callq 0x21a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x392a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x758(%rip), %rdx       # 0x4094
movq %rdx, %rsi
callq 0x3de0
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x740(%rip), %rdx       # 0x4094
leaq 0x20(%rsp), %rdi
movq %rdx, %rsi
callq 0x3de0
leaq 0xb0(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0x3d4a
leaq 0x1f0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x3004
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x39b6
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x90(%rsp), %r12
leaq 0x70(%rsp), %r13
leaq 0x100(%rsp), %r14
leaq 0x80(%rsp), %r15
leaq 0x60(%rsp), %rbp
leaq 0x1f0(%rsp), %rdi
callq 0x3088
movq %rax, %rdx
shrq $0x20, %rdx
movq %r14, %rdi
movl %eax, %esi
callq 0x2b8a
testb %al, %al
je 0x3a47
movzbl %al, %ebx
cmpl $0x8, %ebx
je 0x3a35
cmpl $0xa, %ebx
je 0x3ae2
movsbl %al, %esi
leaq 0x20(%rsp), %rdi
callq 0x2160
cmpb $0x0, 0x430(%rsp)
movl $0x5, %eax
cmovnel %eax, %ebx
movsbl %bl, %esi
movq %rsp, %rdi
callq 0x2160
jmp 0x3a47
cmpq $0x0, 0x28(%rsp)
je 0x3a47
leaq 0x20(%rsp), %rdi
callq 0x21e0
movq %r12, 0x80(%rsp)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x3d4a
movq %r14, %rdi
movq %r15, %rsi
callq 0x2f8c
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0x3a8c
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %r14, %rdi
callq 0x2cf0
movq %r13, 0x60(%rsp)
movq %rbp, %rdi
leaq 0x700(%rip), %rsi       # 0x41a3
leaq 0x700(%rip), %rdx       # 0x41aa
callq 0x3de0
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2650
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x3ad1
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x6eb(%rip), %rdi       # 0x41c3
callq 0x2150
jmp 0x39d8
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x24d5(%rip), %rdi      # 0x5fc8
callq 0x21c0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
leaq 0x1f0(%rsp), %rdi
callq 0x3068
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3b4b
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3b66
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x100(%rsp), %rdi
callq 0x2610
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x3b8f
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21a0
xorl %eax, %eax
addq $0x3f8, %rsp            # imm = 0x3F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3ca3
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3ca3
movq %rax, %rbx
jmp 0x3ca3
jmp 0x3bf9
jmp 0x3c4f
movq %rax, %rbx
movq 0x1f0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3cbf
movq 0x200(%rsp), %rsi
jmp 0x3cb7
movq %rax, %rbx
jmp 0x3cbf
jmp 0x3c4f
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r15, %rdi
je 0x3cda
movq 0xd0(%rsp), %rsi
jmp 0x3cd2
jmp 0x3c4f
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x3cda
movq 0xf0(%rsp), %rsi
jmp 0x3cd2
movq %rax, %rbx
jmp 0x3ce7
movq %rax, %rbx
jmp 0x3cda
jmp 0x3c93
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0x3c96
movq 0x90(%rsp), %rsi
jmp 0x3c85
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x3c96
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3c96
jmp 0x3c93
jmp 0x3c93
movq %rax, %rbx
leaq 0x1f0(%rsp), %rdi
callq 0x3068
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3cbf
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3cda
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x100(%rsp), %rdi
callq 0x2610
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x3d03
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x2280
nop