// File: /workspace/github_c_makefile_star2_O0/alexgirao[P]aimant/subprocess.c
// Function: subprocess_read_selfpipe0
static int subprocess_read_selfpipe0()
{
	DEBUG_INFO("subprocess_read_selfpipe(): begin");
	for (;;) {
		char buf_selfpipe[10 * sizeof(int)]; /* maybe read 10 pids at a time */
		int n = read(selfpipe[0], buf_selfpipe, sizeof(buf_selfpipe));
		DEBUG_INFO("subprocess_read_selfpipe(): read(selfpipe[0], buf_selfpipe, sizeof(buf_selfpipe)): %i", n);
		if (n < 0) {
			int save_errno = errno;
			assert(n == -1);
			if (errno == EINTR) {
				DEBUG_INFO("subprocess_read_selfpipe(): received an EINTR");
				break;
			}
			if (errno == EAGAIN) {
				DEBUG_INFO("subprocess_read_selfpipe(): received an EAGAIN");
				break;
			}
			DEBUG("read(), errno=%i", save_errno);
			errno = save_errno;
			perror("reading selfpipe[0]");
			exit(1);
		}
		assert((n % sizeof(int)) == 0);
		if (n) {
			int *pid_gone = (int*)buf_selfpipe;
			int m = n / sizeof(int);
			do {
				struct child *c;
				if ((c = children_search_by_pid(subprocesses, *pid_gone))) {
					assert(*pid_gone == c->sp->pid);
					DEBUG_INFO("subprocess_read_selfpipe(): \x20\x20pid %i found at child %p", *pid_gone, c);
					children_remove(subprocesses, c);
					child_free(c);
					c = NULL;
				} else {
					DEBUG_INFO("subprocess_read_selfpipe(): \x20\x20pid %i does not concern to us", *pid_gone);
				}
				pid_gone++;
			} while (--m);
			if (n == sizeof(buf_selfpipe)) {
				/* last read filled all the buffer
				 */
				DEBUG_INFO("subprocess_read_selfpipe(): checking again");
				continue;
			}
		}
		break;
	}
	DEBUG_INFO("subprocess_read_selfpipe(): done");
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl 0xb69a(%rip), %edi      # 0x16718
leaq -0x30(%rbp), %rsi
movl $0x28, %edx
callq 0x21f0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0xb12d
callq 0x2070
movl (%rax), %eax
movl %eax, -0x38(%rbp)
cmpl $-0x1, -0x34(%rbp)
jne 0xb0ab
jmp 0xb0ca
leaq 0x51ee(%rip), %rdi      # 0x102a0
leaq 0x5edf(%rip), %rsi      # 0x10f98
movl $0x1b7, %edx            # imm = 0x1B7
leaq 0x67c7(%rip), %rcx      # 0x1188c
callq 0x21a0
callq 0x2070
cmpl $0x4, (%rax)
jne 0xb0d9
jmp 0xb21f
callq 0x2070
cmpl $0xb, (%rax)
jne 0xb0e8
jmp 0xb21f
jmp 0xb0ea
movl -0x38(%rbp), %ecx
leaq 0x5ea4(%rip), %rdi      # 0x10f98
movl $0x1c0, %esi            # imm = 0x1C0
leaq 0x58d7(%rip), %rdx      # 0x109d7
movb $0x0, %al
callq 0xdfe0
movl -0x38(%rbp), %eax
movl %eax, -0x54(%rbp)
callq 0x2070
movl -0x54(%rbp), %ecx
movl %ecx, (%rax)
leaq 0x678e(%rip), %rdi      # 0x118ac
callq 0x2310
movl $0x1, %edi
callq 0x2350
movslq -0x34(%rbp), %rax
andq $0x3, %rax
cmpq $0x0, %rax
jne 0xb13d
jmp 0xb15c
leaq 0x677c(%rip), %rdi      # 0x118c0
leaq 0x5e4d(%rip), %rsi      # 0x10f98
movl $0x1c5, %edx            # imm = 0x1C5
leaq 0x6735(%rip), %rcx      # 0x1188c
callq 0x21a0
cmpl $0x0, -0x34(%rbp)
je 0xb21d
leaq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movslq -0x34(%rbp), %rax
shrq $0x2, %rax
movl %eax, -0x44(%rbp)
movq 0xb690(%rip), %rdi      # 0x16810
movq -0x40(%rbp), %rax
movl (%rax), %esi
callq 0x8f00
movq %rax, -0x50(%rbp)
cmpq $0x0, %rax
je 0xb1ec
movq -0x40(%rbp), %rax
movl (%rax), %eax
movq -0x50(%rbp), %rcx
movq 0x10(%rcx), %rcx
cmpl 0x18(%rcx), %eax
jne 0xb1aa
jmp 0xb1c9
leaq 0x6726(%rip), %rdi      # 0x118d7
leaq 0x5de0(%rip), %rsi      # 0x10f98
movl $0x1cc, %edx            # imm = 0x1CC
leaq 0x66c8(%rip), %rcx      # 0x1188c
callq 0x21a0
movq 0xb640(%rip), %rdi      # 0x16810
movq -0x50(%rbp), %rsi
callq 0x78d0
movq -0x50(%rbp), %rdi
callq 0x8ea0
movq $0x0, -0x50(%rbp)
jmp 0xb1ee
jmp 0xb1ee
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x40(%rbp)
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, %eax
jne 0xb179
movslq -0x34(%rbp), %rax
cmpq $0x28, %rax
jne 0xb21b
jmp 0xb078
jmp 0xb21d
jmp 0xb21f
xorl %eax, %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)