// File: /workspace/github_c_makefile_star2_O3/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, 0x8bd0(%rip)      # 0xd290
jne 0x4701
cmpl $0x0, 0x8bef(%rip)      # 0xd2b8
jne 0x4701
movl 0x8bab(%rip), %eax      # 0xd27c
orl 0x8b9d(%rip), %eax      # 0xd274
cmpl $0x0, 0x8bd2(%rip)      # 0xd2b0
leaq 0x4adf(%rip), %rcx      # 0x91c4
leaq 0x490b(%rip), %rdx      # 0x8ff7
cmovneq %rdx, %rcx
orl 0x8bb6(%rip), %eax      # 0xd2ac
cmovneq %rdx, %rcx
movq %rcx, 0x8b8f(%rip)      # 0xd290
movl $0x0, 0x8bc5(%rip)      # 0xd2d0
movl 0x8ba3(%rip), %eax      # 0xd2b4
testl %eax, %eax
movl $0x1, %ebx
cmovnsl %eax, %ebx
testl %esi, %esi
je 0x479c
leaq 0x8(%rsp), %rdi
callq 0x2190
testl %eax, %eax
jne 0x4c85
movl 0x8b34(%rip), %r12d     # 0xd26c
leal 0x1(%r12), %eax
cmpl $0x3, %r12d
movl $0x3, %r15d
cmovgel %eax, %r15d
testl %r15d, %r15d
jle 0x4769
movl %r15d, %edx
shlq $0x2, %rdx
leaq 0x1020(%rsp), %rdi
movl $0xff, %esi
callq 0x2170
testl %r12d, %r12d
js 0x47ae
cmpl $0x0, 0x8af3(%rip)      # 0xd268
movl $0x2, %eax
je 0x4780
movl 0xc(%rsp), %eax
movl %eax, 0x1028(%rsp)
cmpl $0x2, %r12d
jne 0x47d7
movl %eax, 0x1024(%rsp)
movl $0x2, %r12d
jmp 0x47d7
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
jmp 0x4923
movl $0x1, 0x8ab4(%rip)      # 0xd26c
cmpl $0x0, 0x8aa9(%rip)      # 0xd268
movl $0x2, %eax
je 0x47ca
movl 0xc(%rsp), %eax
movl %eax, 0x1028(%rsp)
movl $0x1, %r12d
xorl %eax, %eax
xorl %ecx, %ecx
testl %r12d, %r12d
setne %al
movl 0x8(%rsp,%rax,4), %eax
movl %r12d, %edx
movl %eax, 0x1020(%rsp,%rdx,4)
sete %cl
movl 0x8(%rsp,%rcx,4), %ebp
movl %ebp, %edi
movl $0x1, %esi
xorl %eax, %eax
callq 0x2260
cmpl $-0x1, %eax
je 0x4820
movl %eax, %edx
orl $0x1, %edx
cmpl %edx, %eax
je 0x4820
movl %ebp, %edi
movl $0x2, %esi
xorl %eax, %eax
callq 0x2260
callq 0x2320
cmpl $-0x1, %eax
je 0x4c8e
testl %eax, %eax
je 0x4c9c
movl %eax, 0x8a94(%rip)      # 0xd2d0
xorl %eax, %eax
cmpl $0x0, 0x8a27(%rip)      # 0xd26c
setne %al
movl 0x8(%rsp,%rax,4), %edi
callq 0x5363
cmpl $0x0, 0x8a14(%rip)      # 0xd26c
je 0x4866
movl 0x8(%rsp), %eax
movl %eax, 0x8a08(%rip)      # 0xd26c
jmp 0x486a
movl 0xc(%rsp), %ebx
cmpl $0x0, 0x89ff(%rip)      # 0xd270
je 0x4890
movl 0x8a57(%rip), %eax      # 0xd2d0
movl %eax, 0x8a55(%rip)      # 0xd2d4
leaq 0x3155(%rip), %rdi      # 0x79db
callq 0x717c
callq 0x79db
cmpl $0x0, 0x8a39(%rip)      # 0xd2d0
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movaps %xmm0, 0x30(%rsp)
je 0x4923
cmpl $0x0, 0x8a03(%rip)      # 0xd2b0
je 0x4923
movl $0x1, %edi
movl $0x1, %esi
callq 0x7233
leaq 0x512c(%rip), %rdi      # 0x99f1
xorl %eax, %eax
callq 0x73f1
movq (%r14), %rsi
testq %rsi, %rsi
je 0x48f5
addq $0x8, %r14
leaq 0x50c8(%rip), %r15      # 0x99a7
movq %r15, %rdi
xorl %eax, %eax
callq 0x73f1
movq (%r14), %rsi
addq $0x8, %r14
testq %rsi, %rsi
jne 0x48df
leaq 0x46fb(%rip), %rdi      # 0x8ff7
xorl %eax, %eax
callq 0x73f1
callq 0x74e0
callq 0x7553
movq %rax, %r14
movq %rax, %rdi
callq 0x20f0
movq %r14, %rdi
movq %rax, %rsi
callq 0x7d71
movl 0x8943(%rip), %ebp      # 0xd26c
testl %ebp, %ebp
jns 0x4939
movl $0x0, 0x8935(%rip)      # 0xd26c
xorl %ebp, %ebp
movl %ebp, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2260
cmpl $-0x1, %eax
je 0x4968
movl %eax, %edx
andl $0xfffff7ff, %edx       # imm = 0xFFFFF7FF
cmpl %edx, %eax
je 0x4968
movl %ebp, %edi
movl $0x4, %esi
xorl %eax, %eax
callq 0x2260
leaq 0x20(%rsp), %r14
movl 0x88f9(%rip), %ebp      # 0xd26c
movq 0x20(%rsp), %r15
movq 0x28(%rsp), %rax
leaq 0x14000(%r15), %rcx
cmpq %rax, %rcx
jb 0x49a3
subq %rax, %r15
addq $0x14001, %r15          # imm = 0x14001
movq %r14, %rdi
movq %r15, %rsi
callq 0x4f9e
movq 0x20(%rsp), %r15
addq 0x38(%rsp), %r15
movl $0x14000, %edx          # imm = 0x14000
movl %ebp, %edi
movq %r15, %rsi
callq 0x21b0
testl %eax, %eax
jns 0x49c7
callq 0x2070
cmpl $0x4, (%rax)
je 0x49a8
jmp 0x49d7
je 0x4ace
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rax, 0x20(%rsp)
callq 0x74e0
movq 0x20(%rsp), %r13
movq 0x30(%rsp), %r15
subq %r15, %r13
je 0x4ab7
addq 0x38(%rsp), %r15
movb 0x88ae(%rip), %cl       # 0xd2a8
xorl %eax, %eax
xorl %r12d, %r12d
cmpb %cl, (%r15,%r12)
jne 0x4a27
leaq (%r15,%rax), %rdi
movq %r12, %rsi
subq %rax, %rsi
movl $0x1, %edx
callq 0x75a7
incq %r12
movb 0x8886(%rip), %cl       # 0xd2a8
movq %r12, %rax
jmp 0x4a2a
incq %r12
cmpq %r13, %r12
jne 0x49ff
movl 0x882b(%rip), %ecx      # 0xd260
testl %ecx, %ecx
je 0x4a41
movq %rax, %r12
testq %rax, %rax
jne 0x4a5f
cmpl $0x2, %ecx
setge %dl
cmpq $0x186a0, %r13          # imm = 0x186A0
setb %sil
cmpl $0x2, %ecx
jg 0x4ab7
movq %r13, %r12
andb %dl, %sil
jne 0x4ab7
movq %r12, %rsi
subq %rax, %rsi
jbe 0x4a74
addq %rax, %r15
movq %r15, %rdi
xorl %edx, %edx
callq 0x75a7
cmpl $0x0, 0x87e9(%rip)      # 0xd264
je 0x4a8a
movq %r14, %rdi
movl %r12d, %esi
callq 0x7806
jmp 0x4a9b
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %edx
callq 0x7872
testl %eax, %eax
jne 0x4aaa
cmpl $0x0, 0x87be(%rip)      # 0xd260
je 0x49dc
jmp 0x4ab7
movq 0x8817(%rip), %rax      # 0xd2c8
movl $0x1, (%rax)
cmpl $0x0, 0x8892(%rip)      # 0xd350
jle 0x496d
callq 0x78ee
jmp 0x496d
movq 0x20(%rsp), %r14
subq 0x30(%rsp), %r14
je 0x4b1c
callq 0x74e0
movq 0x38(%rsp), %rdi
addq 0x30(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x75a7
cmpl $0x0, 0x876a(%rip)      # 0xd264
jne 0x4b1c
leaq 0x20(%rsp), %rdi
movl %ebx, %esi
movl %r14d, %edx
callq 0x7872
testl %eax, %eax
je 0x4b1c
movq 0x87b2(%rip), %rax      # 0xd2c8
movl $0x1, (%rax)
cmpl $0x0, 0x87ad(%rip)      # 0xd2d0
je 0x4c6e
cmpl $0x0, 0x87a4(%rip)      # 0xd2d4
je 0x4b3e
leaq 0x341d(%rip), %rdi      # 0x7f56
callq 0x717c
movl 0x8728(%rip), %edi      # 0xd26c
callq 0x5363
cmpl %ebx, 0x8731(%rip)      # 0xd280
je 0x4b58
movl %ebx, %edi
callq 0x5363
movl 0x8772(%rip), %eax      # 0xd2d0
leaq 0x1020(%rsp), %rdi
movl %eax, (%rdi)
leaq 0x8(%rsp), %rbx
movq $-0x1, %rsi
movq %rbx, %rdx
callq 0x7a54
movl (%rbx), %eax
testb %al, %al
leaq 0x4f64(%rip), %rcx      # 0x9aeb
leaq 0x4f64(%rip), %rsi      # 0x9af2
cmovnsq %rcx, %rsi
movl %eax, %edx
andl $0x7f, %edx
je 0x4bc4
movl %edx, %ecx
shll $0x18, %ecx
addl $0x1000000, %ecx        # imm = 0x1000000
cmpl $0x2000000, %ecx        # imm = 0x2000000
jl 0x4bdc
leaq 0x4f5d(%rip), %rdi      # 0x9b10
xorl %eax, %eax
callq 0x7ab1
movq %rax, %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4c1c
movzbl %ah, %ebp
leaq 0x4f30(%rip), %rdi      # 0x9afe
movl %ebp, %edx
xorl %eax, %eax
callq 0x7ab1
movq %rax, %rbx
jmp 0x4c1c
testb %al, %al
js 0x4bff
leaq 0x4f4e(%rip), %rdi      # 0x9b35
leaq 0x4efd(%rip), %rsi      # 0x9aeb
xorl %eax, %eax
callq 0x7ab1
movq %rax, %rbx
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
jmp 0x4c1c
leaq 0x4f1c(%rip), %rdi      # 0x9b22
leaq 0x4ee5(%rip), %rsi      # 0x9af2
xorl %eax, %eax
callq 0x7ab1
movq %rax, %rbx
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movq 0x86a5(%rip), %rax      # 0xd2c8
movl %ebp, (%rax)
cmpl $0x0, 0x8684(%rip)      # 0xd2b0
je 0x4c6e
movl $0x1, %edi
movl $0x1, %esi
callq 0x7233
leaq 0x4db3(%rip), %rdi      # 0x99f7
movq %rbx, %rsi
xorl %eax, %eax
callq 0x73f1
callq 0x74e0
callq 0x7553
movq %rax, %rbx
movq %rax, %rdi
callq 0x20f0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7d71
callq 0x78ee
addq $0x2028, %rsp           # imm = 0x2028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4d52(%rip), %rdi      # 0x99de
jmp 0x4c95
leaq 0x4d6a(%rip), %rdi      # 0x99ff
xorl %eax, %eax
callq 0x70f4
cmpl $0x401, %r15d           # imm = 0x401
jl 0x4caa
callq 0x2ab7
leaq 0x20(%rsp), %rdi
movl $0x1000, %edx           # imm = 0x1000
xorl %esi, %esi
callq 0x2170
testl %r15d, %r15d
jle 0x4dec
movl %r15d, %eax
movq %rax, 0x10(%rsp)
incq %rax
movslq 0x1018(%rsp,%rax,4), %rcx
testq %rcx, %rcx
js 0x4cec
cmpl $0x400, %ecx            # imm = 0x400
jae 0x4e01
incl 0x20(%rsp,%rcx,4)
decq %rax
cmpq $0x1, %rax
ja 0x4ccf
movq 0x10(%rsp), %rbp
leaq 0x1(%rbp), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
leaq -0x1(%rbp), %r15
movl 0x101c(%rsp,%rbp,4), %ebx
testl %ebx, %ebx
sets %al
cmpq %rbx, %r15
sete %cl
orb %al, %cl
jne 0x4d5f
cmpl $0x0, 0x1c(%rsp,%rbp,4)
je 0x4d32
movl %r15d, %ebx
jmp 0x4d62
movl %ebx, %edi
movl %r15d, %esi
callq 0x2100
movl $0x1, 0x1c(%rsp,%rbp,4)
decl 0x20(%rsp,%rbx,4)
jne 0x4d57
movl %ebx, %edi
callq 0x2180
movl $0x1, %r13d
movl %r15d, 0x101c(%rsp,%rbp,4)
movl %r12d, %ebx
movl %ebx, %r12d
cmpq $0x1, %rbp
movq %r15, %rbp
jg 0x4d0c
movq 0x10(%rsp), %rbp
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %r13d, %r13d
movl $0x0, %r13d
jne 0x4d0c
testl %ebx, %ebx
js 0x4dec
movl %ebx, %edi
callq 0x2140
testl %eax, %eax
js 0x4e06
cmpl $0x400, %eax            # imm = 0x400
jae 0x4e0d
movl %eax, %ecx
cmpl $0x0, 0x20(%rsp,%rcx,4)
jne 0x4e12
movl %ebx, %edx
movq 0x18(%rsp), %rsi
cmpl %ebx, 0x1018(%rsp,%rsi,4)
jne 0x4dc2
incl 0x20(%rsp,%rcx,4)
movl %eax, 0x1018(%rsp,%rsi,4)
decl 0x20(%rsp,%rdx,4)
decq %rsi
cmpq $0x1, %rsi
jg 0x4daa
cmpl $0x0, 0x20(%rsp,%rdx,4)
movq 0x10(%rsp), %rbp
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0x0, %r13d
je 0x4d0c
callq 0x29b8
movq (%r14), %rdi
movq %r14, %rsi
callq 0x22b0
movq (%r14), %rdx
xorl %eax, %eax
callq 0x794d
callq 0x2a78
movl %ebx, %edi
callq 0x2a3a
callq 0x29f9
callq 0x2977