// File: /workspace/github_c_makefile_star2_O3/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 0x506b(%rip), %rdi      # 0x7fd8
callq 0x21e0
incl (%rax)
movl $0x0, 0xc(%rsp)
leaq 0x220(%rsp), %rbx
leaq 0xb(%rsp), %r14
movq $0x0, 0x10(%rsp)
movq 0x5284(%rip), %rdi      # 0x8220
xorl %esi, %esi
xorl %eax, %eax
callq 0x22a0
testl %eax, %eax
js 0x3129
movl %eax, %r15d
movq 0x5271(%rip), %rdi      # 0x8228
movl $0x1, %esi
xorl %eax, %eax
callq 0x22a0
movl %eax, %r13d
testl %eax, %eax
js 0x3121
movq $0x0, 0x18(%rsp)
movb $0x0, 0xb(%rsp)
xorl %r12d, %r12d
movl $0x200, %edx            # imm = 0x200
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2170
movq %rbx, %rax
movq %rax, %rbp
movl $0x1, %edx
movl %r15d, %edi
movq %r14, %rsi
callq 0x21d0
testl %eax, %eax
js 0x30b2
movb 0xb(%rsp), %cl
je 0x3034
addl %eax, %r12d
movb %cl, (%rbp)
cmpl $0x1ff, %r12d           # imm = 0x1FF
ja 0x3031
movzbl %cl, %edx
cmpl $0xa, %edx
je 0x3031
leaq 0x1(%rbp), %rax
testl %edx, %edx
jne 0x2ff1
incq %rbp
testl %r12d, %r12d
setne %al
cmpb $0xa, %cl
sete %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x304e
movb $0x0, -0x1(%rbp)
decl %r12d
testl %r12d, %r12d
jle 0x30ad
movq %rbx, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2270
movl %eax, %r12d
testl %eax, %eax
js 0x30a1
movl $0x200, %esi            # imm = 0x200
leaq 0x20(%rsp), %rbp
movq %rbp, %rdi
leaq 0x217d(%rip), %rdx      # 0x51f8
movl %r12d, %ecx
xorl %eax, %eax
callq 0x2140
movslq %eax, %rdx
movl %r13d, %edi
movq %rbp, %rsi
callq 0x20e0
movq %rax, %r12
testl %r12d, %r12d
jg 0x2fce
jmp 0x30ad
leaq 0x18(%rsp), %rdi
callq 0x2380
jmp 0x3067
testl %r12d, %r12d
jns 0x30bc
callq 0x2060
cmpl $0x20, (%rax)
jne 0x30d9
movl %r15d, %edi
callq 0x2190
movl %r13d, %edi
callq 0x2190
testb $0x1, 0xc(%rsp)
je 0x2f95
jmp 0x311a
leaq 0x20d0(%rip), %rdi      # 0x51b0
callq 0x22c0
movq 0x10(%rsp), %r12
leal 0x1(%r12), %ebp
movl %r15d, %edi
callq 0x2190
movl %r13d, %edi
callq 0x2190
cmpl $0xa, %r12d
setae %al
movl %eax, 0xc(%rsp)
movl %ebp, %eax
movq %rax, 0x10(%rsp)
cmpl $0xb, %ebp
jne 0x2f95
callq 0x239e
jmp 0x3129
movl %r15d, %edi
callq 0x2190
xorl %eax, %eax
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq