// File: /workspace/github_cpp_makefile_star2_O2/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 $0x408, %rsp            # imm = 0x408
movq %r9, %r15
movq %r8, %rbx
movq %rcx, %r14
movl %edx, %ebp
movl %esi, %r12d
movl %edi, %r13d
leaq 0xf70(%rip), %rsi       # 0x419b
leaq 0xb0(%rsp), %rdi
leaq 0x200(%rsp), %rdx
callq 0x359a
leaq 0x110(%rsp), %rdi
movl %r13d, %esi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x242c
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq 0x21f0
leaq 0x110(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x2cb4
leaq 0x90(%rsp), %rdi
callq 0x20b0
leaq 0x110(%rsp), %rdi
callq 0x2a80
leaq 0xf08(%rip), %rsi       # 0x41a3
leaq 0x70(%rsp), %rdi
leaq 0x200(%rsp), %rdx
callq 0x359a
leaq 0x110(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x2602
leaq 0x70(%rsp), %rdi
callq 0x20b0
leaq 0xedb(%rip), %rsi       # 0x41ab
leaq 0x10(%rsp), %rdi
leaq 0x30(%rsp), %rdx
callq 0x359a
leaq 0x200(%rsp), %rdi
leaq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x35d5
movq 0x200(%rsp), %rdi
callq 0x2120
leaq 0x200(%rsp), %rdi
callq 0x20b0
leaq 0x10(%rsp), %rdi
callq 0x20b0
leaq 0xd75(%rip), %rsi       # 0x4094
leaq 0x10(%rsp), %rdi
leaq 0x200(%rsp), %rdx
callq 0x359a
leaq 0xd5c(%rip), %rsi       # 0x4094
leaq 0x30(%rsp), %rdi
leaq 0x200(%rsp), %rdx
callq 0x359a
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x21f0
leaq 0x200(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x2db0
leaq 0x50(%rsp), %rdi
callq 0x20b0
leaq 0x110(%rsp), %r14
leaq 0xf0(%rsp), %r15
leaq 0x30(%rsp), %r12
leaq 0xd0(%rsp), %rbp
leaq 0xe2c(%rip), %r13       # 0x41c3
leaq 0x200(%rsp), %rdi
callq 0x2e32
movq %rax, %rdx
shrq $0x20, %rdx
movq %r14, %rdi
movl %eax, %esi
callq 0x293e
testb %al, %al
je 0x3402
movzbl %al, %ebx
cmpl $0x8, %ebx
je 0x33f2
cmpl $0xa, %ebx
je 0x345c
movsbl %al, %esi
movq %r12, %rdi
callq 0x2130
cmpb $0x0, 0x440(%rsp)
pushq $0x5
popq %rax
cmovnel %eax, %ebx
movsbl %bl, %esi
leaq 0x10(%rsp), %rdi
callq 0x2130
jmp 0x3402
cmpq $0x0, 0x38(%rsp)
je 0x3402
movq %r12, %rdi
callq 0x21b0
movq %r15, %rdi
movq %r12, %rsi
callq 0x21f0
movq %r14, %rdi
movq %r15, %rsi
callq 0x2cb4
movq %r15, %rdi
callq 0x20b0
movq %r14, %rdi
callq 0x2a80
movq %rbp, %rdi
leaq 0xd71(%rip), %rsi       # 0x41a3
leaq 0xf(%rsp), %rdx
callq 0x359a
movq %r14, %rdi
movq %rbp, %rsi
callq 0x2602
movq %rbp, %rdi
callq 0x20b0
movq %r13, %rdi
callq 0x2120
jmp 0x3397
movq 0x2b5d(%rip), %rdi      # 0x5fc0
leaq 0x30(%rsp), %rsi
callq 0x2150
movq %rax, %rdi
callq 0x20c0
leaq 0x200(%rsp), %rdi
callq 0x2e12
leaq 0x30(%rsp), %rdi
callq 0x20b0
leaq 0x10(%rsp), %rdi
callq 0x20b0
leaq 0x110(%rsp), %rdi
callq 0x25d4
leaq 0xb0(%rsp), %rdi
callq 0x20b0
xorl %eax, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x20b0
jmp 0x3548
movq %rax, %rbx
jmp 0x3548
jmp 0x34e9
jmp 0x3510
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
jmp 0x354d
movq %rax, %rbx
jmp 0x3552
jmp 0x3510
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
jmp 0x3557
jmp 0x3510
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x3557
movq %rax, %rbx
jmp 0x3569
jmp 0x3538
movq %rax, %rbx
jmp 0x355c
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
jmp 0x352d
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x20b0
jmp 0x353b
jmp 0x3538
jmp 0x3538
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
callq 0x2e12
leaq 0x30(%rsp), %rdi
callq 0x20b0
leaq 0x10(%rsp), %rdi
callq 0x20b0
leaq 0x110(%rsp), %rdi
callq 0x25d4
leaq 0xb0(%rsp), %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2260