// File: /workspace/github_cpp_makefile_star2_O3/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 0xec74
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x8(%rax)
je 0x1236a
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 0x122fe
movq (%r14), %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0xbc72
movq 0x10(%rbx), %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xb604
movq %rax, %r12
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x122fe
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6330
movl 0x48(%r12), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0x122bd
js 0x12417
movq 0x98(%rbx), %rsi
cmpq 0xa0(%rbx), %rsi
je 0x12330
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rbx)
jmp 0x1233f
movq 0x18(%rsp), %rdi
leaq 0xc(%rsp), %rdx
callq 0xa48c
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 0x122ad
movq 0x90(%rbx), %r14
movq 0x98(%rbx), %r15
cmpq %r15, %r14
je 0x1238e
movl (%r14), %esi
movq %rbx, %rdi
callq 0x124cc
addq $0x4, %r14
jmp 0x12378
movq 0x10(%rbx), %rax
cmpb $0x0, 0xe0(%rax)
je 0x12406
movq 0x9c4e(%rip), %r14      # 0x1bff0
leaq 0x1eca(%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 0x23ac(%rip), %rsi      # 0x1477e
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 0x2341(%rip), %rsi      # 0x14763
callq 0x6410
movl $0x4, 0x80(%rbx)
movl $0x8, %edi
callq 0x6190
movq %rbx, (%rax)
leaq 0x977b(%rip), %rsi      # 0x1bbc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x6550
movq %rax, %r15
jmp 0x12473
movq %rax, %r15
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x12473
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6330
movq %r15, %rdi
callq 0x6130
leaq 0x60(%rbx), %rdi
leaq 0x228e(%rip), %rsi      # 0x14714
callq 0x6410
movl $0x2, 0x80(%rbx)
movl $0x8, %edi
callq 0x6190
movq %rbx, (%rax)
leaq 0x9717(%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 0x7c2d
nop