// File: /workspace/github_cpp_makefile_star2_O1/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 0x960(%rip), %rsi       # 0x419b
leaq 0x960(%rip), %rdx       # 0x41a2
leaq 0x40(%rsp), %rdi
callq 0x3e92
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 0x3e02
leaq 0x100(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x3052
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x38b7
movq 0xf0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x100(%rsp), %rdi
callq 0x2db2
leaq 0xd0(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x8cc(%rip), %rsi       # 0x41a3
leaq 0x8cc(%rip), %rdx       # 0x41aa
leaq 0xc0(%rsp), %rdi
callq 0x3e92
leaq 0x100(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x265a
movq 0xc0(%rsp), %rdi
cmpq %r15, %rdi
je 0x391d
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x87e(%rip), %rsi       # 0x41ab
leaq 0x88e(%rip), %rdx       # 0x41c2
movq %rsp, %rdi
callq 0x3e92
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 0x397b
movq %rdx, 0x1f0(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x200(%rsp)
jmp 0x3982
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 0x39c7
movq 0x200(%rsp), %rsi
incq %rsi
callq 0x21a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x39e2
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rsp, %rdi
leaq 0x10(%rsp), %rax
movq %rax, (%rdi)
leaq 0x6a0(%rip), %rdx       # 0x4094
movq %rdx, %rsi
callq 0x3e92
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x688(%rip), %rdx       # 0x4094
leaq 0x20(%rsp), %rdi
movq %rdx, %rsi
callq 0x3e92
leaq 0xb0(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0x3e02
leaq 0x1f0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x30c8
movq 0xa0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3a6e
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 0x314c
movq %rax, %rdx
shrq $0x20, %rdx
movq %r14, %rdi
movl %eax, %esi
callq 0x2b94
testb %al, %al
je 0x3aff
movzbl %al, %ebx
cmpl $0x8, %ebx
je 0x3aed
cmpl $0xa, %ebx
je 0x3b9a
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 0x3aff
cmpq $0x0, 0x28(%rsp)
je 0x3aff
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 0x3e02
movq %r14, %rdi
movq %r15, %rsi
callq 0x3052
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0x3b44
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %r14, %rdi
callq 0x2db2
movq %r13, 0x60(%rsp)
movq %rbp, %rdi
leaq 0x648(%rip), %rsi       # 0x41a3
leaq 0x648(%rip), %rdx       # 0x41aa
callq 0x3e92
movq %r14, %rdi
movq %rbp, %rsi
callq 0x265a
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x3b89
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
leaq 0x633(%rip), %rdi       # 0x41c3
callq 0x2150
jmp 0x3a90
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x241d(%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 0x312c
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3c03
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3c1e
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 0x3c47
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 0x3d5b
movq 0xb0(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3d5b
movq %rax, %rbx
jmp 0x3d5b
jmp 0x3cb1
jmp 0x3d07
movq %rax, %rbx
movq 0x1f0(%rsp), %rdi
cmpq %r14, %rdi
je 0x3d77
movq 0x200(%rsp), %rsi
jmp 0x3d6f
movq %rax, %rbx
jmp 0x3d77
jmp 0x3d07
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
cmpq %r15, %rdi
je 0x3d92
movq 0xd0(%rsp), %rsi
jmp 0x3d8a
jmp 0x3d07
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
cmpq %r12, %rdi
je 0x3d92
movq 0xf0(%rsp), %rsi
jmp 0x3d8a
movq %rax, %rbx
jmp 0x3d9f
movq %rax, %rbx
jmp 0x3d92
jmp 0x3d4b
movq %rax, %rbx
movq 0x80(%rsp), %rdi
cmpq %r12, %rdi
je 0x3d4e
movq 0x90(%rsp), %rsi
jmp 0x3d3d
movq %rax, %rbx
movq 0x60(%rsp), %rdi
cmpq %r13, %rdi
je 0x3d4e
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x21a0
jmp 0x3d4e
jmp 0x3d4b
jmp 0x3d4b
movq %rax, %rbx
leaq 0x1f0(%rsp), %rdi
callq 0x312c
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3d77
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21a0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3d92
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 0x3dbb
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x2280
nop