// File: /workspace/github_c_makefile_star2_O3/JimKent[P]linearSat/lib/linefile.c
// Function: lineFileParseHttpHeader
boolean lineFileParseHttpHeader(struct lineFile *lf, char **hdr,
				boolean *chunked, int *contentLength)
/* Extract HTTP response header from lf into hdr, tell if it's
 * "Transfer-Encoding: chunked" or if it has a contentLength. */
{
  struct dyString *header = newDyString(1024);
  char *line;
  int lineSize;

  if (chunked != NULL)
    *chunked = FALSE;
  if (contentLength != NULL)
    *contentLength = -1;
  dyStringClear(header);
  if (lineFileNext(lf, &line, &lineSize))
    {
      if (startsWith("HTTP/", line))
	{
	char *version, *code;
	dyStringAppendN(header, line, lineSize-1);
	dyStringAppendC(header, '\n');
	version = nextWord(&line);
	code = nextWord(&line);
	if (code == NULL)
	    {
	    warn("%s: Expecting HTTP/<version> <code> header line, got this: %s\n", lf->fileName, header->string);
	    *hdr = cloneString(header->string);
	    dyStringFree(&header);
	    return FALSE;
	    }
	if (!sameString(code, "200"))
	    {
	    warn("%s: Errored HTTP response header: %s %s %s\n", lf->fileName, version, code, line);
	    *hdr = cloneString(header->string);
	    dyStringFree(&header);
	    return FALSE;
	    }
	while (lineFileNext(lf, &line, &lineSize))
	    {
	    /* blank line means end of HTTP header */
	    if ((line[0] == '\r' && line[1] == 0) || line[0] == 0)
	        break;
	    if (strstr(line, "Transfer-Encoding: chunked") && chunked != NULL)
	        *chunked = TRUE;
	    dyStringAppendN(header, line, lineSize-1);
	    dyStringAppendC(header, '\n');
	    if (strstr(line, "Content-Length:"))
	      {
		code = nextWord(&line);
		code = nextWord(&line);
		if (contentLength != NULL)
		    *contentLength = atoi(code);
	      }
	    }
	}
      else
	{
	  /* put the line back, don't put it in header/hdr */
	  lineFileReuse(lf);
	  warn("%s: Expecting HTTP/<version> <code> header line, got this: %s\n", lf->fileName, header->string);
	  *hdr = cloneString(header->string);
	  dyStringFree(&header);
	  return FALSE;
	}
    }
  else
    {
      *hdr = cloneString(header->string);
      dyStringFree(&header);
      return FALSE;
    }

  *hdr = cloneString(header->string);
  dyStringFree(&header);
  return TRUE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
movl $0x400, %edi            # imm = 0x400
callq 0xad14
movq %rax, %r13
movq %rax, 0x8(%rsp)
testq %r12, %r12
je 0xe2ae
movl $0x0, (%r12)
testq %r15, %r15
je 0xe2ba
movl $0xffffffff, (%r15)     # imm = 0xFFFFFFFF
movl $0x0, 0x14(%r13)
movq 0x8(%r13), %rax
movb $0x0, (%rax)
leaq 0x18(%rsp), %rsi
leaq 0x14(%rsp), %rdx
movq %r14, %rdi
callq 0xd043
testl %eax, %eax
je 0xe37b
movq 0x18(%rsp), %rsi
leaq 0xbf66(%rip), %rdi      # 0x1a255
callq 0x8038
testl %eax, %eax
je 0xe386
movq %rbx, 0x20(%rsp)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rbx
movq (%rbx), %rsi
movl 0x14(%rsp), %edx
decl %edx
callq 0xae1e
movq 0x8(%rsp), %rdi
movl $0xa, %esi
callq 0xaeab
movq %rbx, %rdi
callq 0x7292
movq %rax, %r13
movq %rbx, %rdi
callq 0x7292
testq %rax, %rax
je 0xe3b6
movq %rax, %rbx
leaq 0xbf50(%rip), %rsi      # 0x1a29a
movq %rax, %rdi
callq 0x3440
testl %eax, %eax
je 0xe3e6
movq 0x8(%r14), %rsi
movq 0x18(%rsp), %r8
leaq 0xbf34(%rip), %rdi      # 0x1a29e
xorl %ebp, %ebp
movq %r13, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0xb41e
jmp 0xe3d3
addq $0x8, %r13
xorl %ebp, %ebp
jmp 0xe4ca
movb $0x1, 0x3c(%r14)
movq 0x8(%r14), %rsi
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0xbebc(%rip), %rdi      # 0x1a25b
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xb41e
movq 0x8(%rsp), %r13
addq $0x8, %r13
jmp 0xe4ca
movq 0x8(%r14), %rsi
movq 0x8(%rsp), %rax
movq 0x8(%rax), %rdx
leaq 0xbe91(%rip), %rdi      # 0x1a25b
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xb41e
movq 0x8(%rsp), %r13
addq $0x8, %r13
movq 0x20(%rsp), %rbx
jmp 0xe4ca
leaq 0x18(%rsp), %rsi
leaq 0x14(%rsp), %rdx
movq %r14, %rdi
callq 0xd043
testl %eax, %eax
movq 0x20(%rsp), %rbx
je 0xe4bc
leaq 0x18(%rsp), %r13
movq 0x18(%rsp), %rbp
movzbl (%rbp), %eax
cmpl $0xd, %eax
je 0xe421
testl %eax, %eax
jne 0xe42b
jmp 0xe4bc
cmpb $0x0, 0x1(%rbp)
je 0xe4bc
movq %rbp, %rdi
leaq 0xbe95(%rip), %rsi      # 0x1a2ca
callq 0x3760
testq %r12, %r12
je 0xe44c
testq %rax, %rax
je 0xe44c
movl $0x1, (%r12)
movq 0x8(%rsp), %rdi
movl 0x14(%rsp), %edx
decl %edx
movq %rbp, %rsi
callq 0xae1e
movq 0x8(%rsp), %rdi
movl $0xa, %esi
callq 0xaeab
movq 0x18(%rsp), %rdi
leaq 0xbe6b(%rip), %rsi      # 0x1a2e5
callq 0x3760
testq %rax, %rax
je 0xe4a4
movq %r13, %rdi
callq 0x7292
movq %r13, %rdi
callq 0x7292
testq %r15, %r15
je 0xe4a4
movq %rax, %rdi
callq 0x36a0
movl %eax, (%r15)
movq %r14, %rdi
movq %r13, %rsi
leaq 0x14(%rsp), %rdx
callq 0xd043
testl %eax, %eax
jne 0xe40a
movq 0x8(%rsp), %r13
addq $0x8, %r13
movl $0x1, %ebp
movq (%r13), %rdi
callq 0x6402
movq %rax, (%rbx)
leaq 0x8(%rsp), %rdi
callq 0xad51
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq