// File: /workspace/github_c_makefile_star2_O1/albertito[P]libfiu/libfiu/fiu-rc.c
// Function: rc_fifo_thread
static void *rc_fifo_thread(void *unused)
{
	int fdr, fdw, r, errcount;

	/* increment the recursion count so we're not affected by libfiu,
	 * otherwise we could make the remote control useless by enabling all
	 * failure points */
	rec_count++;

	errcount = 0;

reopen:
	if (errcount > 10) {
		fprintf(stderr, "libfiu: Too many errors in remote control "
		                "thread, shutting down\n");
		return NULL;
	}

	fdr = open(npipe_path_in, O_RDONLY);
	if (fdr < 0)
		return NULL;

	fdw = open(npipe_path_out, O_WRONLY);
	if (fdw < 0) {
		close(fdr);
		return NULL;
	}

	for (;;) {
		r = rc_do_command(fdr, fdw);
		if (r < 0 && errno != EPIPE) {
			perror("libfiu: Error reading from remote control");
			errcount++;
			close(fdr);
			close(fdw);
			goto reopen;
		} else if (r == 0 || (r < 0 && errno == EPIPE)) {
			/* one of the ends of the pipe was closed */
			close(fdr);
			close(fdw);
			goto reopen;
		}
	}

	/* we never get here */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
leaq 0x5056(%rip), %rdi      # 0x7fd8
callq 0x21e0
incl (%rax)
movl $0x0, 0xc(%rsp)
leaq 0x220(%rsp), %rbx
leaq 0x20(%rsp), %r14
movq $0x0, 0x10(%rsp)
movq 0x5267(%rip), %rdi      # 0x8218
xorl %esi, %esi
xorl %eax, %eax
callq 0x2290
testl %eax, %eax
js 0x3145
movl %eax, %ebp
movq 0x5255(%rip), %rdi      # 0x8220
movl $0x1, %esi
xorl %eax, %eax
callq 0x2290
movl %eax, %r15d
testl %eax, %eax
js 0x313e
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
xorl %r12d, %r12d
movl $0x200, %edx            # imm = 0x200
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2170
movq %rbx, %rcx
movq %rcx, %r13
movl $0x1, %edx
movl %ebp, %edi
movq %r14, %rsi
callq 0x21d0
testl %eax, %eax
js 0x3058
je 0x3042
addl %eax, %r12d
movzbl 0x20(%rsp), %eax
movb %al, (%r13)
cmpl $0x1ff, %r12d           # imm = 0x1FF
ja 0x303f
cmpl $0xa, %eax
je 0x303f
leaq 0x1(%r13), %rcx
testl %eax, %eax
jne 0x3005
incq %r13
testl %r12d, %r12d
je 0x305e
cmpb $0xa, 0x20(%rsp)
jne 0x305e
movb $0x0, -0x1(%r13)
decl %r12d
jmp 0x305e
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %r12d, %r12d
jle 0x30a4
movq %rbx, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2260
movl %eax, %r13d
testl %eax, %eax
js 0x30ce
movl $0x200, %esi            # imm = 0x200
movq %r14, %rdi
leaq 0x2172(%rip), %rdx      # 0x51f8
movl %r13d, %ecx
xorl %eax, %eax
callq 0x2140
movslq %eax, %rdx
movl %r15d, %edi
movq %r14, %rsi
callq 0x20e0
testl %eax, %eax
cmovlel %eax, %r12d
testl %r12d, %r12d
jns 0x30b3
callq 0x2060
cmpl $0x20, (%rax)
jne 0x30f6
testl %r12d, %r12d
je 0x30da
jns 0x2fe2
callq 0x2060
cmpl $0x20, (%rax)
jne 0x2fe2
jmp 0x30da
leaq 0x18(%rsp), %rdi
callq 0x2370
jmp 0x3077
movl %ebp, %edi
callq 0x2190
movl %r15d, %edi
callq 0x2190
testb $0x1, 0xc(%rsp)
je 0x2faa
jmp 0x3137
leaq 0x20b3(%rip), %rdi      # 0x51b0
callq 0x22b0
movq 0x10(%rsp), %r13
leal 0x1(%r13), %r12d
movl %ebp, %edi
callq 0x2190
movl %r15d, %edi
callq 0x2190
cmpl $0xa, %r13d
setae %al
movl %eax, 0xc(%rsp)
movl %r12d, %eax
movq %rax, 0x10(%rsp)
cmpl $0xb, %r12d
jne 0x2faa
callq 0x238e
jmp 0x3145
movl %ebp, %edi
callq 0x2190
xorl %eax, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq