// File: /workspace/github_c_makefile_star2_O2/chrispanag[P]operating-systems-scheduler/shell.c
// Function: process_cmdline
void process_cmdline(char *cmdline, int wfd, int rfd)
{
	struct request_struct rq;

	if (strlen(cmdline) == 0 || strcmp(cmdline, "?") == 0){
		help();
		return;
	}

	/* Quit */
	if (strcmp(cmdline, "q") == 0 || strcmp(cmdline, "Q") == 0) {
		fprintf(stderr, "Shell: Exiting. Goodbye.\n");
		exit(0);
	}

	/* Print Tasks */
	if (strcmp(cmdline, "p") == 0 || strcmp(cmdline, "P") == 0) {
		rq.request_no = REQ_PRINT_TASKS;
		issue_request(wfd, rfd, &rq);
		return;
	}

	/* Kill Task */
	if ((cmdline[0] == 'k' || cmdline[0] == 'K') &&
	    cmdline[1] == ' ') {
		rq.request_no = REQ_KILL_TASK;
		rq.task_arg = atoi(&cmdline[2]);
		issue_request(wfd, rfd, &rq);
		return;
	}

	/* Exec Task */
	if ((cmdline[0] == 'e' || cmdline[0] == 'E') && cmdline[1] == ' ') {
		rq.request_no = REQ_EXEC_TASK;
		strncpy(rq.exec_task_arg, &cmdline[2], EXEC_TASK_NAME_SZ);
		rq.exec_task_arg[EXEC_TASK_NAME_SZ - 1] = '\0';
		issue_request(wfd, rfd, &rq);
		return;
	}

	/* High-prioritize task */
	if ((cmdline[0] == 'h' || cmdline[0] == 'H') && cmdline[1] == ' ') {
		rq.request_no = REQ_HIGH_TASK;
		rq.task_arg = atoi(&cmdline[2]);
		issue_request(wfd, rfd, &rq);
		return;
	}

	/* Low-prioritize task */
	if ((cmdline[0] == 'l' || cmdline[0] == 'L') && cmdline[1] == ' ') {
		rq.request_no = REQ_LOW_TASK;
		rq.task_arg = atoi(&cmdline[2]);
		issue_request(wfd, rfd, &rq);
		return;
	}

	/* Parse error, malformed command, whatever... */
	printf("command `%s': Bad Command.\n", cmdline);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %rsi
movzbl (%rdi), %eax
leal -0x45(%rax), %ecx
cmpl $0xc, %ecx
jbe 0x13f1
leal -0x65(%rax), %ecx
cmpl $0xc, %ecx
ja 0x1433
leaq 0xc50(%rip), %rdx       # 0x2038
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0xc0c(%rip), %rdx       # 0x2004
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpb $0x20, 0x1(%rsi)
jne 0x14b6
leaq 0x14(%rsp), %r14
movl $0x2, -0x8(%r14)
addq $0x2, %rsi
pushq $0x3c
popq %rdx
movq %r14, %rdi
callq 0x1030
movb $0x0, 0x3b(%r14)
leaq 0xc(%rsp), %rdx
jmp 0x1469
testl %eax, %eax
je 0x144a
cmpl $0x3f, %eax
jne 0x1539
cmpb $0x0, 0x1(%rsi)
jne 0x1539
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x13b3
cmpb $0x0, 0x1(%rsi)
jne 0x1539
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movl %ebp, %edi
movl %ebx, %esi
jmp 0x152b
cmpb $0x20, 0x1(%rsi)
jne 0x14d4
leaq 0xc(%rsp), %r14
movl $0x1, (%r14)
jmp 0x1514
cmpb $0x0, 0x1(%rsi)
jne 0x1539
movq 0x2b5e(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0xcd1(%rip), %rdi       # 0x2175
pushq $0x19
popq %rsi
pushq $0x1
popq %rdx
callq 0x1160
xorl %edi, %edi
callq 0x1150
leal -0x48(%rax), %ecx
rolb $0x6, %cl
cmpb $0x9, %cl
ja 0x1539
movzbl %cl, %ecx
leaq 0xba1(%rip), %rdx       # 0x206c
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
cmpl $0x4c, %eax
je 0x1502
cmpl $0x68, %eax
je 0x14e9
cmpl $0x65, %eax
je 0x1401
jmp 0x1539
cmpb $0x20, 0x1(%rsi)
jne 0x14fd
leaq 0xc(%rsp), %r14
movl $0x3, (%r14)
jmp 0x1514
cmpl $0x4c, %eax
jne 0x1539
cmpb $0x20, 0x1(%rsi)
jne 0x1539
leaq 0xc(%rsp), %r14
movl $0x4, (%r14)
addq $0x2, %rsi
movq %rsi, %rdi
callq 0x1140
movl %eax, 0x4(%r14)
movl %ebp, %edi
movl %ebx, %esi
movq %r14, %rdx
callq 0x128c
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0xc4f(%rip), %rdi       # 0x218f
xorl %eax, %eax
addq $0x50, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x10a0