// File: /workspace/github_c_makefile_star2_O3/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: http_parse
static int
http_parse(struct soap *soap)
{ char header[SOAP_HDRLEN], *s;
  unsigned short httpcmd = 0, status = 0;
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Waiting for HTTP request/response...\n"));
  *soap->endpoint = '\0';
  soap->length = 0;
  soap->userid = NULL;
  soap->passwd = NULL;
  soap->action = NULL;
  soap->authrealm = NULL;
  soap->proxy_from = NULL;
  soap->http_content = NULL;
  soap->status = 0;
  do
  { if (soap_getline(soap, soap->msgbuf, sizeof(soap->msgbuf)))
    { if (soap->error == SOAP_EOF)
        return SOAP_EOF;
      return soap->error = 414;
    }
    if ((s = strchr(soap->msgbuf, ' ')))
    { soap->status = (unsigned short)soap_strtoul(s, &s, 10);
      if (!soap_blank(*s))
        soap->status = 0;
    }
    else
      soap->status = 0;
    DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP status: %s\n", soap->msgbuf));
    for (;;)
    { if (soap_getline(soap, header, SOAP_HDRLEN))
      { if (soap->error == SOAP_EOF)
        { soap->error = SOAP_OK;
          DBGLOG(TEST,SOAP_MESSAGE(fdebug, "EOF in HTTP header, continue anyway\n"));
          break;
        }
        return soap->error;
      }
      if (!*header)
        break;
      DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP header: %s\n", header));
      s = strchr(header, ':');
      if (s)
      { char *t;
        *s = '\0';
        do s++;
        while (*s && *s <= 32);
        if (*s == '"')
          s++;
        t = s + strlen(s) - 1;
        while (t > s && *t <= 32)
          t--;
        if (t >= s && *t == '"')
          t--;
        t[1] = '\0';
        if ((soap->error = soap->fparsehdr(soap, header, s)))
        { if (soap->error < SOAP_STOP)
            return soap->error;
          status = soap->error;
          soap->error = SOAP_OK;
        }
      }
    }
  } while (soap->status == 100);
  DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Finished HTTP header parsing, status = %d\n", soap->status));
  s = strstr(soap->msgbuf, "HTTP/");
  if (s && s[7] != '1')
  { if (soap->keep_alive == 1)
      soap->keep_alive = 0;
    if (soap->status == 0 && (soap->omode & SOAP_IO) == SOAP_IO_CHUNK) /* soap->status == 0 for HTTP request */
    { soap->imode |= SOAP_IO_CHUNK;
      soap->omode = (soap->omode & ~SOAP_IO) | SOAP_IO_STORE;
    }
  }
  if (soap->keep_alive < 0)
    soap->keep_alive = 1;
  DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Keep alive connection = %d\n", soap->keep_alive));
  if (soap->status == 0)
  { size_t l = 0;
    if (s)
    { if (!strncmp(soap->msgbuf, "POST ", l = 5))
        httpcmd = 1;
      else if (!strncmp(soap->msgbuf, "GET ", l = 4))
        httpcmd = 2;
      else if (!strncmp(soap->msgbuf, "PUT ", l = 4))
        httpcmd = 3;
      else if (!strncmp(soap->msgbuf, "DELETE ", l = 7))
        httpcmd = 4;
      else if (!strncmp(soap->msgbuf, "HEAD ", l = 5))
        httpcmd = 5;
    }
    if (s && httpcmd) 
    { size_t m = strlen(soap->endpoint);
      size_t n = m + (s - soap->msgbuf) - l - 1;
      if (m > n)
        m = n;
      if (n >= sizeof(soap->endpoint))
        n = sizeof(soap->endpoint) - 1;
      strncpy(soap->path, soap->msgbuf + l, n - m);
      soap->path[n - m] = '\0';
      strcat(soap->endpoint, soap->path);
      DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Target endpoint='%s'\n", soap->endpoint));
      if (httpcmd > 1)
      { switch (httpcmd)
        { case  2: soap->error = soap->fget(soap); break;
          case  3: soap->error = soap->fput(soap); break;
          case  4: soap->error = soap->fdel(soap); break;
          case  5: soap->error = soap->fhead(soap); break;
	  default: soap->error = 405; break;
	}
        if (soap->error == SOAP_OK)
          soap->error = SOAP_STOP; /* prevents further processing */
        return soap->error;
      }
      if (status)
        return soap->error = status;
    }
    else if (status)
      return soap->error = status;
    else if (s)
      return soap->error = 405;
  }
  /* Status OK (HTTP 200) */
  if (soap->status == 0 || soap->status == 200)
    return SOAP_OK;
  /* Status 201 (Created), 202 (Accepted), ... and HTTP 400 and 500 errors
     may not have a body. When content length, content type, or chunking is
     used assume there is a message to parse, either XML or HTTP.
  */
  if (soap->length > 0 || soap->http_content || (soap->imode & SOAP_IO) == SOAP_IO_CHUNK)
  { if (((soap->status > 200 && soap->status <= 299) || soap->status == 400 || soap->status == 500))
      return SOAP_OK;
    /* force close afterwards in soap_closesock() */
    soap->keep_alive = 0;
    /* read HTTP body for error details */
    s = soap_get_http_body(soap);
    if (s)
      return soap_set_receiver_error(soap, soap->msgbuf, s, soap->status);
  }
  DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP error %d\n", soap->status));
  return soap_set_receiver_error(soap, "HTTP Error", soap->msgbuf, soap->status);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2028, %rsp           # imm = 0x2028
movq %rdi, %rbx
leaq 0x185a8(%rdi), %rax
movq %rax, 0x18(%rsp)
movb $0x0, 0x185a8(%rdi)
xorl %eax, %eax
movq %rax, 0x6118(%rdi)
movq %rax, 0x19208(%rdi)
movq %rax, 0x30(%rdi)
movl $0x0, 0x19210(%rdi)
leaq 0x16138(%rdi), %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x5f58(%rdi)
movups %xmm0, 0x191a8(%rdi)
leaq 0x20(%rsp), %r12
xorl %r13d, %r13d
movq %rbx, %rdi
movq %r14, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x475d7
testl %eax, %eax
jne 0x3c564
movq %r14, %rdi
movl $0x20, %esi
callq 0x3130
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x3c34a
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x3340
movzwl %ax, %eax
movl %eax, 0x19210(%rbx)
movq 0x8(%rsp), %rcx
cmpb $0x21, (%rcx)
movl $0x0, %ecx
cmovael %ecx, %eax
jmp 0x3c34c
xorl %eax, %eax
movl %eax, 0x19210(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x2000, %edx           # imm = 0x2000
callq 0x475d7
testl %eax, %eax
jne 0x3c422
cmpb $0x0, 0x20(%rsp)
je 0x3c43b
movq %r12, %rdi
movl $0x3a, %esi
callq 0x3130
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x3c352
movb $0x0, (%rax)
incq %rax
movb (%rax), %cl
incq %rax
testb %cl, %cl
je 0x3c3a0
cmpb $0x21, %cl
jl 0x3c392
leaq -0x1(%rax), %r15
cmpb $0x22, %cl
cmoveq %rax, %r15
movq %r15, 0x8(%rsp)
movq %r15, %rdi
callq 0x3110
leaq (%r15,%rax), %rcx
decq %rcx
movq %rcx, %rax
cmpq %r15, %rcx
jbe 0x3c3d0
leaq -0x1(%rax), %rcx
cmpb $0x21, (%rax)
jl 0x3c3bf
cmpq %r15, %rax
jb 0x3c3e0
leaq -0x1(%rax), %rcx
cmpb $0x22, (%rax)
cmoveq %rcx, %rax
movb $0x0, 0x1(%rax)
movq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq *0x5fb0(%rbx)
movl %eax, 0x19214(%rbx)
testl %eax, %eax
je 0x3c352
movl %eax, %ebp
cmpl $0x3e8, %eax            # imm = 0x3E8
jl 0x3c714
movl $0x0, 0x19214(%rbx)
movl %ebp, %r13d
jmp 0x3c352
movl 0x19214(%rbx), %ebp
cmpl $-0x1, %ebp
jne 0x3c714
movl $0x0, 0x19214(%rbx)
movl 0x19210(%rbx), %r15d
cmpl $0x64, %r15d
je 0x3c2ee
leaq 0x173d3(%rip), %rsi     # 0x53826
movq %r14, %rdi
callq 0x33d0
movq %rax, %r12
testq %rax, %rax
je 0x3c499
cmpb $0x31, 0x7(%r12)
je 0x3c499
cmpw $0x1, 0x191cc(%rbx)
jne 0x3c47e
movw $0x0, 0x191cc(%rbx)
testl %r15d, %r15d
jne 0x3c499
movl 0xc(%rbx), %eax
movl %eax, %ecx
notl %ecx
testb $0x3, %cl
jne 0x3c499
orb $0x3, 0x8(%rbx)
andl $-0x2, %eax
movl %eax, 0xc(%rbx)
cmpw $0x0, 0x191cc(%rbx)
jns 0x3c4ac
movw $0x1, 0x191cc(%rbx)
testl %r15d, %r15d
je 0x3c58b
xorl %ebp, %ebp
testl %r15d, %r15d
je 0x3c714
cmpl $0xc8, %r15d
je 0x3c714
cmpq $0x0, 0x6118(%rbx)
jne 0x3c4eb
cmpq $0x0, 0x30(%rbx)
jne 0x3c4eb
movl 0x8(%rbx), %eax
notl %eax
testb $0x3, %al
jne 0x3c737
leal -0xc9(%r15), %eax
cmpl $0x63, %eax
jb 0x3c714
cmpl $0x190, %r15d           # imm = 0x190
je 0x3c714
cmpl $0x1f4, %r15d           # imm = 0x1F4
je 0x3c714
movw $0x0, 0x191cc(%rbx)
movq %rbx, %rdi
callq 0x4aef0
movl 0x19210(%rbx), %ebp
testq %rax, %rax
je 0x3c734
cmpw $0x2, 0x2(%rbx)
leaq 0x16c43(%rip), %rcx     # 0x53184
leaq 0x16c2c(%rip), %rsi     # 0x53174
cmoveq %rcx, %rsi
movq %rbx, %rdi
xorl %edx, %edx
movq %r14, %rcx
movq %rax, %r8
movl %ebp, %r9d
callq 0x4a997
jmp 0x3c714
cmpl $-0x1, 0x19214(%rbx)
je 0x3c581
movl $0x19e, 0x19214(%rbx)   # imm = 0x19E
movl $0x19e, %ebp            # imm = 0x19E
jmp 0x3c714
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x3c714
testq %r12, %r12
je 0x3c654
leaq 0x17291(%rip), %rsi     # 0x5382c
movl $0x5, %r15d
movl $0x5, %edx
movq %r14, %rdi
callq 0x3080
testl %eax, %eax
movl %eax, 0x14(%rsp)
je 0x3c665
leaq 0x17271(%rip), %rsi     # 0x53832
movl $0x4, %r15d
movl $0x4, %edx
movq %r14, %rdi
callq 0x3080
testl %eax, %eax
je 0x3c671
leaq 0x17254(%rip), %rsi     # 0x53837
movl $0x4, %r15d
movl $0x4, %edx
movq %r14, %rdi
callq 0x3080
testl %eax, %eax
je 0x3c678
leaq 0x1723b(%rip), %rsi     # 0x5383c
movl $0x7, %r15d
movl $0x7, %edx
movq %r14, %rdi
callq 0x3080
testl %eax, %eax
je 0x3c67f
leaq 0x17225(%rip), %rsi     # 0x53844
movl $0x5, %r15d
movl $0x5, %edx
movq %r14, %rdi
callq 0x3080
testl %eax, %eax
je 0x3c686
testw %r13w, %r13w
jne 0x3c70a
movl $0x195, 0x19214(%rbx)   # imm = 0x195
movl $0x195, %ebp            # imm = 0x195
jmp 0x3c714
testw %r13w, %r13w
jne 0x3c70a
xorl %ebp, %ebp
jmp 0x3c714
movabsq $0x800005f68, %rax      # imm = 0x800005F68
jmp 0x3c68b
movl $0x5f70, %eax           # imm = 0x5F70
jmp 0x3c68b
movl $0x5f78, %eax           # imm = 0x5F78
jmp 0x3c68b
movl $0x5f80, %eax           # imm = 0x5F80
jmp 0x3c68b
movl $0x5f88, %eax           # imm = 0x5F88
movq %rax, (%rsp)
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0x3110
addq %rax, %r12
addq %r14, %r15
movq %r15, %rsi
notq %r15
addq %r12, %r15
cmpq %r15, %rax
cmovaeq %r15, %rax
movl $0x3ff, %ecx            # imm = 0x3FF
cmpq %rcx, %r15
cmovaeq %rcx, %r15
leaq 0x189a8(%rbx), %r12
subq %rax, %r15
movq %r12, %rdi
movq %r15, %rdx
callq 0x3070
movb $0x0, 0x189a8(%rbx,%r15)
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3350
cmpl $0x0, 0x14(%rsp)
je 0x3c704
movq %rbx, %rdi
movq (%rsp), %rax
callq *(%rbx,%rax)
testl %eax, %eax
movl $0x3e8, %ebp            # imm = 0x3E8
cmovnel %eax, %ebp
jmp 0x3c70e
testw %r13w, %r13w
je 0x3c728
movzwl %r13w, %ebp
movl %ebp, 0x19214(%rbx)
movl %ebp, %eax
addq $0x2028, %rsp           # imm = 0x2028
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x19210(%rbx), %r15d
jmp 0x3c4b5
movl %ebp, %r15d
cmpw $0x2, 0x2(%rbx)
leaq 0x16a41(%rip), %rax     # 0x53184
leaq 0x16a2a(%rip), %rsi     # 0x53174
cmoveq %rax, %rsi
leaq 0x170f5(%rip), %rcx     # 0x5384a
movq %rbx, %rdi
xorl %edx, %edx
movq %r14, %r8
movl %r15d, %r9d
callq 0x4a997
movl %r15d, %ebp
jmp 0x3c714