// File: /workspace/github_c_makefile_star2_O0/alexgirao[P]aimant/aimant.c
// Function: tail0loop
static int tail0loop(int fdin, int fdout)
{
	char buf[0x100000]; /* 1M */
	int bufsz = sizeof(buf);
	int eof_count = 0;

	for (;;) {
		int n;
		if ((n = read(fdin, buf, bufsz)) < 0) {
			int save_errno = errno;
			assert(n == -1);
			DEBUG("read(fdin=%i, buf, bufsz=%i), errno=%i", fdin, bufsz, save_errno);
			errno = save_errno;
			perror("read(fdin, buf, bufsz)");
			return -1;
		} else if (n) {
			int r;
			if ((r = write_exact(fdout, buf, n)) < 0) {
				int save_errno = errno;
				assert(r == -1);
				DEBUG("write_exact(fdout=%i, buf, n=%i), errno=%i", fdout, n, save_errno);
				errno = save_errno;
				perror("write_exact(fdout, buf, n)");
				return -1;
			}
			eof_count = 0;
		} else {
			/* got EOF
			 */
			int msec;
			eof_count++;

			if (eof_count >= 100) msec = 250;
			else if (eof_count >= 20) msec = 20 * 5;
			else msec = eof_count * 5;

			usleep(msec * 1000);
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100040, %rsp         # imm = 0x100040
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x100000, -0x100014(%rbp) # imm = 0x100000
movl $0x0, -0x100018(%rbp)
movl -0x8(%rbp), %edi
leaq -0x100010(%rbp), %rsi
movslq -0x100014(%rbp), %rdx
callq 0x21f0
movl %eax, -0x10001c(%rbp)
cmpl $0x0, %eax
jge 0x6b9f
callq 0x2070
movl (%rax), %eax
movl %eax, -0x100020(%rbp)
cmpl $-0x1, -0x10001c(%rbp)
jne 0x6b22
jmp 0x6b41
leaq 0x9777(%rip), %rdi      # 0x102a0
leaq 0x952c(%rip), %rsi      # 0x1005c
movl $0x529, %edx            # imm = 0x529
leaq 0xa376(%rip), %rcx      # 0x10eb2
callq 0x21a0
jmp 0x6b43
movl -0x8(%rbp), %ecx
movl -0x100014(%rbp), %r8d
movl -0x100020(%rbp), %r9d
leaq 0x9501(%rip), %rdi      # 0x1005c
movl $0x52a, %esi            # imm = 0x52A
leaq 0xa363(%rip), %rdx      # 0x10eca
movb $0x0, %al
callq 0xdfe0
movl -0x100020(%rbp), %eax
movl %eax, -0x100030(%rbp)
callq 0x2070
movl -0x100030(%rbp), %ecx
movl %ecx, (%rax)
leaq 0xa363(%rip), %rdi      # 0x10ef1
callq 0x2310
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ccc
cmpl $0x0, -0x10001c(%rbp)
je 0x6c6e
movl -0xc(%rbp), %edi
leaq -0x100010(%rbp), %rsi
movl -0x10001c(%rbp), %edx
callq 0x6ce0
movl %eax, -0x100024(%rbp)
cmpl $0x0, %eax
jge 0x6c62
callq 0x2070
movl (%rax), %eax
movl %eax, -0x100028(%rbp)
cmpl $-0x1, -0x100024(%rbp)
jne 0x6be8
jmp 0x6c07
leaq 0xaf86(%rip), %rdi      # 0x11b75
leaq 0x9466(%rip), %rsi      # 0x1005c
movl $0x532, %edx            # imm = 0x532
leaq 0xa2b0(%rip), %rcx      # 0x10eb2
callq 0x21a0
jmp 0x6c09
movl -0xc(%rbp), %ecx
movl -0x10001c(%rbp), %r8d
movl -0x100028(%rbp), %r9d
leaq 0x943b(%rip), %rdi      # 0x1005c
movl $0x533, %esi            # imm = 0x533
leaq 0xa2db(%rip), %rdx      # 0x10f08
movb $0x0, %al
callq 0xdfe0
movl -0x100028(%rbp), %eax
movl %eax, -0x100034(%rbp)
callq 0x2070
movl -0x100034(%rbp), %ecx
movl %ecx, (%rax)
leaq 0xa2df(%rip), %rdi      # 0x10f33
callq 0x2310
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x6ccc
movl $0x0, -0x100018(%rbp)
jmp 0x6cc5
movl -0x100018(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x100018(%rbp)
cmpl $0x64, -0x100018(%rbp)
jl 0x6c92
movl $0xfa, -0x10002c(%rbp)
jmp 0x6cb6
cmpl $0x14, -0x100018(%rbp)
jl 0x6ca7
movl $0x64, -0x10002c(%rbp)
jmp 0x6cb4
imull $0x5, -0x100018(%rbp), %eax
movl %eax, -0x10002c(%rbp)
jmp 0x6cb6
imull $0x3e8, -0x10002c(%rbp), %edi # imm = 0x3E8
callq 0x23c0
jmp 0x6cc7
jmp 0x6ae5
movl -0x4(%rbp), %eax
addq $0x100040, %rsp         # imm = 0x100040
popq %rbp
retq
nopl (%rax,%rax)