// File: /workspace/github_c_makefile_star2_O0/s3lase[P]v6shell/osh.c
// Function: do_source
static void
do_source(char **av)
{
	const char *sname;
	char *const *sdolv;
	int nfd, sfd, sdolc;
	static int cnt;

	if ((nfd = open(av[1], O_RDONLY | O_NONBLOCK)) == -1) {
		err(-1, FMT4S, getmyname(), av[0], av[1], ERR_OPEN);
		return;
	}
	if (nfd >= SAVFD0 || !fd_type(nfd, FD_ISREG)) {
		(void)close(nfd);
		err(-1, FMT4S, getmyname(), av[0], av[1], ERR_EXEC);
		return;
	}
	sfd = dup2(FD0, SAVFD0 + cnt);
	if (cnt > SOURCEMAX || sfd == -1 || dup2(nfd, FD0) == -1 ||
	    fcntl(FD0, F_SETFL, O_RDONLY & ~O_NONBLOCK) == -1) {
		(void)close(sfd);
		(void)close(nfd);
		err(-1, FMT4S, getmyname(), av[0], av[1], strerror(EMFILE));
		return;
	}
	(void)fcntl(sfd, F_SETFD, FD_CLOEXEC);
	(void)close(nfd);

	if (!SHTYPE(ST_SOURCE))
		shtype |= ST_SOURCE;

	/* Save and initialize any positional parameters. */
	sname = name, sdolv = dolv, sdolc = dolc;
	name  = av[1], dolv = &av[1];
	for (dolc = 0; dolv[dolc] != NULL; dolc++)
		;	/* nothing */

	cnt++;
	cmd_loop(HALT);
	cnt--;

	/* Restore any saved positional parameters. */
	name = sname, dolv = sdolv, dolc = sdolc;

	if (error_source || (is_login && logout_now != 0)) {
		/*
		 * Terminate any and all source commands (nested or not).
		 * Restore original standard input before returning for
		 * the final time, and call err() if needed.
		 */
		if (cnt == 0) {
			/* Restore original standard input or die trying. */
			if (dup2(SAVFD0, FD0) == -1)
				err(SH_ERR, FMT4S,
				    getmyname(), av[0], av[1], strerror(errno));
			(void)close(SAVFD0);
			shtype &= ~ST_SOURCE;
			if (!SHTYPE(ST_RCFILE))
				err(0, NULL);
			return;
		}
		(void)close(sfd);
		return;
	}

	/* Restore previous standard input or die trying. */
	if (dup2(sfd, FD0) == -1) {
		(void)close(sfd);
		err(SH_ERR, FMT4S, getmyname(), av[0], av[1], strerror(errno));
		return;
	}
	(void)close(sfd);

	if (cnt == 0)
		shtype &= ~ST_SOURCE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
movl $0x800, %esi            # imm = 0x800
movb $0x0, %al
callq 0x2320
movl %eax, -0x1c(%rbp)
cmpl $-0x1, %eax
jne 0x822e
callq 0x8df0
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %r8
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x357e(%rip), %rsi      # 0xb799
leaq 0x342d(%rip), %r9       # 0xb64f
movb $0x0, %al
callq 0x8af0
jmp 0x8577
cmpl $0xd, -0x1c(%rbp)
jge 0x8245
movl -0x1c(%rbp), %edi
movl $0x8000, %esi           # imm = 0x8000
callq 0x2b90
testb $0x1, %al
jne 0x8283
movl -0x1c(%rbp), %edi
callq 0x21d0
callq 0x8df0
movq %rax, %rdx
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %r8
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x3529(%rip), %rsi      # 0xb799
leaq 0x3532(%rip), %r9       # 0xb7a9
movb $0x0, %al
callq 0x8af0
jmp 0x8577
movl 0xb0ef(%rip), %esi      # 0x13378
addl $0xd, %esi
xorl %edi, %edi
callq 0x2160
movl %eax, -0x20(%rbp)
cmpl $0x40, 0xb0db(%rip)     # 0x13378
jg 0x82c9
cmpl $-0x1, -0x20(%rbp)
je 0x82c9
movl -0x1c(%rbp), %edi
xorl %esi, %esi
callq 0x2160
cmpl $-0x1, %eax
je 0x82c9
xorl %edx, %edx
movl $0x4, %esi
movl %edx, %edi
movb $0x0, %al
callq 0x20d0
cmpl $-0x1, %eax
jne 0x832a
movl -0x20(%rbp), %edi
callq 0x21d0
movl -0x1c(%rbp), %edi
callq 0x21d0
callq 0x8df0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x18, %edi
callq 0x2380
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %r8
movq %rax, %r9
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x347b(%rip), %rsi      # 0xb799
movb $0x0, %al
callq 0x8af0
jmp 0x8577
movl -0x20(%rbp), %edi
movl $0x2, %esi
movl $0x1, %edx
movb $0x0, %al
callq 0x20d0
movl -0x1c(%rbp), %edi
callq 0x21d0
movl 0x5ef0(%rip), %eax      # 0xe23c
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x8363
movl 0x5ee2(%rip), %eax      # 0xe23c
orl $0x10, %eax
movl %eax, 0x5ed9(%rip)      # 0xe23c
movq 0x5ebe(%rip), %rax      # 0xe228
movq %rax, -0x10(%rbp)
movq 0x5ebb(%rip), %rax      # 0xe230
movq %rax, -0x18(%rbp)
movl 0x5eb9(%rip), %eax      # 0xe238
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x5e97(%rip)      # 0xe228
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, 0x5e90(%rip)      # 0xe230
movl $0x0, 0x5e8e(%rip)      # 0xe238
movq 0x5e7f(%rip), %rax      # 0xe230
movslq 0x5e80(%rip), %rcx      # 0xe238
cmpq $0x0, (%rax,%rcx,8)
je 0x83d2
jmp 0x83c1
movl 0x5e71(%rip), %eax      # 0xe238
addl $0x1, %eax
movl %eax, 0x5e68(%rip)      # 0xe238
jmp 0x83aa
movl 0xafa0(%rip), %eax      # 0x13378
addl $0x1, %eax
movl %eax, 0xaf97(%rip)      # 0x13378
movl $0x1, %edi
callq 0x3240
movl 0xaf87(%rip), %eax      # 0x13378
addl $-0x1, %eax
movl %eax, 0xaf7e(%rip)      # 0x13378
movq -0x10(%rbp), %rax
movq %rax, 0x5e23(%rip)      # 0xe228
movq -0x18(%rbp), %rax
movq %rax, 0x5e20(%rip)      # 0xe230
movl -0x24(%rbp), %eax
movl %eax, 0x5e1f(%rip)      # 0xe238
testb $0x1, 0x5e50(%rip)      # 0xe270
jne 0x843e
testb $0x1, 0x5e1f(%rip)      # 0xe248
je 0x84f0
movl 0x5e1b(%rip), %eax      # 0xe250
cmpl $0x0, %eax
je 0x84f0
cmpl $0x0, 0xaf33(%rip)      # 0x13378
jne 0x84e3
movl $0xd, %edi
xorl %esi, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x84aa
callq 0x8df0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x2070
movl (%rax), %edi
callq 0x2380
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %r8
movq %rax, %r9
movl $0x2, %edi
leaq 0x32f6(%rip), %rsi      # 0xb799
movb $0x0, %al
callq 0x8af0
movl $0xd, %edi
callq 0x21d0
movl 0x5d82(%rip), %eax      # 0xe23c
andl $-0x11, %eax
movl %eax, 0x5d79(%rip)      # 0xe23c
movl 0x5d73(%rip), %eax      # 0xe23c
andl $0x8, %eax
cmpl $0x0, %eax
jne 0x84de
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %esi
movb $0x0, %al
callq 0x8af0
jmp 0x8577
movl -0x20(%rbp), %edi
callq 0x21d0
jmp 0x8577
movl -0x20(%rbp), %edi
xorl %esi, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x8557
movl -0x20(%rbp), %edi
callq 0x21d0
callq 0x8df0
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
callq 0x2070
movl (%rax), %edi
callq 0x2380
movq -0x70(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq -0x60(%rbp), %r8
movq %rax, %r9
movl $0x2, %edi
leaq 0x324b(%rip), %rsi      # 0xb799
movb $0x0, %al
callq 0x8af0
jmp 0x8577
movl -0x20(%rbp), %edi
callq 0x21d0
cmpl $0x0, 0xae12(%rip)      # 0x13378
jne 0x8577
movl 0x5cce(%rip), %eax      # 0xe23c
andl $-0x11, %eax
movl %eax, 0x5cc5(%rip)      # 0xe23c
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)