// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1060
cmpq $0x0, %rax
je 0x1466
movq -0x8(%rbp), %rdi
leaq 0xd88(%rip), %rsi       # 0x21e4
callq 0x10d0
cmpl $0x0, %eax
jne 0x1470
callq 0x1410
jmp 0x1658
movq -0x8(%rbp), %rdi
leaq 0xd6b(%rip), %rsi       # 0x21e6
callq 0x10d0
cmpl $0x0, %eax
je 0x149a
movq -0x8(%rbp), %rdi
leaq 0xd58(%rip), %rsi       # 0x21e8
callq 0x10d0
cmpl $0x0, %eax
jne 0x14b9
movq 0x2b57(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xd3f(%rip), %rsi       # 0x21ea
movb $0x0, %al
callq 0x10e0
xorl %edi, %edi
callq 0x1150
movq -0x8(%rbp), %rdi
leaq 0xd40(%rip), %rsi       # 0x2204
callq 0x10d0
cmpl $0x0, %eax
je 0x14e3
movq -0x8(%rbp), %rdi
leaq 0xd2d(%rip), %rsi       # 0x2206
callq 0x10d0
cmpl $0x0, %eax
jne 0x14fe
movl $0x0, -0x54(%rbp)
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
leaq -0x54(%rbp), %rdx
callq 0x1280
jmp 0x1658
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x6b, %eax
je 0x1516
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4b, %eax
jne 0x154e
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x20, %eax
jne 0x154e
movl $0x1, -0x54(%rbp)
movq -0x8(%rbp), %rdi
addq $0x2, %rdi
callq 0x1140
movl %eax, -0x50(%rbp)
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
leaq -0x54(%rbp), %rdx
callq 0x1280
jmp 0x1658
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x65, %eax
je 0x1566
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x45, %eax
jne 0x15ac
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x20, %eax
jne 0x15ac
movl $0x2, -0x54(%rbp)
leaq -0x54(%rbp), %rdi
addq $0x8, %rdi
movq -0x8(%rbp), %rsi
addq $0x2, %rsi
movl $0x3c, %edx
callq 0x1030
movb $0x0, -0x11(%rbp)
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
leaq -0x54(%rbp), %rdx
callq 0x1280
jmp 0x1658
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x68, %eax
je 0x15c4
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x48, %eax
jne 0x15f9
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x20, %eax
jne 0x15f9
movl $0x3, -0x54(%rbp)
movq -0x8(%rbp), %rdi
addq $0x2, %rdi
callq 0x1140
movl %eax, -0x50(%rbp)
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
leaq -0x54(%rbp), %rdx
callq 0x1280
jmp 0x1658
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x6c, %eax
je 0x1611
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4c, %eax
jne 0x1646
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x20, %eax
jne 0x1646
movl $0x4, -0x54(%rbp)
movq -0x8(%rbp), %rdi
addq $0x2, %rdi
callq 0x1140
movl %eax, -0x50(%rbp)
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
leaq -0x54(%rbp), %rdx
callq 0x1280
jmp 0x1658
movq -0x8(%rbp), %rsi
leaq 0xbb7(%rip), %rdi       # 0x2208
movb $0x0, %al
callq 0x1090
addq $0x60, %rsp
popq %rbp
retq
nop