// File: /workspace/github_c_makefile_star2_O1/hilbix[P]unbuffered/unbuffered.c
// Function: unbuffered
static void
unbuffered(const char *arg0, int argc, char **argv)
{
  TINO_BUF	buf;
  int		fd_target;

  if (!line_cont_suffix && !flag_hexdump)
    line_cont_suffix = (flag_localtime || flag_linecount || flag_utc || flag_verbose) ? "\n" : "";
  producer	= 0;
  fd_target	= fd_write<0 ? 1 : fd_write;
  if (argc)
    {
      int	fds[2], redir[TINO_OPEN_MAX], fdmax, i;

      if (tino_file_pipeE(fds))
        tino_exit("cannot create pipe");

      fdmax = fd_in<3 ? 3 : fd_in+1;

      for (i=fdmax; --i>=0; )
        redir[i] = -1;				/* preserve all FDs	*/

      if (fd_in<0)
        fd_in = 1;

      redir[2] = flag_both ? fds[1] : 2;	/* catch stderr on -d, too	*/
      if (fd_in==2)
        redir[1] = redir[2];			/* swap stdin/stderr on -i2	*/
      redir[fd_in] = fds[!!fd_in];		/* catch 0:input else:output of producer	*/

      tino_file_close_on_exec_setE(fds[!fd_in]);	/* we do not want to keep the other one	*/

      /* catch the child's 0:input else:output for preprocessing
       */
      producer = tino_fork_execO(redir, fdmax, argv, NULL, 0, NULL);
      tino_file_closeE(fds[!!fd_in]);		/* close the used side of pipe	*/
      if (fd_in)
        fd_in = fds[0];
      else
        fd_target = fds[1];			/* write input to producer	*/

      if (flag_killme)
        {
          /* Following is a mess.  It is only needed for a consumer, though.
           * With a producer we see EOF on the pipe.
           * Shall be handled implicitely by a library somehow:
           */
          consumer	= producer;		/* it's a static, so 0 if not set here */
          tino_sigset(SIGCHLD, terminate);
          terminate();	/* catch early terminated childs	*/
        }
    }

  tino_buf_initO(&buf);
  if (producer && flag_verbose)
    {
      start_line(1, 1);
      add_prefix("start");
      for (; *argv; argv++)
        add_prefix(" '%s'", *argv);	/* XXX TODO sadly, escape is implemented in tino_io, not in tino_buf	*/
      add_prefix("\n");
      out_open();
      tino_data_putsA(&out, tino_buf_get_sN(&prefix));
    }

  if (fd_in<0)
    fd_in = 0;
  tino_file_blockE(fd_in);
  while (tino_buf_readE(&buf, fd_in, -1))
    {
      size_t		n;

      out_open();
      /* XXX TODO MISSING:
       * for flag_buffer==1 or flag_buffer==2
       * immediately write STDOUT(1),
       * but buffer STDERR(dump_line)
       */
      while ((n=tino_buf_get_lenO(&buf))>0)
        {
          const char	*ptr;
          size_t	k, p;

          ptr	= tino_buf_getN(&buf);
          p	= 0;
          for (k=0; k<n; k++)
            if (ptr[k]==line_terminator)
              {
                dump_line(ptr+p, k-p, 1);
                p	= k+1;
              }
          /* k=n	*/
          if (flag_buffer && p)
            n = p;	/* do not output incomplete line	*/
          else if ((flag_buffer>1 && n<=99999) || flag_buffer>2)
            break;		/* buffer fragments	*/

          /* We shall, nonblockingly, read additional input data here,
           * if available.  Leave this to future.
           */
          TINO_XXX;

          if (p<n)
            dump_line(ptr+p, n-p, 0);
          if (flag_cat)
            tino_buf_advanceO(&buf, n);
          else if (tino_buf_write_away_allE(&buf, fd_target, n))
            {
              /* silently drop out	*/
              *tino_main_errflag	= 1;
              break;
            }
          if (flag_buffer)
            break;
        }
      out_flush();
    }
  {
      size_t		n;

      /* in case of flag_buffer: send the rest	*/
      if ((n=tino_buf_get_lenO(&buf))>0)
        {
          const char	*ptr;

          out_open();
          ptr	= tino_buf_getN(&buf);
          dump_line(ptr, n, 0);
          if (!flag_cat && tino_buf_write_away_allE(&buf, fd_target, n))
            *tino_main_errflag	= 1;
        }
  }
  if (producer)
    {
      char *cause;

      if (consumer)
        tino_sigdummy(SIGCHLD);	/* prevent reentrance of waitpid()	*/

      /* wait for child to finish after the pipe was closed,
       * so give the child the chance to terminate.
       */
      tino_file_closeE(fd_in);
      if (fd_out != fd_target)
        tino_file_closeE(fd_target);
      *tino_main_errflag	= tino_wait_child_exact(producer, &cause);
      if (flag_verbose)
        {
          start_line(1, 1);
          add_prefix("end %s\n", cause);
          out_open();
          tino_data_putsA(&out, tino_buf_get_sN(&prefix));
        }
    }
  out_close();			/* close(2)	*/
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2028, %rsp           # imm = 0x2028
movq %rdx, %r14
cmpq $0x0, 0x9a00(%rip)      # 0xe290
jne 0x48d1
cmpl $0x0, 0x9a1f(%rip)      # 0xe2b8
jne 0x48d1
movl 0x99db(%rip), %eax      # 0xe27c
orl 0x99cd(%rip), %eax      # 0xe274
cmpl $0x0, 0x9a02(%rip)      # 0xe2b0
leaq 0x59bc(%rip), %rcx      # 0xa271
leaq 0x56d3(%rip), %rdx      # 0x9f8f
cmovneq %rdx, %rcx
orl 0x99e6(%rip), %eax      # 0xe2ac
cmovneq %rdx, %rcx
movq %rcx, 0x99bf(%rip)      # 0xe290
movl $0x0, 0x99f5(%rip)      # 0xe2d0
movl 0x99d3(%rip), %eax      # 0xe2b4
testl %eax, %eax
movl $0x1, %ebx
cmovnsl %eax, %ebx
testl %esi, %esi
je 0x4a2d
leaq 0x8(%rsp), %rdi
callq 0x2190
testl %eax, %eax
jne 0x4e20
movl 0x9960(%rip), %r15d     # 0xe26c
leal 0x1(%r15), %eax
cmpl $0x3, %r15d
movl $0x3, %r13d
cmovgel %eax, %r13d
testl %r13d, %r13d
jle 0x493c
movl %r13d, %edx
shlq $0x2, %rdx
leaq 0x1020(%rsp), %rdi
movl $0xff, %esi
callq 0x2170
testl %r15d, %r15d
jns 0x494b
movl $0x1, 0x9921(%rip)      # 0xe26c
cmpl $0x0, 0x9916(%rip)      # 0xe268
movl $0x2, %ecx
je 0x495d
movl 0xc(%rsp), %ecx
movl %ecx, 0x1028(%rsp)
movslq 0x9901(%rip), %rax      # 0xe26c
cmpq $0x2, %rax
jne 0x4978
movl %ecx, 0x1024(%rsp)
xorl %ecx, %ecx
xorl %edx, %edx
testl %eax, %eax
setne %cl
movl 0x8(%rsp,%rcx,4), %ecx
movl %ecx, 0x1020(%rsp,%rax,4)
sete %dl
movl 0x8(%rsp,%rdx,4), %ebp
movl %ebp, %edi
movl $0x1, %esi
xorl %eax, %eax
callq 0x2260
cmpl $-0x1, %eax
je 0x49bd
movl %eax, %edx
orl $0x1, %edx
cmpl %edx, %eax
je 0x49bd
movl %ebp, %edi
movl $0x2, %esi
xorl %eax, %eax
callq 0x2260
callq 0x2320
cmpl $-0x1, %eax
je 0x4e29
testl %eax, %eax
je 0x4e37
movl %eax, 0x98f7(%rip)      # 0xe2d0
xorl %eax, %eax
cmpl $0x0, 0x988a(%rip)      # 0xe26c
setne %al
movl 0x8(%rsp,%rax,4), %edi
callq 0x54e6
cmpl $0x0, 0x9877(%rip)      # 0xe26c
je 0x4a03
movl 0x8(%rsp), %eax
movl %eax, 0x986b(%rip)      # 0xe26c
jmp 0x4a07
movl 0xc(%rsp), %ebx
cmpl $0x0, 0x9862(%rip)      # 0xe270
je 0x4a2d
movl 0x98ba(%rip), %eax      # 0xe2d0
movl %eax, 0x98b8(%rip)      # 0xe2d4
leaq 0x31ae(%rip), %rdi      # 0x7bd1
callq 0x7346
callq 0x7bd1
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
cmpl $0x0, 0x988f(%rip)      # 0xe2d0
je 0x4ac0
cmpl $0x0, 0x9866(%rip)      # 0xe2b0
je 0x4ac0
movl $0x1, %edi
movl $0x1, %esi
callq 0x73f7
leaq 0x5f58(%rip), %rdi      # 0xa9ba
xorl %eax, %eax
callq 0x75b3
movq (%r14), %rsi
testq %rsi, %rsi
je 0x4a92
addq $0x8, %r14
leaq 0x5ef4(%rip), %r15      # 0xa970
movq %r15, %rdi
xorl %eax, %eax
callq 0x75b3
movq (%r14), %rsi
addq $0x8, %r14
testq %rsi, %rsi
jne 0x4a7c
leaq 0x54f6(%rip), %rdi      # 0x9f8f
xorl %eax, %eax
callq 0x75b3
callq 0x76a2
callq 0x772f
movq %rax, %r14
movq %rax, %rdi
callq 0x20f0
movq %r14, %rdi
movq %rax, %rsi
callq 0x7f65
cmpl $0x0, 0x97a5(%rip)      # 0xe26c
jns 0x4ad3
movl $0x0, 0x9799(%rip)      # 0xe26c
movl 0x9793(%rip), %ebp      # 0xe26c
movl %ebp, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2260
cmpl $-0x1, %eax
je 0x4b08
movl %eax, %edx
andl $0xfffff7ff, %edx       # imm = 0xFFFFF7FF
cmpl %edx, %eax
je 0x4b08
movl %ebp, %edi
movl $0x4, %esi
xorl %eax, %eax
callq 0x2260
leaq 0x20(%rsp), %r14
movl 0x9759(%rip), %ebp      # 0xe26c
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rax
leaq 0x14000(%rsi), %rcx
cmpq %rax, %rcx
jb 0x4b3b
subq %rax, %rsi
addq $0x14001, %rsi          # imm = 0x14001
movq %r14, %rdi
callq 0x5136
movq 0x38(%rsp), %r12
addq 0x20(%rsp), %r12
movl $0x14000, %edx          # imm = 0x14000
movl %ebp, %edi
movq %r12, %rsi
callq 0x21b0
movq %rax, %r15
testl %r15d, %r15d
jns 0x4b66
callq 0x2070
cmpl $0x4, (%rax)
je 0x4b45
testl %r15d, %r15d
jle 0x4b78
movl %r15d, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rax, 0x20(%rsp)
testl %r15d, %r15d
je 0x4c77
callq 0x76a2
movq 0x20(%rsp), %r13
movq 0x30(%rsp), %r15
subq %r15, %r13
je 0x4c60
addq 0x38(%rsp), %r15
xorl %eax, %eax
xorl %r12d, %r12d
movb (%r15,%r12), %cl
cmpb 0x96fb(%rip), %cl       # 0xe2a8
jne 0x4bc8
leaq (%r15,%rax), %rdi
movq %r12, %rsi
subq %rax, %rsi
movl $0x1, %edx
callq 0x7783
leaq 0x1(%r12), %rax
incq %r12
cmpq %r12, %r13
jne 0x4ba3
movl 0x968a(%rip), %ecx      # 0xe260
testl %ecx, %ecx
setne %dl
testq %rax, %rax
setne %sil
movq %rax, %r12
testb %sil, %dl
jne 0x4c08
cmpl $0x2, %ecx
setge %dl
cmpq $0x186a0, %r13          # imm = 0x186A0
setb %sil
cmpl $0x2, %ecx
jg 0x4c60
movq %r13, %r12
andb %dl, %sil
jne 0x4c60
movq %r12, %rsi
subq %rax, %rsi
jbe 0x4c1d
addq %rax, %r15
movq %r15, %rdi
xorl %edx, %edx
callq 0x7783
cmpl $0x0, 0x9640(%rip)      # 0xe264
je 0x4c33
movq %r14, %rdi
movl %r12d, %esi
callq 0x79de
jmp 0x4c44
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %edx
callq 0x7a4a
testl %eax, %eax
jne 0x4c53
cmpl $0x0, 0x9615(%rip)      # 0xe260
je 0x4b86
jmp 0x4c60
movq 0x966e(%rip), %rax      # 0xe2c8
movl $0x1, (%rax)
cmpl $0x0, 0x96e9(%rip)      # 0xe350
jle 0x4b0d
callq 0x7ae4
jmp 0x4b0d
movq 0x20(%rsp), %r14
subq 0x30(%rsp), %r14
je 0x4cc5
callq 0x76a2
movq 0x38(%rsp), %rdi
addq 0x30(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x7783
cmpl $0x0, 0x95c1(%rip)      # 0xe264
jne 0x4cc5
leaq 0x20(%rsp), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x7a4a
testl %eax, %eax
je 0x4cc5
movq 0x9609(%rip), %rax      # 0xe2c8
movl $0x1, (%rax)
cmpl $0x0, 0x9604(%rip)      # 0xe2d0
je 0x4e09
cmpl $0x0, 0x95fb(%rip)      # 0xe2d4
je 0x4ce7
leaq 0x3468(%rip), %rdi      # 0x814a
callq 0x7346
movl 0x957f(%rip), %edi      # 0xe26c
callq 0x54e6
cmpl %ebx, 0x9588(%rip)      # 0xe280
je 0x4d01
movl %ebx, %edi
callq 0x54e6
movl 0x95c9(%rip), %eax      # 0xe2d0
leaq 0x1020(%rsp), %rdi
movl %eax, (%rdi)
leaq 0x8(%rsp), %rbx
movq $-0x1, %rsi
movq %rbx, %rdx
callq 0x7c5c
movl (%rbx), %eax
testb %al, %al
leaq 0x5d84(%rip), %rcx      # 0xaab4
leaq 0x5d84(%rip), %rsi      # 0xaabb
cmovnsq %rcx, %rsi
movl %eax, %edx
andl $0x7f, %edx
je 0x4d6d
movl %edx, %ecx
shll $0x18, %ecx
addl $0x1000000, %ecx        # imm = 0x1000000
cmpl $0x2000000, %ecx        # imm = 0x2000000
jl 0x4d85
leaq 0x5d7d(%rip), %rdi      # 0xaad9
xorl %eax, %eax
callq 0x7cb9
movq %rax, %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4db7
movzbl %ah, %ebp
leaq 0x5d50(%rip), %rdi      # 0xaac7
movl %ebp, %edx
xorl %eax, %eax
callq 0x7cb9
movq %rax, %rbx
jmp 0x4db7
testb %al, %al
js 0x4da1
leaq 0x5d6e(%rip), %rdi      # 0xaafe
xorl %eax, %eax
callq 0x7cb9
movq %rax, %rbx
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jmp 0x4db7
leaq 0x5d43(%rip), %rdi      # 0xaaeb
xorl %eax, %eax
callq 0x7cb9
movq %rax, %rbx
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movq 0x950a(%rip), %rax      # 0xe2c8
movl %ebp, (%rax)
cmpl $0x0, 0x94e9(%rip)      # 0xe2b0
je 0x4e09
movl $0x1, %edi
movl $0x1, %esi
callq 0x73f7
leaq 0x5be1(%rip), %rdi      # 0xa9c0
movq %rbx, %rsi
xorl %eax, %eax
callq 0x75b3
callq 0x76a2
callq 0x772f
movq %rax, %rbx
movq %rax, %rdi
callq 0x20f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7f65
callq 0x7ae4
addq $0x2028, %rsp           # imm = 0x2028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5b80(%rip), %rdi      # 0xa9a7
jmp 0x4e30
leaq 0x5b98(%rip), %rdi      # 0xa9c8
xorl %eax, %eax
callq 0x72be
cmpl $0x401, %r13d           # imm = 0x401
jl 0x4e45
callq 0x2a1f
leaq 0x20(%rsp), %rdi
movl $0x1000, %edx           # imm = 0x1000
xorl %esi, %esi
callq 0x2170
movl %r13d, %edx
testl %r13d, %r13d
jle 0x4e88
leaq 0x1(%rdx), %rax
movslq 0x1018(%rsp,%rax,4), %rcx
testq %rcx, %rcx
js 0x4e7f
cmpl $0x400, %ecx            # imm = 0x400
jge 0x4f81
incl 0x20(%rsp,%rcx,4)
decq %rax
cmpq $0x1, %rax
jg 0x4e62
leaq -0x1(%rdx), %rax
movq %rax, 0x18(%rsp)
incq %rdx
movq %rdx, 0x10(%rsp)
testl %r13d, %r13d
jle 0x4f16
xorl %ebp, %ebp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq 0x18(%rsp), %r15
movl 0x1020(%rsp,%r15,4), %r12d
testl %r12d, %r12d
sets %al
cmpq %r12, %r15
sete %cl
orb %al, %cl
jne 0x4eff
cmpl $0x0, 0x20(%rsp,%r15,4)
je 0x4ecf
movl %r15d, %ebx
jmp 0x4eff
movl %r12d, %edi
movl %r15d, %esi
callq 0x2100
movl $0x1, 0x20(%rsp,%r15,4)
decl 0x20(%rsp,%r12,4)
jne 0x4ef7
movl %r12d, %edi
callq 0x2180
movl $0x1, %ebp
movl %r15d, 0x1020(%rsp,%r15,4)
leaq -0x1(%r15), %rax
incq %r15
cmpq $0x1, %r15
movq %rax, %r15
jg 0x4eaa
testl %ebp, %ebp
sete %al
jmp 0x4f1d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movb $0x1, %al
testb %al, %al
je 0x4e99
testl %ebx, %ebx
js 0x4f86
movl %ebx, %edi
callq 0x2140
testl %eax, %eax
js 0x4f9b
cmpl $0x400, %eax            # imm = 0x400
jge 0x4fa2
movl %eax, %ecx
cmpl $0x0, 0x20(%rsp,%rcx,4)
jne 0x4fa7
movl %ebx, %edx
testl %r13d, %r13d
jle 0x4f71
movq 0x10(%rsp), %rsi
cmpl %ebx, 0x1018(%rsp,%rsi,4)
jne 0x4f68
incl 0x20(%rsp,%rcx,4)
movl %eax, 0x1018(%rsp,%rsi,4)
decl 0x20(%rsp,%rdx,4)
decq %rsi
cmpq $0x1, %rsi
jg 0x4f50
cmpl $0x0, 0x20(%rsp,%rdx,4)
je 0x4e99
callq 0x2920
callq 0x29e0
movq (%r14), %rdi
movq %r14, %rsi
callq 0x22b0
movq (%r14), %rdx
xorl %eax, %eax
callq 0x7b43
movl %ebx, %edi
callq 0x29a2
callq 0x2961
callq 0x28df