// File: /workspace/github_c_makefile_star2_O1/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 0x497e6
movq 0x5fc8(%rbx), %rax
testq %rax, %rax
je 0x49af5
movl 0x191c8(%rbx), %ecx
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq *%rax
movl %eax, 0x19214(%rbx)
testl %eax, %eax
jne 0x49c8c
jmp 0x49bbb
cmpq $0x0, 0x5fe8(%rbx)
je 0x49bbb
cmpb $0x0, (%r12)
je 0x49bbb
cmpw $0x0, 0x191cc(%rbx)
je 0x49b50
cmpl $-0x1, 0x60d4(%rbx)
je 0x49b50
leaq 0x10(%rsp), %rsi
movq %r12, %rdi
callq 0x3200
testl %eax, %eax
jne 0x49b50
cmpl %r14d, 0x191c8(%rbx)
jne 0x49b50
movq 0x6010(%rbx), %rax
testq %rax, %rax
je 0x49b50
movq %rbx, %rdi
callq *%rax
testl %eax, %eax
je 0x49bbb
movw $0x0, 0x191cc(%rbx)
andb $-0x5, 0xc(%rbx)
movq %rbx, %rdi
callq 0x3ba2e
leaq 0x9d9f(%rip), %rsi      # 0x5390b
movl $0x9, %edx
movq %r15, %rdi
callq 0x3080
testl %eax, %eax
jne 0x49b81
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 0x49c8c
movzwl 0xc(%rbx), %eax
shrl $0x4, %eax
andl $0x1, %eax
movw %ax, 0x191cc(%rbx)
movq %rbx, %rdi
callq 0x4a512
movq %rax, %r14
movq %rbx, %rdi
callq 0x3eeb0
testl %eax, %eax
je 0x49bdd
movl 0x19214(%rbx), %eax
jmp 0x49c8c
movq %r14, 0x8(%rsp)
cmpl $0x7d2, %ebp            # imm = 0x7D2
jne 0x49bf5
movl 0x4(%rbx), %eax
andl $-0x4, %eax
incl %eax
movl %eax, 0x4(%rbx)
movq %rbx, %rdi
movq %r13, %rsi
callq 0x3a567
movq %rax, 0x191a8(%rbx)
movl 0x4(%rbx), %edx
movl %edx, %r14d
andl $0x3, %r14d
cmpl $0x2, %r14d
je 0x49c7a
movl %edx, %eax
andl $0x40, %eax
shrl $0x6, %eax
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x49c7a
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, 0x8(%rsp)
movq %r12, %rdx
movq %r13, %r9
callq *0x5f68(%rbx)
movl %eax, 0x19214(%rbx)
movb $0x1, %r15b
testl %eax, %eax
je 0x49c9e
movl %eax, %ecx
jmp 0x49ce2
xorl %eax, %eax
cmpl $0x7d2, %ebp            # imm = 0x7D2
jne 0x49c8c
movq %rbx, %rdi
callq 0x40148
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x8(%rsp), %r12d
cmpl $0x3, %r14d
jne 0x49cdb
movq 0x60f0(%rbx), %rdx
testq %rdx, %rdx
je 0x49cdb
movq $0x0, 0x60f0(%rbx)
leaq 0x6138(%rbx), %rsi
movq %rbx, %rdi
callq 0x37839
testl %eax, %eax
je 0x49cdb
movl 0x19214(%rbx), %ecx
jmp 0x49ce2
movl %r12d, 0x4(%rbx)
xorl %r15d, %r15d
cmpl $0x7d2, %ebp            # imm = 0x7D2
setne %dl
orb %r15b, %dl
xorl %eax, %eax
testb %r15b, %r15b
cmovnel %ecx, %eax
testb %dl, %dl
je 0x49c84
jmp 0x49c8c