// File: /workspace/github_cpp_makefile_star2_O1/ryuichiueda[P]GlueLang/src/Pipeline.cc
// Function: Pipeline::execWait()
int Pipeline::execWait(void)
{
	auto *c = (Executable *)m_nodes[0];
	c->eval();
	auto argv = c->makeArgv();
	
	int i = 1;
	while(argv[i] != NULL){
		DataJob *p = NULL;
		int pid = 0;
		
		while(pid == 0){ // not forked
			if(p == NULL){
				try{
					string s(argv[i]);
					p = (DataJob *)m_env->getData(&m_scopes,&s);
				}catch(...){
					m_error_msg = "Bug of backgound process";
					m_exit_status = 2;
					throw this;
				}
			}
			pid = p->m_pid;
			//pid = m_env->getBG(argv[i]);
		}
		if(pid < 0){
			m_error_msg = "Unknown background process";
			m_exit_status = 4;
			throw this;
		}
		m_pids.push_back(pid);
		p->m_pid = 0;
		i++;
	}

	for(auto pid : m_pids)
		waitCommands(pid);

	if(m_env->m_v_opt)
		cerr << "+ pid " << m_env->m_pid << " wait done" << endl;

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %rax
movq (%rax), %r14
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %r14, %rdi
callq 0xecb0
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x8(%rax)
je 0x12596
movq 0x10(%rsp), %rax
leaq 0x8(%rax), %r14
leaq 0x48(%rbx), %r15
leaq 0x90(%rbx), %rax
movq %rax, 0x18(%rsp)
movl $0x1, %eax
leaq 0x28(%rsp), %r13
leaq 0xb(%rsp), %rbp
movq %rax, 0x20(%rsp)
movl $0x0, 0xc(%rsp)
xorl %r12d, %r12d
testq %r12, %r12
jne 0x1252a
movq (%r14), %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0xbc92
movq 0x10(%rbx), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xb626
movq %rax, %r12
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1252a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6330
movl 0x48(%r12), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0x124e9
js 0x12643
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0x1255c
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0x1256b
movq 0x18(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xa4a8
movl $0x0, 0x48(%r12)
movq 0x10(%rsp), %rax
movq 0x20(%rsp), %rcx
leaq (%rax,%rcx,8), %r14
addq $0x8, %r14
cmpq $0x0, 0x8(%rax,%rcx,8)
leaq 0x1(%rcx), %rax
jne 0x124d9
movq 0x90(%rbx), %r14
movq 0x98(%rbx), %r15
cmpq %r15, %r14
je 0x125ba
movl (%r14), %esi
movq %rbx, %rdi
callq 0x126f8
addq $0x4, %r14
jmp 0x125a4
movq 0x10(%rbx), %rax
cmpb $0x0, 0xe0(%rax)
je 0x12632
movq 0x9a22(%rip), %r14      # 0x1bff0
leaq 0x1c9e(%rip), %rsi      # 0x14273
movl $0x6, %edx
movq %r14, %rdi
callq 0x63a0
movq 0x10(%rbx), %rax
movl 0xe4(%rax), %esi
movq %r14, %rdi
callq 0x6560
movq %rax, %rbx
leaq 0x2166(%rip), %rsi      # 0x14764
movl $0xa, %edx
movq %rax, %rdi
callq 0x63a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6300
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61e0
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x60(%rbx), %rdi
leaq 0x20fb(%rip), %rsi      # 0x14749
callq 0x6410
movl $0x4, 0x80(%rbx)
movl $0x8, %edi
callq 0x6190
movq %rbx, (%rax)
leaq 0x954f(%rip), %rsi      # 0x1bbc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x6550
movq %rax, %r15
jmp 0x1269f
movq %rax, %r15
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x1269f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6330
movq %r15, %rdi
callq 0x6130
leaq 0x60(%rbx), %rdi
leaq 0x2048(%rip), %rsi      # 0x146fa
callq 0x6410
movl $0x2, 0x80(%rbx)
movl $0x8, %edi
callq 0x6190
movq %rbx, (%rax)
leaq 0x94eb(%rip), %rsi      # 0x1bbc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x6550
movq %rax, %rbx
callq 0x6500
movq %rbx, %rdi
callq 0x6580
movq %rax, %rdi
callq 0x7c1d
nop