// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movzbl (%rdi), %r15d
testl %r15d, %r15d
je 0x15b0
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
leaq 0xc2c(%rip), %rsi       # 0x214d
callq 0x10e0
testl %eax, %eax
je 0x15b0
leaq 0xc1a(%rip), %rsi       # 0x214f
movq %r14, %rdi
callq 0x10e0
testl %eax, %eax
je 0x16fd
leaq 0xc05(%rip), %rsi       # 0x2151
movq %r14, %rdi
callq 0x10e0
testl %eax, %eax
je 0x16fd
leaq 0xc0a(%rip), %rsi       # 0x216d
movq %r14, %rdi
callq 0x10e0
testl %eax, %eax
je 0x1670
leaq 0xbf5(%rip), %rsi       # 0x216f
movq %r14, %rdi
callq 0x10e0
testl %eax, %eax
je 0x1670
leal -0x45(%r15), %eax
cmpl $0x7, %eax
jbe 0x15c6
leal -0x65(%r15), %ecx
cmpl $0x7, %ecx
ja 0x1655
leaq 0xa7d(%rip), %rdx       # 0x2024
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0xc4a(%rip), %rdi       # 0x2201
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1040
leaq 0xa37(%rip), %rcx       # 0x2004
movslq (%rcx,%rax,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
cmpb $0x20, 0x1(%r14)
je 0x16ca
cmpl $0x27, %eax
ja 0x1655
movabsq $0x100000001, %rcx      # imm = 0x100000001
btq %rax, %rcx
jb 0x1618
movabsq $0x800000008, %rcx      # imm = 0x800000008
btq %rax, %rcx
jb 0x163d
movabsq $0x8000000080, %rcx     # imm = 0x8000000080
btq %rax, %rcx
jb 0x164e
jmp 0x1655
cmpb $0x20, 0x1(%r14)
je 0x169d
leal -0x48(%r15), %eax
rolb $0x6, %al
cmpb $0x9, %al
ja 0x1655
movzbl %al, %eax
leaq 0xa10(%rip), %rcx       # 0x2044
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x20, 0x1(%r14)
je 0x168f
orl $0x20, %r15d
cmpl $0x6c, %r15d
jne 0x1655
cmpb $0x20, 0x1(%r14)
je 0x1681
leaq 0xb15(%rip), %rdi       # 0x2171
movq %r14, %rsi
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x10a0
leaq 0x4(%rsp), %rdx
movl $0x0, (%rdx)
movl %ebp, %edi
movl %ebx, %esi
jmp 0x16ed
leaq 0x4(%rsp), %r15
movl $0x4, (%r15)
jmp 0x16d6
leaq 0x4(%rsp), %r15
movl $0x3, (%r15)
jmp 0x16d6
leaq 0xc(%rsp), %r15
movl $0x2, -0x8(%r15)
addq $0x2, %r14
movl $0x3c, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x1030
movb $0x0, 0x3b(%r15)
leaq 0x4(%rsp), %rdx
jmp 0x167b
leaq 0x4(%rsp), %r15
movl $0x1, (%r15)
addq $0x2, %r14
movq %r14, %rdi
callq 0x1150
movl %eax, 0x4(%r15)
movl %ebp, %edi
movl %ebx, %esi
movq %r15, %rdx
callq 0x11b0
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x12a9