// File: /workspace/github_c_makefile_star2_O1/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 0x62c6
movl %eax, %r14d
cmpl $0xc, %eax
jle 0x6300
movl %r14d, %edi
callq 0x21d0
callq 0x6b0f
movq (%rbx), %rcx
movq 0x8(%rbx), %r8
leaq 0x3078(%rip), %rsi      # 0x9335
leaq 0x3081(%rip), %r9       # 0x9345
jmp 0x62e0
callq 0x6b0f
movq (%rbx), %rcx
movq 0x8(%rbx), %r8
leaq 0x305c(%rip), %rsi      # 0x9335
leaq 0x2f0b(%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 0x68c8
leaq 0x8(%rsp), %rsi
movl %r14d, %edi
callq 0x2390
testl %eax, %eax
js 0x62a2
movl $0xf000, %eax           # imm = 0xF000
andl 0x20(%rsp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x62a2
movl 0xb051(%rip), %esi      # 0x11378
addl $0xd, %esi
xorl %edi, %edi
callq 0x2160
movl %eax, %ebp
cmpl $0x41, 0xb03e(%rip)     # 0x11378
setge %al
cmpl $-0x1, %ebp
sete %cl
orb %al, %cl
jne 0x6454
movl %r14d, %edi
xorl %esi, %esi
callq 0x2160
cmpl $-0x1, %eax
je 0x6454
xorl %edi, %edi
movl $0x4, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x20d0
cmpl $-0x1, %eax
je 0x6454
leaq 0x8(%rbx), %r13
movl %ebp, %edi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x20d0
movl %r14d, %edi
callq 0x21d0
movl 0x5ea0(%rip), %eax      # 0xc23c
testb $0x10, %al
jne 0x63a9
orl $0x10, %eax
movl %eax, 0x5e93(%rip)      # 0xc23c
movq 0x5e78(%rip), %r14      # 0xc228
movq 0x5e79(%rip), %r15      # 0xc230
movl 0x5e7a(%rip), %r12d     # 0xc238
movq (%r13), %rax
movq %rax, 0x5e5f(%rip)      # 0xc228
movq %r13, 0x5e60(%rip)      # 0xc230
xorl %eax, %eax
cmpq $0x0, 0x8(%rbx,%rax,8)
leaq 0x1(%rax), %rax
jne 0x63d2
decl %eax
movl %eax, 0x5e52(%rip)      # 0xc238
incl 0xaf8c(%rip)            # 0x11378
movl $0x1, %edi
callq 0x2f99
movl 0xaf7c(%rip), %eax      # 0x11378
decl %eax
movl %eax, 0xaf74(%rip)      # 0x11378
movq %r14, 0x5e1d(%rip)      # 0xc228
movq %r15, 0x5e1e(%rip)      # 0xc230
movl %r12d, 0x5e1f(%rip)     # 0xc238
cmpb $0x0, 0x5e50(%rip)      # 0xc270
jne 0x6434
cmpb $0x1, 0x5e1f(%rip)      # 0xc248
jne 0x6499
cmpl $0x0, 0x5e1e(%rip)      # 0xc250
je 0x6499
testl %eax, %eax
je 0x64cf
movl %ebp, %edi
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x21d0
movl %ebp, %edi
callq 0x21d0
movl %r14d, %edi
callq 0x21d0
callq 0x6b0f
movq %rax, %r14
movq (%rbx), %r15
movq 0x8(%rbx), %rbx
movl $0x18, %edi
callq 0x2380
leaq 0x2eb2(%rip), %rsi      # 0x9335
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %r14, %rdx
movq %r15, %rcx
movq %rbx, %r8
movq %rax, %r9
jmp 0x62e8
movl %ebp, %edi
xorl %esi, %esi
callq 0x2160
movl %eax, %r14d
movl %ebp, %edi
callq 0x21d0
cmpl $-0x1, %r14d
je 0x6567
cmpl $0x0, 0xaebb(%rip)      # 0x11378
jne 0x6555
andb $-0x11, 0x5d72(%rip)    # 0xc23c
jmp 0x6555
movl $0xd, %edi
xorl %esi, %esi
callq 0x2160
cmpl $-0x1, %eax
jne 0x651a
callq 0x6b0f
movq %rax, %r14
movq (%rbx), %r15
movq 0x8(%rbx), %rbx
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x2e33(%rip), %rsi      # 0x9335
movl $0x2, %edi
movq %r14, %rdx
movq %r15, %rcx
movq %rbx, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x68c8
movl $0xd, %edi
callq 0x21d0
movl 0x5d12(%rip), %eax      # 0xc23c
movl %eax, %ecx
andl $-0x11, %ecx
movl %ecx, 0x5d07(%rip)      # 0xc23c
testb $0x8, %al
jne 0x6555
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 0x68c8
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6b0f
movq %rax, %r14
movq (%rbx), %r15
movq 0x8(%rbx), %rbx
callq 0x2070
movl (%rax), %edi
callq 0x2380
leaq 0x2dac(%rip), %rsi      # 0x9335
movl $0x2, %edi
jmp 0x6488