// File: /workspace/github_c_makefile_star2_O0/haxlang[P]hax/haxGlob.c
// Function: Hax_TildeSubst
char *
Hax_TildeSubst(
    Hax_Interp *interp,		/* Interpreter in which to store error
				 * message (if necessary). */
    ClientData clientData,	/* Unix Client Data */
    char *name			/* File name, which may begin with "~/"
				 * (to indicate current user's home directory)
				 * or "~<user>/" (to indicate any user's
				 * home directory). */)
{
    Hax_Memoryp *memoryp;
    UnixClientData *clientDataPtr = (UnixClientData *) clientData;
    char *dir;
    int length;
    int fromPw = 0;
    char *p;

    if (name[0] != '~') {
	return name;
    }

    memoryp = Hax_GetMemoryp (interp);

    /*
     * First, find the directory name corresponding to the tilde entry.
     */

    if ((name[1] == '/') || (name[1] == '\0')) {
	dir = getenv("HOME");
	if (dir == NULL) {
	    Hax_ResetResult(interp);
	    Hax_AppendResult(interp, "couldn't find HOME environment ",
		    "variable to expand \"", name, "\"", (char *) NULL);
	    return NULL;
	}
	p = name+1;
    } else {
	struct passwd *pwPtr;

	for (p = &name[1]; (*p != 0) && (*p != '/'); p++) {
	    /* Null body;  just find end of name. */
	}
	length = p-&name[1];
	if (length >= clientDataPtr->curSize) {
	    length = clientDataPtr->curSize-1;
	}
	memcpy(clientDataPtr->curBuf, (name+1), length);
	clientDataPtr->curBuf[length] = '\0';
	pwPtr = getpwnam(clientDataPtr->curBuf);
	if (pwPtr == NULL) {
	    endpwent();
	    Hax_ResetResult(interp);
	    Hax_AppendResult(interp, "user \"", clientDataPtr->curBuf,
		    "\" doesn't exist", (char *) NULL);
	    return NULL;
	}
	dir = pwPtr->pw_dir;
	fromPw = 1;
    }

    /*
     * Grow the buffer if necessary to make enough space for the
     * full file name.
     */

    length = strlen(dir) + strlen(p);
    if (length >= clientDataPtr->curSize) {
	if (clientDataPtr->curBuf != clientDataPtr->staticBuf) {
	    ckfree(memoryp, clientDataPtr->curBuf);
	}
	clientDataPtr->curSize = length + 1;
	clientDataPtr->curBuf = (char *) ckalloc(memoryp,
		clientDataPtr->curSize);
    }

    /*
     * Finally, concatenate the directory name with the remainder
     * of the path in the buffer.
     */

    strcpy(clientDataPtr->curBuf, dir);
    strcat(clientDataPtr->curBuf, p);
    if (fromPw) {
	endpwent();
    }
    return clientDataPtr->curBuf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x40(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7e, %eax
je 0x41cc
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x442f
movq -0x10(%rbp), %rdi
callq 0x3540
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2f, %eax
je 0x41f3
movq -0x20(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
jne 0x425a
leaq 0x6eee(%rip), %rdi      # 0xb0e8
callq 0x3050
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4249
movq -0x10(%rbp), %rdi
callq 0x3270
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rcx
leaq 0x6ecb(%rip), %rsi      # 0xb0ed
leaq 0x6ee4(%rip), %rdx      # 0xb10d
leaq 0x6ef0(%rip), %r8       # 0xb120
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x3510
movq $0x0, -0x8(%rbp)
jmp 0x442f
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x4360
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x51(%rbp)
je 0x4287
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
setne %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x4290
jmp 0x42a0
jmp 0x4292
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x4266
movq -0x48(%rbp), %rax
movq -0x20(%rbp), %rcx
addq $0x1, %rcx
subq %rcx, %rax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x54(%rcx), %eax
jl 0x42cb
movq -0x30(%rbp), %rax
movl 0x54(%rax), %eax
subl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x1, %rsi
movslq -0x3c(%rbp), %rdx
callq 0x33c0
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movslq -0x3c(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x3350
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x434d
callq 0x3450
movq -0x10(%rbp), %rdi
callq 0x3270
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdx
leaq 0x6df5(%rip), %rsi      # 0xb122
leaq 0x6df5(%rip), %rcx      # 0xb129
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x3510
movq $0x0, -0x8(%rbp)
jmp 0x442f
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movl $0x1, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3190
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3190
movq %rax, %rcx
movq -0x60(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl 0x54(%rcx), %eax
jl 0x43f6
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x30(%rbp), %rcx
addq $0x20, %rcx
cmpq %rcx, %rax
je 0x43c1
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rsi
leaq 0x6d82(%rip), %rdx      # 0xb139
movl $0x1da, %ecx            # imm = 0x1DA
callq 0x31f0
movl -0x3c(%rbp), %ecx
addl $0x1, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x54(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rax
movslq 0x54(%rax), %rsi
leaq 0x6d58(%rip), %rdx      # 0xb139
movl $0x1de, %ecx            # imm = 0x1DE
callq 0x34c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x30e0
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x3580
cmpl $0x0, -0x40(%rbp)
je 0x4423
callq 0x3450
movq -0x30(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)