// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x400, %edi            # imm = 0x400
callq 0xf030
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x14247
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0x14258
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movq -0x30(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0x12650
cmpl $0x0, %eax
je 0x144c1
movq -0x38(%rbp), %rsi
leaq 0x10fea(%rip), %rdi     # 0x2527d
callq 0xa4b0
cmpl $0x0, %eax
je 0x1446f
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x3c(%rbp), %edx
subl $0x1, %edx
callq 0xf200
movq -0x30(%rbp), %rdi
movl $0xa, %esi
callq 0xf2b0
leaq -0x38(%rbp), %rdi
callq 0x9050
movq %rax, -0x48(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9050
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x1432d
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x10f89(%rip), %rdi     # 0x25283
movb $0x0, %al
callq 0xf8f0
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7530
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
leaq -0x30(%rbp), %rdi
callq 0xf090
movl $0x0, -0x4(%rbp)
jmp 0x14511
movq -0x50(%rbp), %rdi
leaq 0x10f8a(%rip), %rsi     # 0x252c2
callq 0x3410
cmpl $0x0, %eax
je 0x14390
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %r8
leaq 0x10f69(%rip), %rdi     # 0x252c6
movb $0x0, %al
callq 0xf8f0
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7530
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
leaq -0x30(%rbp), %rdi
callq 0xf090
movl $0x0, -0x4(%rbp)
jmp 0x14511
jmp 0x14392
movq -0x10(%rbp), %rdi
leaq -0x38(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0x12650
cmpl $0x0, %eax
je 0x1446d
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xd, %eax
jne 0x143c5
movq -0x38(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0x143d1
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x143d6
jmp 0x1446d
movq -0x38(%rbp), %rdi
leaq 0x10f11(%rip), %rsi     # 0x252f2
callq 0x3730
cmpq $0x0, %rax
je 0x143fd
cmpq $0x0, -0x20(%rbp)
je 0x143fd
movq -0x20(%rbp), %rax
movl $0x1, (%rax)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl -0x3c(%rbp), %edx
subl $0x1, %edx
callq 0xf200
movq -0x30(%rbp), %rdi
movl $0xa, %esi
callq 0xf2b0
movq -0x38(%rbp), %rdi
leaq 0x10ee4(%rip), %rsi     # 0x2530d
callq 0x3730
cmpq $0x0, %rax
je 0x14468
leaq -0x38(%rbp), %rdi
callq 0x9050
movq %rax, -0x50(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x9050
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x14466
movq -0x50(%rbp), %rdi
callq 0x3670
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x14468
jmp 0x14392
jmp 0x144bf
movq -0x10(%rbp), %rdi
callq 0x12460
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x10df4(%rip), %rdi     # 0x25283
movb $0x0, %al
callq 0xf8f0
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7530
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
leaq -0x30(%rbp), %rdi
callq 0xf090
movl $0x0, -0x4(%rbp)
jmp 0x14511
jmp 0x144ea
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7530
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
leaq -0x30(%rbp), %rdi
callq 0xf090
movl $0x0, -0x4(%rbp)
jmp 0x14511
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7530
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
leaq -0x30(%rbp), %rdi
callq 0xf090
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)