// File: /workspace/github_c_makefile_star2_O1/hkshenSmart[P]ONVIF-discovery_cs/stdsoap2.c
// Function: http_parse
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((soap_wchar)*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, "PUT ", l = 4))
        httpcmd = 2;
      else if (!strncmp(soap->msgbuf, "GET ", l = 4))
        httpcmd = 3;
      else if (!strncmp(soap->msgbuf, "DELETE ", l = 7))
        httpcmd = 4;
      else if (!strncmp(soap->msgbuf, "OPTIONS ", l = 8))
        httpcmd = 5;
      else if (!strncmp(soap->msgbuf, "HEAD ", l = 5))
        httpcmd = 6;
    }
    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)
      { DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP %s handler\n", soap->msgbuf));
        switch (httpcmd)
        { case  2: soap->error = soap->fput(soap); break;
          case  3: soap->error = soap->fget(soap); break;
          case  4: soap->error = soap->fdel(soap); break;
          case  5: soap->error = soap->fopt(soap); break;
          case  6: soap->error = soap->fhead(soap); break;
          default: soap->error = 405; break;
        }
        DBGLOG(TEST,SOAP_MESSAGE(fdebug, "HTTP handler return = %d\n", soap->error));
        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->recv_timeout) || (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;
#ifndef WITH_LEAN
    /* 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);
#endif
  }
  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 $0x2038, %rsp           # imm = 0x2038
movq %rdi, %rbx
leaq 0x1e608(%rdi), %rax
movq %rax, 0x28(%rsp)
movb $0x0, 0x1e608(%rdi)
xorl %r13d, %r13d
movq %r13, 0xc178(%rdi)
movq %r13, 0x1f268(%rdi)
movq %r13, 0x30(%rdi)
movl $0x0, 0x1f270(%rdi)
leaq 0x1c198(%rdi), %r14
xorps %xmm0, %xmm0
movups %xmm0, 0xbf78(%rdi)
movups %xmm0, 0x1f208(%rdi)
leaq 0x30(%rsp), %r12
movq $0x0, 0x10(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x21311
testl %eax, %eax
jne 0x160bb
movq %r14, %rdi
movl $0x20, %esi
callq 0x3130
movq %rax, (%rsp)
testq %rax, %rax
je 0x15e75
movq %rax, %rdi
movq %rsp, %rsi
movl $0xa, %edx
callq 0x32e0
movzwl %ax, %eax
movl %eax, 0x1f270(%rbx)
movq (%rsp), %rcx
cmpb $0x21, (%rcx)
cmovael %r13d, %eax
jmp 0x15e77
xorl %eax, %eax
movl %eax, 0x1f270(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
movl $0x2000, %edx           # imm = 0x2000
callq 0x21311
testl %eax, %eax
jne 0x15f5f
cmpb $0x0, 0x30(%rsp)
je 0x15f78
movq %r12, %rdi
movl $0x3a, %esi
callq 0x3130
movq %rax, (%rsp)
testq %rax, %rax
je 0x15e7d
movb $0x0, (%rax)
movq (%rsp), %rax
incq %rax
movb (%rax), %cl
incq %rax
testb %cl, %cl
je 0x15ece
cmpb $0x21, %cl
jl 0x15ec0
leaq -0x1(%rax), %rbp
cmpb $0x22, %cl
cmoveq %rax, %rbp
movq %rbp, (%rsp)
movq %rbp, %rdi
callq 0x3110
leaq (%rax,%rbp), %rcx
decq %rcx
movq %rcx, %rax
cmpq %rbp, %rcx
jbe 0x15efd
leaq -0x1(%rax), %rcx
cmpb $0x21, (%rax)
jl 0x15eec
cmpq %rbp, %rax
jb 0x15f0d
leaq -0x1(%rax), %rcx
cmpb $0x22, (%rax)
cmoveq %rcx, %rax
movb $0x0, 0x1(%rax)
movq (%rsp), %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq *0xbfd8(%rbx)
movl %eax, %ebp
movl %eax, 0x1f274(%rbx)
movb $0x1, %al
testl %ebp, %ebp
je 0x15f4c
cmpl $0x3e8, %ebp            # imm = 0x3E8
jge 0x15f3b
xorl %eax, %eax
jmp 0x15f4f
movl %ebp, %ecx
movq %rcx, 0x10(%rsp)
movl $0x0, 0x1f274(%rbx)
movl %r15d, %ebp
movl %ebp, %r15d
testb %al, %al
jne 0x15e7d
jmp 0x1632e
movl 0x1f274(%rbx), %ebp
cmpl $-0x1, %ebp
jne 0x1632e
movl $0x0, 0x1f274(%rbx)
movl 0x1f270(%rbx), %ebp
cmpl $0x64, %ebp
je 0x15e21
leaq 0x116ec(%rip), %rsi     # 0x2767a
movq %r14, %rdi
callq 0x3330
movq %rax, %r12
movq %rax, (%rsp)
testq %rax, %rax
je 0x15fd7
cmpb $0x31, 0x7(%r12)
je 0x15fd7
cmpw $0x1, 0x1f22c(%rbx)
jne 0x15fbd
movw $0x0, 0x1f22c(%rbx)
testl %ebp, %ebp
jne 0x15fd7
movl 0xc(%rbx), %eax
movl %eax, %ecx
notl %ecx
testb $0x3, %cl
jne 0x15fd7
orb $0x3, 0x8(%rbx)
andl $-0x2, %eax
movl %eax, 0xc(%rbx)
cmpw $0x0, 0x1f22c(%rbx)
jns 0x15fea
movw $0x1, 0x1f22c(%rbx)
testl %ebp, %ebp
jne 0x16255
movq $-0x2, %r13
testq %r12, %r12
je 0x160e2
leaq 0x11677(%rip), %rsi     # 0x27680
movl $0x5, %edx
movq %r14, %rdi
callq 0x3070
testl %eax, %eax
je 0x160f1
leaq 0x11661(%rip), %rsi     # 0x27686
movl $0x4, %edx
movq %r14, %rdi
callq 0x3070
movb $0x1, %bpl
testl %eax, %eax
je 0x16109
leaq 0x11647(%rip), %rsi     # 0x2768b
movl $0x4, %edx
movq %r14, %rdi
callq 0x3070
testl %eax, %eax
je 0x16118
leaq 0x11630(%rip), %rsi     # 0x27690
movl $0x7, %edx
movq %r14, %rdi
callq 0x3070
testl %eax, %eax
je 0x1612a
leaq 0x1161c(%rip), %rsi     # 0x27698
movl $0x8, %edx
movq %r14, %rdi
callq 0x3070
testl %eax, %eax
je 0x1613c
leaq 0x11609(%rip), %rsi     # 0x276a1
movl $0x5, %eax
movq %rax, 0x8(%rsp)
movl $0x5, %edx
movq %r14, %rdi
callq 0x3070
testl %eax, %eax
je 0x1614e
xorl %ebp, %ebp
jmp 0x16105
cmpl $-0x1, 0x1f274(%rbx)
je 0x160d8
movl $0x19e, 0x1f274(%rbx)   # imm = 0x19E
movl $0x19e, %ebp            # imm = 0x19E
jmp 0x1632e
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x1632e
xorl %ebp, %ebp
xorl %ecx, %ecx
movq $0x0, 0x8(%rsp)
jmp 0x16156
movl $0x5, %eax
movq %rax, 0x8(%rsp)
movq $-0x1, %r13
movb $0x1, %bpl
xorl %ecx, %ecx
jmp 0x16156
movl $0x4, %eax
movq %rax, 0x8(%rsp)
xorl %r13d, %r13d
jmp 0x16154
movl $0x4, %eax
movq %rax, 0x8(%rsp)
movl $0x1, %r13d
jmp 0x16154
movl $0x7, %eax
movq %rax, 0x8(%rsp)
movl $0x2, %r13d
jmp 0x16154
movl $0x8, %eax
movq %rax, 0x8(%rsp)
movl $0x3, %r13d
jmp 0x16154
movl $0x4, %r13d
movb $0x1, %cl
testq %r12, %r12
sete %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x1620a
movq %r13, 0x18(%rsp)
movq 0x28(%rsp), %r13
movq %r13, %rdi
movq %rcx, 0x20(%rsp)
callq 0x3110
movq 0x8(%rsp), %rsi
addq %r14, %rsi
movq %rsi, %rcx
notq %rcx
addq %rax, %r12
addq %rcx, %r12
cmpq %r12, %rax
cmovaeq %r12, %rax
movl $0x3ff, %ecx            # imm = 0x3FF
cmpq %rcx, %r12
cmovaeq %rcx, %r12
leaq 0x1ea08(%rbx), %rbp
subq %rax, %r12
movq %rbp, %rdi
movq %r12, %rdx
callq 0x3060
movb $0x0, 0x1ea08(%rbx,%r12)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x32f0
cmpb $0x0, 0x20(%rsp)
je 0x1622f
leaq 0xfe8a(%rip), %rax      # 0x26068
movq 0x18(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rbx, %rdi
callq *(%rbx,%rax)
movl %eax, 0x1f274(%rbx)
testl %eax, %eax
jne 0x16201
movl $0x3e8, 0x1f274(%rbx)   # imm = 0x3E8
movl 0x1f274(%rbx), %r15d
jmp 0x16248
movq 0x10(%rsp), %rax
testw %ax, %ax
jne 0x1623d
testq %r12, %r12
je 0x16342
movl $0x195, 0x1f274(%rbx)   # imm = 0x195
movl $0x195, %r15d           # imm = 0x195
jmp 0x16248
movq 0x10(%rsp), %rax
testw %ax, %ax
je 0x16342
movzwl %ax, %r15d
movl %r15d, 0x1f274(%rbx)
xorl %eax, %eax
movl %r15d, %ebp
testb %al, %al
je 0x1632e
movl 0x1f270(%rbx), %eax
xorl %ebp, %ebp
testl %eax, %eax
je 0x1632e
cmpl $0xc8, %eax
je 0x1632e
cmpq $0x0, 0xc178(%rbx)
je 0x162e3
leal -0xc9(%rax), %ecx
cmpl $0x63, %ecx
jb 0x1632e
cmpl $0x190, %eax            # imm = 0x190
je 0x1632e
cmpl $0x1f4, %eax            # imm = 0x1F4
je 0x1632e
movw $0x0, 0x1f22c(%rbx)
movq %rbx, %rdi
callq 0x23018
movq %rax, (%rsp)
testq %rax, %rax
je 0x162fa
movl 0x1f270(%rbx), %ebp
cmpw $0x2, 0x2(%rbx)
leaq 0x10d78(%rip), %rcx     # 0x27043
leaq 0x10d61(%rip), %rsi     # 0x27033
cmoveq %rcx, %rsi
movq %rbx, %rdi
xorl %edx, %edx
movq %r14, %rcx
movq %rax, %r8
jmp 0x16326
cmpq $0x0, 0x30(%rbx)
je 0x162f0
cmpl $0x0, 0x50(%rbx)
jne 0x1627a
movl 0x8(%rbx), %ecx
notl %ecx
testb $0x3, %cl
je 0x1627a
movl 0x1f270(%rbx), %ebp
cmpw $0x2, 0x2(%rbx)
leaq 0x10d37(%rip), %rax     # 0x27043
leaq 0x10d20(%rip), %rsi     # 0x27033
cmoveq %rax, %rsi
leaq 0x11389(%rip), %rcx     # 0x276a7
movq %rbx, %rdi
xorl %edx, %edx
movq %r14, %r8
movl %ebp, %r9d
callq 0x245f7
movl %ebp, %eax
addq $0x2038, %rsp           # imm = 0x2038
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %al
jmp 0x1624a