// File: /workspace/github_c_makefile_star2_O0/calmopyrin[P]tedplay/main.cpp
// Function: loop()
static void loop()
{
	char c;
	int quit = 0;

	do {
		SDL_Delay(50);
		c = getchar();
		switch (c) {
			default:
				if (isalpha(c)) {
					cerr << "Unknown command!" << endl;
					cerr << "Valid commands are:" << endl;
				} else
					break;
			case 'h':
			case '?':
				cerr << "1\t toggle channel 1" << endl;
				cerr << "2\t toggle channel 2" << endl;
				cerr << "3\t toggle channel 3" << endl;
				cerr << "b\t skip back one track" << endl;
				cerr << "f\t skip forward one track" << endl;
				cerr << "h or ?\t this help" << endl;
				cerr << "i\t print info" << endl;
				cerr << "p\t toggle pause/resume" << endl;
				cerr << "q or x\t quit tedplay" << endl;
				break;

			case '1':
			case '2':
			case '3':
				tedPlayChannelEnable(c - '1', !tedPlayIsChannelEnabled(c - '1'));
				cerr << "Channel " << int(c - '0') << (tedPlayIsChannelEnabled(c - '0') ? " enabled." : " muted.") << endl;
				break;
			case 'b':
				psidChangeTrack(-1);
				cout << "Playing track #" << int(getPsidHeader().current) << endl;
				break;
			case 'f':
				psidChangeTrack(+1);
				cout << "Playing track #" << int(getPsidHeader().current) << endl;
				break;
			case 'i':
				printPsidInfo(getPsidHeader());
				if (!player->isPaused())
					cerr << "Playing track #" << int(getPsidHeader().current) << endl;
				break;
			case 'p':
				if (!player->isPaused()) {
					player->pause();
					cerr << "Player suspended." << endl;
				} else {
					player->play();
					cerr << "Player resumed." << endl;
				}
				break;
			case 's':
				break;
			case 'x':
			case 'q':
				cerr << "Exiting." << endl;
				quit = 1;
				break;
		}
	} while(!quit && c != EOF);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x8(%rbp)
movl $0x32, %edi
callq 0x3180
callq 0x3370
movb %al, -0x1(%rbp)
movsbl -0x1(%rbp), %eax
addl $-0x31, %eax
movl %eax, %ecx
movq %rcx, -0x10(%rbp)
subl $0x47, %eax
ja 0x1a937
movq -0x10(%rbp), %rax
leaq 0x4fe2(%rip), %rcx      # 0x1f910
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsbl -0x1(%rbp), %edi
callq 0x33d0
cmpl $0x0, %eax
je 0x1a98b
movq 0x96a4(%rip), %rdi      # 0x23ff0
leaq 0x5152(%rip), %rsi      # 0x1faa5
callq 0x3250
movq %rax, %rdi
movq 0x9656(%rip), %rsi      # 0x23fb8
callq 0x3290
movq 0x9682(%rip), %rdi      # 0x23ff0
leaq 0x5141(%rip), %rsi      # 0x1fab6
callq 0x3250
movq %rax, %rdi
movq 0x9634(%rip), %rsi      # 0x23fb8
callq 0x3290
jmp 0x1a990
jmp 0x1ace0
jmp 0x1a992
movq 0x9657(%rip), %rdi      # 0x23ff0
leaq 0x512a(%rip), %rsi      # 0x1faca
callq 0x3250
movq %rax, %rdi
movq 0x9609(%rip), %rsi      # 0x23fb8
callq 0x3290
movq 0x9635(%rip), %rdi      # 0x23ff0
leaq 0x511c(%rip), %rsi      # 0x1fade
callq 0x3250
movq %rax, %rdi
movq 0x95e7(%rip), %rsi      # 0x23fb8
callq 0x3290
movq 0x9613(%rip), %rdi      # 0x23ff0
leaq 0x510e(%rip), %rsi      # 0x1faf2
callq 0x3250
movq %rax, %rdi
movq 0x95c5(%rip), %rsi      # 0x23fb8
callq 0x3290
movq 0x95f1(%rip), %rdi      # 0x23ff0
leaq 0x5100(%rip), %rsi      # 0x1fb06
callq 0x3250
movq %rax, %rdi
movq 0x95a3(%rip), %rsi      # 0x23fb8
callq 0x3290
movq 0x95cf(%rip), %rdi      # 0x23ff0
leaq 0x50f5(%rip), %rsi      # 0x1fb1d
callq 0x3250
movq %rax, %rdi
movq 0x9581(%rip), %rsi      # 0x23fb8
callq 0x3290
movq 0x95ad(%rip), %rdi      # 0x23ff0
leaq 0x50ed(%rip), %rsi      # 0x1fb37
callq 0x3250
movq %rax, %rdi
movq 0x955f(%rip), %rsi      # 0x23fb8
callq 0x3290
movq 0x958b(%rip), %rdi      # 0x23ff0
leaq 0x50dd(%rip), %rsi      # 0x1fb49
callq 0x3250
movq %rax, %rdi
movq 0x953d(%rip), %rsi      # 0x23fb8
callq 0x3290
movq 0x9569(%rip), %rdi      # 0x23ff0
leaq 0x50c9(%rip), %rsi      # 0x1fb57
callq 0x3250
movq %rax, %rdi
movq 0x951b(%rip), %rsi      # 0x23fb8
callq 0x3290
movq 0x9547(%rip), %rdi      # 0x23ff0
leaq 0x50be(%rip), %rsi      # 0x1fb6e
callq 0x3250
movq %rax, %rdi
movq 0x94f9(%rip), %rsi      # 0x23fb8
callq 0x3290
jmp 0x1ace0
movsbl -0x1(%rbp), %eax
subl $0x31, %eax
movl %eax, -0x1c(%rbp)
movsbl -0x1(%rbp), %edi
subl $0x31, %edi
callq 0x1d320
movl -0x1c(%rbp), %edi
xorb $-0x1, %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x1d350
movq 0x94fa(%rip), %rdi      # 0x23ff0
leaq 0x5086(%rip), %rsi      # 0x1fb83
callq 0x3250
movq %rax, %rdi
movsbl -0x1(%rbp), %esi
subl $0x30, %esi
callq 0x33f0
movq %rax, -0x18(%rbp)
movsbl -0x1(%rbp), %edi
subl $0x30, %edi
callq 0x1d320
movq -0x18(%rbp), %rdi
movb %al, %cl
leaq 0x5068(%rip), %rsi      # 0x1fb96
leaq 0x5057(%rip), %rax      # 0x1fb8c
testb $0x1, %cl
cmovneq %rax, %rsi
callq 0x3250
movq %rax, %rdi
movq 0x946d(%rip), %rsi      # 0x23fb8
callq 0x3290
jmp 0x1ace0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1b820
movq 0x9462(%rip), %rdi      # 0x23fc8
leaq 0x5031(%rip), %rsi      # 0x1fb9e
callq 0x3250
movq %rax, -0x28(%rbp)
callq 0x1ad30
movq -0x28(%rbp), %rdi
movl 0x67c(%rax), %esi
callq 0x33f0
movq %rax, %rdi
movq 0x9424(%rip), %rsi      # 0x23fb8
callq 0x3290
jmp 0x1ace0
movl $0x1, %edi
callq 0x1b820
movq 0x9419(%rip), %rdi      # 0x23fc8
leaq 0x4fe8(%rip), %rsi      # 0x1fb9e
callq 0x3250
movq %rax, -0x30(%rbp)
callq 0x1ad30
movq -0x30(%rbp), %rdi
movl 0x67c(%rax), %esi
callq 0x33f0
movq %rax, %rdi
movq 0x93db(%rip), %rsi      # 0x23fb8
callq 0x3290
jmp 0x1ace0
callq 0x1ad30
movq %rax, %rdi
callq 0x1b530
movq 0x1aff5(%rip), %rdi     # 0x35bf0
callq 0x1ad10
testb $0x1, %al
jne 0x1ac3e
movq 0x93e5(%rip), %rdi      # 0x23ff0
leaq 0x4f8c(%rip), %rsi      # 0x1fb9e
callq 0x3250
movq %rax, -0x38(%rbp)
callq 0x1ad30
movq -0x38(%rbp), %rdi
movl 0x67c(%rax), %esi
callq 0x33f0
movq %rax, %rdi
movq 0x937f(%rip), %rsi      # 0x23fb8
callq 0x3290
jmp 0x1ace0
movq 0x1afa6(%rip), %rdi     # 0x35bf0
callq 0x1ad10
testb $0x1, %al
jne 0x1ac84
movq 0x1af96(%rip), %rdi     # 0x35bf0
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x9389(%rip), %rdi      # 0x23ff0
leaq 0x4f40(%rip), %rsi      # 0x1fbae
callq 0x3250
movq %rax, %rdi
movq 0x933b(%rip), %rsi      # 0x23fb8
callq 0x3290
jmp 0x1acb3
movq 0x1af65(%rip), %rdi     # 0x35bf0
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x9358(%rip), %rdi      # 0x23ff0
leaq 0x4f21(%rip), %rsi      # 0x1fbc0
callq 0x3250
movq %rax, %rdi
movq 0x930a(%rip), %rsi      # 0x23fb8
callq 0x3290
jmp 0x1ace0
jmp 0x1ace0
movq 0x9332(%rip), %rdi      # 0x23ff0
leaq 0x4f0b(%rip), %rsi      # 0x1fbd0
callq 0x3250
movq %rax, %rdi
movq 0x92e4(%rip), %rsi      # 0x23fb8
callq 0x3290
movl $0x1, -0x8(%rbp)
jmp 0x1ace2
xorl %eax, %eax
cmpl $0x0, -0x8(%rbp)
movb %al, -0x39(%rbp)
jne 0x1acfa
movsbl -0x1(%rbp), %eax
cmpl $-0x1, %eax
setne %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x1a8ff
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)