// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x2060, %rsp           # imm = 0x2060
movq %rdi, -0x10(%rbp)
movw $0x0, -0x201a(%rbp)
movw $0x0, -0x201c(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, 0x185a8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x6118(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x5f58(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x5f60(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x191a8(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x191b0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x19208(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x19210(%rax)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x16138, %rsi          # imm = 0x16138
movl $0x400, %edx            # imm = 0x400
callq 0x688e0
cmpl $0x0, %eax
je 0x56a31
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x19214(%rax)
jne 0x56a17
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x57271
movq -0x10(%rbp), %rax
movl $0x19e, 0x19214(%rax)   # imm = 0x19E
movl $0x19e, -0x4(%rbp)      # imm = 0x19E
jmp 0x57271
movq -0x10(%rbp), %rdi
addq $0x16138, %rdi          # imm = 0x16138
movl $0x20, %esi
callq 0x3130
movq %rax, -0x2018(%rbp)
cmpq $0x0, %rax
je 0x56aa6
movq -0x2018(%rbp), %rdi
leaq -0x2018(%rbp), %rsi
movl $0xa, %edx
callq 0x3350
movzwl %ax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x19210(%rax)
movq -0x2018(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jl 0x56a96
movq -0x2018(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
jle 0x56aa4
movq -0x10(%rbp), %rax
movl $0x0, 0x19210(%rax)
jmp 0x56ab4
movq -0x10(%rbp), %rax
movl $0x0, 0x19210(%rax)
jmp 0x56ab6
movq -0x10(%rbp), %rdi
leaq -0x2010(%rbp), %rsi
movl $0x2000, %edx           # imm = 0x2000
callq 0x688e0
cmpl $0x0, %eax
je 0x56b02
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x19214(%rax)
jne 0x56af0
movq -0x10(%rbp), %rax
movl $0x0, 0x19214(%rax)
jmp 0x56cdc
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x57271
cmpb $0x0, -0x2010(%rbp)
jne 0x56b10
jmp 0x56cdc
leaq -0x2010(%rbp), %rdi
movl $0x3a, %esi
callq 0x3130
movq %rax, -0x2018(%rbp)
cmpq $0x0, -0x2018(%rbp)
je 0x56cd7
movq -0x2018(%rbp), %rax
movb $0x0, (%rax)
movq -0x2018(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2018(%rbp)
movq -0x2018(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x2041(%rbp)
je 0x56b7f
movq -0x2018(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
setle %al
movb %al, -0x2041(%rbp)
movb -0x2041(%rbp), %al
testb $0x1, %al
jne 0x56b40
movq -0x2018(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0x56baa
movq -0x2018(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x2018(%rbp)
movq -0x2018(%rbp), %rax
movq %rax, -0x2050(%rbp)
movq -0x2018(%rbp), %rdi
callq 0x3100
movq %rax, %rcx
movq -0x2050(%rbp), %rax
addq %rcx, %rax
addq $-0x1, %rax
movq %rax, -0x2028(%rbp)
movq -0x2028(%rbp), %rcx
xorl %eax, %eax
cmpq -0x2018(%rbp), %rcx
movb %al, -0x2051(%rbp)
jbe 0x56c0a
movq -0x2028(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x20, %eax
setle %al
movb %al, -0x2051(%rbp)
movb -0x2051(%rbp), %al
testb $0x1, %al
jne 0x56c16
jmp 0x56c2a
movq -0x2028(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x2028(%rbp)
jmp 0x56bdc
movq -0x2028(%rbp), %rax
cmpq -0x2018(%rbp), %rax
jb 0x56c5b
movq -0x2028(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x22, %eax
jne 0x56c5b
movq -0x2028(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x2028(%rbp)
movq -0x2028(%rbp), %rax
movb $0x0, 0x1(%rax)
movq -0x10(%rbp), %rax
movq 0x5fb0(%rax), %rax
movq -0x10(%rbp), %rdi
leaq -0x2010(%rbp), %rsi
movq -0x2018(%rbp), %rdx
callq *%rax
movq -0x10(%rbp), %rcx
movl %eax, 0x19214(%rcx)
cmpl $0x0, %eax
je 0x56cd5
movq -0x10(%rbp), %rax
cmpl $0x3e8, 0x19214(%rax)   # imm = 0x3E8
jge 0x56cb6
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x57271
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movw %ax, -0x201c(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x19214(%rax)
jmp 0x56cd7
jmp 0x56ab6
jmp 0x56cde
movq -0x10(%rbp), %rax
cmpl $0x64, 0x19210(%rax)
je 0x569e0
movq -0x10(%rbp), %rdi
addq $0x16138, %rdi          # imm = 0x16138
leaq 0x24ef2(%rip), %rsi     # 0x7bbf3
callq 0x33e0
movq %rax, -0x2018(%rbp)
cmpq $0x0, -0x2018(%rbp)
je 0x56d83
movq -0x2018(%rbp), %rax
movsbl 0x7(%rax), %eax
cmpl $0x31, %eax
je 0x56d83
movq -0x10(%rbp), %rax
movswl 0x191cc(%rax), %eax
cmpl $0x1, %eax
jne 0x56d44
movq -0x10(%rbp), %rax
movw $0x0, 0x191cc(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x19210(%rax)
jne 0x56d81
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
andl $0x3, %eax
cmpl $0x3, %eax
jne 0x56d81
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
orl $0x3, %ecx
movl %ecx, 0x8(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
andl $-0x4, %ecx
orl $0x2, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
jmp 0x56d83
movq -0x10(%rbp), %rax
movswl 0x191cc(%rax), %eax
cmpl $0x0, %eax
jge 0x56da0
movq -0x10(%rbp), %rax
movw $0x1, 0x191cc(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x19210(%rax)
jne 0x57158
movq $0x0, -0x2030(%rbp)
cmpq $0x0, -0x2018(%rbp)
je 0x56eeb
movq -0x10(%rbp), %rdi
addq $0x16138, %rdi          # imm = 0x16138
movq $0x5, -0x2030(%rbp)
leaq 0x24e12(%rip), %rsi     # 0x7bbf9
movl $0x5, %edx
callq 0x3080
cmpl $0x0, %eax
jne 0x56e04
movw $0x1, -0x201a(%rbp)
jmp 0x56ee9
movq -0x10(%rbp), %rdi
addq $0x16138, %rdi          # imm = 0x16138
movq $0x4, -0x2030(%rbp)
leaq 0x24dde(%rip), %rsi     # 0x7bbff
movl $0x4, %edx
callq 0x3080
cmpl $0x0, %eax
jne 0x56e3e
movw $0x2, -0x201a(%rbp)
jmp 0x56ee7
movq -0x10(%rbp), %rdi
addq $0x16138, %rdi          # imm = 0x16138
movq $0x4, -0x2030(%rbp)
leaq 0x24da9(%rip), %rsi     # 0x7bc04
movl $0x4, %edx
callq 0x3080
cmpl $0x0, %eax
jne 0x56e75
movw $0x3, -0x201a(%rbp)
jmp 0x56ee5
movq -0x10(%rbp), %rdi
addq $0x16138, %rdi          # imm = 0x16138
movq $0x7, -0x2030(%rbp)
leaq 0x24d77(%rip), %rsi     # 0x7bc09
movl $0x7, %edx
callq 0x3080
cmpl $0x0, %eax
jne 0x56eac
movw $0x4, -0x201a(%rbp)
jmp 0x56ee3
movq -0x10(%rbp), %rdi
addq $0x16138, %rdi          # imm = 0x16138
movq $0x5, -0x2030(%rbp)
leaq 0x24d48(%rip), %rsi     # 0x7bc11
movl $0x5, %edx
callq 0x3080
cmpl $0x0, %eax
jne 0x56ee1
movw $0x5, -0x201a(%rbp)
jmp 0x56ee3
jmp 0x56ee5
jmp 0x56ee7
jmp 0x56ee9
jmp 0x56eeb
cmpq $0x0, -0x2018(%rbp)
je 0x5710b
movzwl -0x201a(%rbp), %eax
cmpl $0x0, %eax
je 0x5710b
movq -0x10(%rbp), %rdi
addq $0x185a8, %rdi          # imm = 0x185A8
callq 0x3100
movq %rax, -0x2038(%rbp)
movq -0x2038(%rbp), %rax
movq -0x2018(%rbp), %rcx
movq -0x10(%rbp), %rdx
addq $0x16138, %rdx          # imm = 0x16138
subq %rdx, %rcx
addq %rcx, %rax
subq -0x2030(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x2040(%rbp)
movq -0x2038(%rbp), %rax
cmpq -0x2040(%rbp), %rax
jbe 0x56f6f
movq -0x2040(%rbp), %rax
movq %rax, -0x2038(%rbp)
cmpq $0x400, -0x2040(%rbp) # imm = 0x400
jb 0x56f87
movq $0x3ff, -0x2040(%rbp) # imm = 0x3FF
movq -0x10(%rbp), %rdi
addq $0x189a8, %rdi          # imm = 0x189A8
movq -0x10(%rbp), %rsi
addq $0x16138, %rsi          # imm = 0x16138
addq -0x2030(%rbp), %rsi
movq -0x2040(%rbp), %rdx
subq -0x2038(%rbp), %rdx
callq 0x3070
movq -0x10(%rbp), %rax
movq -0x2040(%rbp), %rcx
subq -0x2038(%rbp), %rcx
movb $0x0, 0x189a8(%rax,%rcx)
movq -0x10(%rbp), %rdi
addq $0x185a8, %rdi          # imm = 0x185A8
movq -0x10(%rbp), %rsi
addq $0x189a8, %rsi          # imm = 0x189A8
callq 0x3360
movzwl -0x201a(%rbp), %eax
cmpl $0x1, %eax
jle 0x570e6
movzwl -0x201a(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x2060(%rbp)
subl $0x3, %eax
ja 0x570ab
movq -0x2060(%rbp), %rax
leaq 0x22fde(%rip), %rcx     # 0x7a004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movq 0x5f70(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x19214(%rax)
jmp 0x570b9
movq -0x10(%rbp), %rax
movq 0x5f78(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x19214(%rax)
jmp 0x570b9
movq -0x10(%rbp), %rax
movq 0x5f80(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x19214(%rax)
jmp 0x570b9
movq -0x10(%rbp), %rax
movq 0x5f88(%rax), %rax
movq -0x10(%rbp), %rdi
callq *%rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x19214(%rax)
jmp 0x570b9
movq -0x10(%rbp), %rax
movl $0x195, 0x19214(%rax)   # imm = 0x195
movq -0x10(%rbp), %rax
cmpl $0x0, 0x19214(%rax)
jne 0x570d4
movq -0x10(%rbp), %rax
movl $0x3e8, 0x19214(%rax)   # imm = 0x3E8
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x57271
cmpw $0x0, -0x201c(%rbp)
je 0x57109
movzwl -0x201c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl %eax, 0x19214(%rcx)
movl %eax, -0x4(%rbp)
jmp 0x57271
jmp 0x57156
cmpw $0x0, -0x201c(%rbp)
je 0x5712e
movzwl -0x201c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl %eax, 0x19214(%rcx)
movl %eax, -0x4(%rbp)
jmp 0x57271
cmpq $0x0, -0x2018(%rbp)
je 0x57152
movq -0x10(%rbp), %rax
movl $0x195, 0x19214(%rax)   # imm = 0x195
movl $0x195, -0x4(%rbp)      # imm = 0x195
jmp 0x57271
jmp 0x57154
jmp 0x57156
jmp 0x57158
movq -0x10(%rbp), %rax
cmpl $0x0, 0x19210(%rax)
je 0x57175
movq -0x10(%rbp), %rax
cmpl $0xc8, 0x19210(%rax)
jne 0x57181
movl $0x0, -0x4(%rbp)
jmp 0x57271
movq -0x10(%rbp), %rax
cmpq $0x0, 0x6118(%rax)
ja 0x571ad
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x571ad
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
andl $0x3, %eax
cmpl $0x3, %eax
jne 0x57249
movq -0x10(%rbp), %rax
cmpl $0xc8, 0x19210(%rax)
jle 0x571cd
movq -0x10(%rbp), %rax
cmpl $0x12b, 0x19210(%rax)   # imm = 0x12B
jle 0x571ed
movq -0x10(%rbp), %rax
cmpl $0x190, 0x19210(%rax)   # imm = 0x190
je 0x571ed
movq -0x10(%rbp), %rax
cmpl $0x1f4, 0x19210(%rax)   # imm = 0x1F4
jne 0x571f6
movl $0x0, -0x4(%rbp)
jmp 0x57271
movq -0x10(%rbp), %rax
movw $0x0, 0x191cc(%rax)
movq -0x10(%rbp), %rdi
callq 0x6ea60
movq %rax, -0x2018(%rbp)
cmpq $0x0, -0x2018(%rbp)
je 0x57247
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x16138, %rsi          # imm = 0x16138
movq -0x2018(%rbp), %rdx
movq -0x10(%rbp), %rax
movl 0x19210(%rax), %ecx
callq 0x59640
movl %eax, -0x4(%rbp)
jmp 0x57271
jmp 0x57249
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rdx
addq $0x16138, %rdx          # imm = 0x16138
movq -0x10(%rbp), %rax
movl 0x19210(%rax), %ecx
leaq 0x249ae(%rip), %rsi     # 0x7bc17
callq 0x59640
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2060, %rsp           # imm = 0x2060
popq %rbp
retq
nopl (%rax)