// File: /workspace/github_c_makefile_star2_O3/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_try_connect_command
static int
soap_try_connect_command(struct soap *soap, int http_command, const char *endpoint, const char *action)
{ char host[sizeof(soap->host)];
  int port;
  size_t count;
  soap->error = SOAP_OK;
  strcpy(host, soap->host); /* save previous host name: if != then reconnect */
  port = soap->port; /* save previous port to compare */
  soap->status = http_command;
  soap_set_endpoint(soap, endpoint);
#ifndef WITH_LEANER
  if (soap->fconnect)
  { if ((soap->error = soap->fconnect(soap, endpoint, soap->host, soap->port)))
      return soap->error;
  }
  else
#endif
  if (soap->fopen && *soap->host)
  { if (!soap->keep_alive || !soap_valid_socket(soap->socket) || strcmp(soap->host, host) || soap->port != port || !soap->fpoll || soap->fpoll(soap))
    { soap->keep_alive = 0; /* to force close */
      soap->omode &= ~SOAP_IO_UDP; /* to force close */
      soap_closesock(soap);
      DBGLOG(TEST,SOAP_MESSAGE(fdebug, "Connect/reconnect to host='%s' path='%s' port=%d\n", soap->host, soap->path, soap->port));
#ifndef WITH_LEAN
      if (!strncmp(endpoint, "soap.udp:", 9))
        soap->omode |= SOAP_IO_UDP;
#endif
      soap->socket = soap->fopen(soap, endpoint, soap->host, soap->port);
      if (soap->error)
        return soap->error;
      soap->keep_alive = ((soap->omode & SOAP_IO_KEEPALIVE) != 0);
    }
  }
  count = soap_count_attachments(soap);
  if (soap_begin_send(soap))
    return soap->error;
  if (http_command == SOAP_GET)
  { soap->mode &= ~SOAP_IO;
    soap->mode |= SOAP_IO_BUFFER;
  }
#ifndef WITH_NOHTTP
  soap->action = soap_strdup(soap, action);
  if ((soap->mode & SOAP_IO) != SOAP_IO_STORE && !(soap->mode & SOAP_ENC_XML) && endpoint)
  { unsigned int k = soap->mode;
    soap->mode &= ~(SOAP_IO | SOAP_ENC_ZLIB);
    if ((k & SOAP_IO) != SOAP_IO_FLUSH)
      soap->mode |= SOAP_IO_BUFFER;
    if ((soap->error = soap->fpost(soap, endpoint, soap->host, soap->port, soap->path, action, count)))
      return soap->error;
#ifndef WITH_LEANER
    if ((k & SOAP_IO) == SOAP_IO_CHUNK)
    { if (soap_flush(soap))
        return soap->error;
    }
#endif
    soap->mode = k;
  }
  if (http_command == SOAP_GET)
    return soap_end_send(soap);
#endif
  return SOAP_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x418, %rsp            # imm = 0x418
movq %rcx, %r13
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
movl $0x0, 0x19214(%rdi)
leaq 0x18da8(%rdi), %r12
leaq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x3090
movl 0x191c8(%rbx), %r14d
movl %ebp, 0x19210(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4914f
movq 0x5fc8(%rbx), %rax
testq %rax, %rax
je 0x49471
movl 0x191c8(%rbx), %ecx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *%rax
movl %eax, 0x19214(%rbx)
testl %eax, %eax
jne 0x49550
jmp 0x49533
cmpq $0x0, 0x5fe8(%rbx)
je 0x49533
cmpb $0x0, (%r12)
je 0x49533
cmpw $0x0, 0x191cc(%rbx)
je 0x494cc
cmpl $-0x1, 0x60d4(%rbx)
je 0x494cc
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0x3210
testl %eax, %eax
jne 0x494cc
cmpl %r14d, 0x191c8(%rbx)
jne 0x494cc
movq 0x6010(%rbx), %rax
testq %rax, %rax
je 0x494cc
movq %rbx, %rdi
callq *%rax
testl %eax, %eax
je 0x49533
movw $0x0, 0x191cc(%rbx)
andb $-0x5, 0xc(%rbx)
movq %rbx, %rdi
callq 0x3baf5
leaq 0xa423(%rip), %rsi      # 0x5390b
movl $0x9, %edx
movq %r15, %rdi
callq 0x3080
testl %eax, %eax
jne 0x494fd
orb $0x4, 0xc(%rbx)
movl 0x191c8(%rbx), %ecx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *0x5fe8(%rbx)
movl %eax, 0x60d4(%rbx)
movl 0x19214(%rbx), %eax
testl %eax, %eax
jne 0x49550
movzwl 0xc(%rbx), %eax
shrl $0x4, %eax
andl $0x1, %eax
movw %ax, 0x191cc(%rbx)
movq %rbx, %rdi
callq 0x49e4b
movq %rax, %r14
movq %rbx, %rdi
callq 0x3ee31
testl %eax, %eax
je 0x49562
movl 0x19214(%rbx), %eax
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, 0x8(%rsp)
cmpl $0x7d2, %ebp            # imm = 0x7D2
jne 0x4957a
movl 0x4(%rbx), %eax
andl $-0x4, %eax
incl %eax
movl %eax, 0x4(%rbx)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3a6c4
movq %rax, 0x191a8(%rbx)
movl 0x4(%rbx), %edx
movl %edx, %r14d
andl $0x3, %r14d
cmpl $0x2, %r14d
je 0x4963b
movl %edx, %eax
andl $0x40, %eax
shrl $0x6, %eax
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x4963b
movl %edx, %eax
andl $0xfffffbbc, %eax       # imm = 0xFFFFFBBC
xorl %ecx, %ecx
testl %r14d, %r14d
setne %cl
orl %eax, %ecx
movl %ecx, 0x4(%rbx)
movl 0x191c8(%rbx), %ecx
leaq 0x189a8(%rbx), %r8
movq 0x8(%rsp), %rax
movq %rax, (%rsp)
movq %rbx, %rdi
movq %r15, %rsi
movl %edx, %r15d
movq %r12, %rdx
movq %r13, %r9
callq *0x5f68(%rbx)
movl %eax, 0x19214(%rbx)
testl %eax, %eax
jne 0x49550
cmpl $0x3, %r14d
jne 0x49637
movq 0x60f0(%rbx), %rdx
testq %rdx, %rdx
je 0x49637
movq $0x0, 0x60f0(%rbx)
leaq 0x6138(%rbx), %rsi
movq %rbx, %rdi
callq 0x37b1c
testl %eax, %eax
jne 0x4954a
movl %r15d, 0x4(%rbx)
cmpl $0x7d2, %ebp            # imm = 0x7D2
jne 0x49650
movq %rbx, %rdi
callq 0x4007f
jmp 0x49550
xorl %eax, %eax
jmp 0x49550