// File: /workspace/github_c_makefile_star2_O0/ebiggers[P]mysh/mysh_param.c
// Function: lookup_param
const char *
lookup_param(const char *name, size_t len)
{
	static char buf[20];
	unsigned char char_type = shell_char_type(*name);
	if (char_type & SHELL_PARAM_NUMERIC_CHAR) {
		/* Positional parameter */
		unsigned n = 0;
		do {
			n *= 10;
			n += *name - '0';
		} while (--len);
		if (n > num_positional_parameters)
			return NULL;
		else
			return positional_parameters[n];
	} else if (char_type & SHELL_PARAM_SPECIAL_CHAR) {
		/* Special variable */
		switch (*name) {
		case '$':
			/* $$: Process ID */
			sprintf(buf, "%d", getpid());
			return buf;
		case '?':
			/* $?: Exit status of last command */
			sprintf(buf, "%d", mysh_last_exit_status);
			return buf;
		case '#':
			/* $#: Number of positional parameters */
			sprintf(buf, "%u", num_positional_parameters);
			return buf;
		case '!':
			/* $!: pid of last process in last background pipeline */
			if (mysh_last_background_pid == 0) {
				return NULL;
			} else {
				sprintf(buf, "%d", mysh_last_background_pid);
				return buf;
			}
		case '*':
		case '@': /* Note: $@ does not yet behave correctly (it's treated the same as $*) */
			/* All positional parameters */
			return get_all_positional_params();
		}
	} else {
		/* Regular variable; look it up in the trie. */
		return lookup_shell_param_len(name, len);
	}
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %edi
callq 0x60f0
movb %al, -0x19(%rbp)
movzbl -0x19(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x62fa
movl $0x0, -0x20(%rbp)
imull $0xa, -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x62a2
movl -0x20(%rbp), %eax
cmpl 0x8620(%rip), %eax      # 0xe8f4
jbe 0x62e3
movq $0x0, -0x8(%rbp)
jmp 0x6424
movq 0x860e(%rip), %rax      # 0xe8f8
movl -0x20(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x6424
movzbl -0x19(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x6407
movq -0x10(%rbp), %rax
movsbl (%rax), %eax
addl $-0x21, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x1f, %eax
ja 0x6405
movq -0x28(%rbp), %rax
leaq 0x4686(%rip), %rcx      # 0xa9b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
callq 0x20e0
movl %eax, %edx
leaq 0x859b(%rip), %rdi      # 0xe8e0
leaq 0x4709(%rip), %rsi      # 0xaa55
movb $0x0, %al
callq 0x2350
leaq 0x8586(%rip), %rax      # 0xe8e0
movq %rax, -0x8(%rbp)
jmp 0x6424
leaq 0x82b6(%rip), %rax      # 0xe620
movl (%rax), %edx
leaq 0x856d(%rip), %rdi      # 0xe8e0
leaq 0x46db(%rip), %rsi      # 0xaa55
movb $0x0, %al
callq 0x2350
leaq 0x8558(%rip), %rax      # 0xe8e0
movq %rax, -0x8(%rbp)
jmp 0x6424
movl 0x855d(%rip), %edx      # 0xe8f4
leaq 0x8542(%rip), %rdi      # 0xe8e0
leaq 0x46b3(%rip), %rsi      # 0xaa58
movb $0x0, %al
callq 0x2350
leaq 0x852d(%rip), %rax      # 0xe8e0
movq %rax, -0x8(%rbp)
jmp 0x6424
leaq 0x827c(%rip), %rax      # 0xe63c
cmpl $0x0, (%rax)
jne 0x63cf
movq $0x0, -0x8(%rbp)
jmp 0x6424
leaq 0x8266(%rip), %rax      # 0xe63c
movl (%rax), %edx
leaq 0x8501(%rip), %rdi      # 0xe8e0
leaq 0x466f(%rip), %rsi      # 0xaa55
movb $0x0, %al
callq 0x2350
leaq 0x84ec(%rip), %rax      # 0xe8e0
movq %rax, -0x8(%rbp)
jmp 0x6424
callq 0x6d30
movq %rax, -0x8(%rbp)
jmp 0x6424
jmp 0x641a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6110
movq %rax, -0x8(%rbp)
jmp 0x6424
jmp 0x641c
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nop