// File: /workspace/github_c_makefile_star2_O0/rakitzis[P]rc/which.c
// Function: which
extern char *which(char *name, bool verbose) {
	static char *test = NULL;
	static size_t testlen = 0;
	List *path;
	int len;
	struct stat st;
	if (name == NULL)	/* no filename? can happen with "> foo" as a command */
		return NULL;
	if (!initialized) {
		initialized = TRUE;
		uid = geteuid();
		gid = getegid();
#if HAVE_GETGROUPS
#if HAVE_POSIX_GETGROUPS
		ngroups = getgroups(0, (GETGROUPS_T *)0);
		if (ngroups < 0) {
			uerror("getgroups");
			rc_exit(1);
		}
#else
		ngroups = NGROUPS;
#endif
		if (ngroups) {	
			gidset = ealloc(ngroups * sizeof(GETGROUPS_T));
			getgroups(ngroups, gidset);
		}
#endif
	}
	if (isabsolute(name)) /* absolute pathname? */
		return rc_access(name, verbose, &st) ? name : NULL;
	len = strlen(name);
	for (path = varlookup("path"); path != NULL; path = path->n) {
		size_t need = strlen(path->w) + len + 2; /* one for null terminator, one for the '/' */
		if (testlen < need) {
			efree(test);
			test = ealloc(testlen = need);
		}
		if (*path->w == '\0') {
			strcpy(test, name);
		} else {
			strcpy(test, path->w);
			if (!streq(test, "/")) /* "//" is special to POSIX */
				strcat(test, "/");
			strcat(test, name);
		}
		if (rc_access(test, FALSE, &st))
			return test;
	}
	if (verbose)
		fprint(2, RC "cannot find `%s'\n", name);
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x13f06
movq $0x0, -0x8(%rbp)
jmp 0x14143
cmpl $0x0, 0xd17b(%rip)      # 0x21088
jne 0x13f97
movl $0x1, 0xd16b(%rip)      # 0x21088
callq 0x3160
movl %eax, 0xd148(%rip)      # 0x21070
callq 0x3270
movl %eax, 0xd141(%rip)      # 0x21074
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %esi
callq 0x3250
movl %eax, 0xd148(%rip)      # 0x2108c
cmpl $0x0, 0xd141(%rip)      # 0x2108c
jge 0x13f63
leaq 0x6abc(%rip), %rdi      # 0x1aa10
callq 0x11c10
movl $0x1, %edi
callq 0x5c00
cmpl $0x0, 0xd122(%rip)      # 0x2108c
je 0x13f95
movslq 0xd119(%rip), %rdi      # 0x2108c
shlq $0x2, %rdi
callq 0xd820
movq %rax, 0xd10d(%rip)      # 0x21090
movl 0xd103(%rip), %edi      # 0x2108c
movq 0xd100(%rip), %rsi      # 0x21090
callq 0x3250
jmp 0x13f97
movq -0x10(%rbp), %rdi
callq 0x11d90
cmpl $0x0, %eax
je 0x13fe5
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0xb8(%rbp), %rdx
callq 0x13d90
cmpl $0x0, %eax
je 0x13fca
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x13fd5
xorl %eax, %eax
movq %rax, -0xc8(%rbp)
jmp 0x13fd5
movq -0xc8(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x14143
movq -0x10(%rbp), %rdi
callq 0x30f0
movl %eax, -0x24(%rbp)
leaq 0x1137(%rip), %rdi      # 0x1512f
callq 0x12110
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1411e
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x30f0
movslq -0x24(%rbp), %rcx
addq %rcx, %rax
addq $0x2, %rax
movq %rax, -0xc0(%rbp)
movq 0xd04f(%rip), %rax      # 0x21080
cmpq -0xc0(%rbp), %rax
jae 0x14060
movq 0xd037(%rip), %rdi      # 0x21078
callq 0xd7a0
movq -0xc0(%rbp), %rdi
movq %rdi, 0xd02c(%rip)      # 0x21080
callq 0xd820
movq %rax, 0xd018(%rip)      # 0x21078
movq -0x20(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x14081
movq 0xd002(%rip), %rdi      # 0x21078
movq -0x10(%rbp), %rsi
callq 0x3070
jmp 0x140e4
movq 0xcff0(%rip), %rdi      # 0x21078
movq -0x20(%rbp), %rax
movq (%rax), %rsi
callq 0x3070
movq 0xcfdd(%rip), %rax      # 0x21078
movsbl (%rax), %eax
movsbl 0x1083(%rip), %ecx      # 0x15128
cmpl %ecx, %eax
jne 0x140c1
movq 0xcfc8(%rip), %rdi      # 0x21078
leaq 0x1071(%rip), %rsi      # 0x15128
callq 0x31e0
cmpl $0x0, %eax
je 0x140d4
movq 0xcfb0(%rip), %rdi      # 0x21078
leaq 0x1059(%rip), %rsi      # 0x15128
callq 0x3300
movq 0xcf9d(%rip), %rdi      # 0x21078
movq -0x10(%rbp), %rsi
callq 0x3300
movq 0xcf8d(%rip), %rdi      # 0x21078
xorl %esi, %esi
leaq -0xb8(%rbp), %rdx
callq 0x13d90
cmpl $0x0, %eax
je 0x1410b
movq 0xcf73(%rip), %rax      # 0x21078
movq %rax, -0x8(%rbp)
jmp 0x14143
jmp 0x1410d
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x14001
cmpl $0x0, -0x14(%rbp)
je 0x1413b
movq -0x10(%rbp), %rdx
movl $0x2, %edi
leaq 0x68e6(%rip), %rsi      # 0x1aa1a
movb $0x0, %al
callq 0xf3a0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq