// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movl $0x800, %esi            # imm = 0x800
xorl %eax, %eax
callq 0x2320
cmpl $-0x1, %eax
je 0x6399
movl %eax, %r14d
cmpl $0xc, %eax
jg 0x6375
leaq 0x8(%rsp), %rsi
movl %r14d, %edi
callq 0x2390
testl %eax, %eax
js 0x6375
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x6375
movl 0xb138(%rip), %esi      # 0x11378
addl $0xd, %esi
xorl %edi, %edi
callq 0x2160
movl %eax, %ebp
cmpl $0x41, 0xb125(%rip)     # 0x11378
setge %al
cmpl $-0x1, %ebp
sete %cl
orb %al, %cl
jne 0x63d3
movl %r14d, %edi
xorl %esi, %esi
callq 0x2160
cmpl $-0x1, %eax
je 0x63d3
xorl %edi, %edi
movl $0x4, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
je 0x63d3
leaq 0x8(%rbx), %r13
movl %ebp, %edi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x20d0
movl %r14d, %edi
callq 0x21d0
movl 0x5f87(%rip), %eax      # 0xc23c
testb $0x10, %al
jne 0x62c2
orl $0x10, %eax
movl %eax, 0x5f7a(%rip)      # 0xc23c
movq 0x5f5f(%rip), %r14      # 0xc228
movq 0x5f60(%rip), %r15      # 0xc230
movl 0x5f61(%rip), %r12d     # 0xc238
movq (%r13), %rax
movq %rax, 0x5f46(%rip)      # 0xc228
movq %r13, 0x5f47(%rip)      # 0xc230
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx,%rax,8)
leaq 0x1(%rax), %rax
jne 0x62eb
decl %eax
movl %eax, 0x5f39(%rip)      # 0xc238
incl 0xb073(%rip)            # 0x11378
movl $0x1, %edi
callq 0x2fc5
movl 0xb063(%rip), %eax      # 0x11378
decl %eax
movl %eax, 0xb05b(%rip)      # 0x11378
movq %r14, 0x5f04(%rip)      # 0xc228
movq %r15, 0x5f05(%rip)      # 0xc230
movl %r12d, 0x5f06(%rip)     # 0xc238
cmpb $0x0, 0x5f37(%rip)      # 0xc270
jne 0x6355
cmpb $0x1, 0x5f06(%rip)      # 0xc248
jne 0x6415
cmpl $0x0, 0x5f01(%rip)      # 0xc250
je 0x6415
testl %eax, %eax
je 0x644b
movl %ebp, %edi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21d0
movl %r14d, %edi
callq 0x21d0
callq 0x6a87
movq (%rbx), %rcx
movq 0x8(%rbx), %r8
leaq 0x2f9f(%rip), %rsi      # 0x932f
leaq 0x2fa8(%rip), %r9       # 0x933f
jmp 0x63b3
callq 0x6a87
movq (%rbx), %rcx
movq 0x8(%rbx), %r8
leaq 0x2f83(%rip), %rsi      # 0x932f
leaq 0x2e38(%rip), %r9       # 0x91eb
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rdx
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6840
movl %ebp, %edi
callq 0x21d0
movl %r14d, %edi
callq 0x21d0
callq 0x6a87
movq %rax, %r14
movq (%rbx), %r15
movq 0x8(%rbx), %rbx
movl $0x18, %edi
callq 0x2380
leaq 0x2f2d(%rip), %rsi      # 0x932f
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %r14, %rdx
movq %r15, %rcx
movq %rbx, %r8
movq %rax, %r9
jmp 0x63bb
movl %ebp, %edi
xorl %esi, %esi
callq 0x2160
movl %eax, %r14d
movl %ebp, %edi
callq 0x21d0
cmpl $-0x1, %r14d
je 0x64e3
cmpl $0x0, 0xaf3f(%rip)      # 0x11378
jne 0x64d1
andb $-0x11, 0x5df6(%rip)    # 0xc23c
jmp 0x64d1
movl $0xd, %edi
xorl %esi, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x6496
callq 0x6a87
movq %rax, %r14
movq (%rbx), %r15
movq 0x8(%rbx), %rbx
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x2eb1(%rip), %rsi      # 0x932f
movl $0x2, %edi
movq %r14, %rdx
movq %r15, %rcx
movq %rbx, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x6840
movl $0xd, %edi
callq 0x21d0
movl 0x5d96(%rip), %eax      # 0xc23c
movl %eax, %ecx
andl $-0x11, %ecx
movl %ecx, 0x5d8b(%rip)      # 0xc23c
testb $0x8, %al
jne 0x64d1
xorl %edi, %edi
xorl %esi, %esi
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6840
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6a87
movq %rax, %r14
movq (%rbx), %r15
movq 0x8(%rbx), %rbx
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x2e2a(%rip), %rsi      # 0x932f
movl $0x2, %edi
jmp 0x6407