// File: /workspace/github_c_makefile_star2_O0/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_attachment
SOAP_FMAC2
soap_attachment(struct soap *soap, const char *tag, int id, const void *p, const struct soap_array *a, const char *aid, const char *atype, const char *aoptions, int n, const char *type, int t) 
{
#ifndef WITH_NOIDREF
  struct soap_plist *pp;
  int i;
  if (!p || !a->__ptr || (!aid && !atype))
    return soap_element_id(soap, tag, id, p, a, n, type, t);
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Attachment tag='%s' id='%s' (%d) type='%s'\n", tag, aid?aid:SOAP_STR_EOS, id, atype?atype:SOAP_STR_EOS));
  i = soap_array_pointer_lookup(soap, p, a, n, t, &pp);
  if (!i)
  { i = soap_pointer_enter(soap, p, a, n, t, &pp);
    if (!i)
    { soap->error = SOAP_EOM;
      return -1;
    }
  }
  if (id <= 0)
    id = i;
  if (!aid)
  { sprintf(soap->tmpbuf, soap->dime_id_format, id);
    aid = soap_strdup(soap, soap->tmpbuf);
  }
  /* Add MTOM xop:Include element when necessary */
  /* TODO: this code to be obsoleted with new import/xop.h conventions */
  if ((soap->mode & SOAP_ENC_MTOM) && strcmp(tag, "xop:Include"))
  { if (soap_element_begin_out(soap, tag, 0, type)
     || soap_element_href(soap, "xop:Include", 0, "href", aid)
     || soap_element_end_out(soap, tag))
      return soap->error;
  }
  else if (soap_element_href(soap, tag, 0, "href", aid))
    return soap->error;
  if (soap->mode & SOAP_IO_LENGTH)
  { if (pp->mark1 != 3)
    { struct soap_multipart *content;
      if (soap->mode & SOAP_ENC_MTOM)
        content = soap_new_multipart(soap, &soap->mime.first, &soap->mime.last, (char*)a->__ptr, a->__size);
      else
        content = soap_new_multipart(soap, &soap->dime.first, &soap->dime.last, (char*)a->__ptr, a->__size);
      if (!content)
      { soap->error = SOAP_EOM;
        return -1;
      }
      if (!strncmp(aid, "cid:", 4)) /* RFC 2111 */
      { if (soap->mode & SOAP_ENC_MTOM)
        { char *s = (char*)soap_malloc(soap, strlen(aid) - 1);
          if (s)
          { *s = '<';
            strcpy(s + 1, aid + 4);
            strcat(s, ">");
            content->id = s;
          }
        }
        else
          content->id = aid + 4;
      }
      else
        content->id = aid;
      content->type = atype;
      content->options = aoptions;
      content->encoding = SOAP_MIME_BINARY;
      pp->mark1 = 3;
    }
  }
  else
    pp->mark2 = 3;
#endif
  return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl 0x30(%rbp), %eax
movq 0x28(%rbp), %rax
movl 0x20(%rbp), %eax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x5b750
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x5b750
cmpq $0x0, -0x38(%rbp)
jne 0x5b783
cmpq $0x0, 0x10(%rbp)
jne 0x5b783
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x1c(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
movl 0x20(%rbp), %r9d
movq 0x28(%rbp), %r10
movl 0x30(%rbp), %eax
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
callq 0x5bab0
movl %eax, -0x4(%rbp)
jmp 0x5baa5
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl 0x20(%rbp), %ecx
movl 0x30(%rbp), %r8d
leaq -0x40(%rbp), %r9
callq 0x5a5a0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x5b7e9
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl 0x20(%rbp), %ecx
movl 0x30(%rbp), %r8d
leaq -0x40(%rbp), %r9
callq 0x5a900
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x5b7e7
movq -0x10(%rbp), %rax
movl $0x14, 0x19214(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5baa5
jmp 0x5b7e9
cmpl $0x0, -0x1c(%rbp)
jg 0x5b7f5
movl -0x44(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x5b831
movq -0x10(%rbp), %rdi
addq $0x16538, %rdi          # imm = 0x16538
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
movl -0x1c(%rbp), %edx
movb $0x0, %al
callq 0x3370
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x16538, %rsi          # imm = 0x16538
callq 0x538b0
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x5b8b7
movq -0x18(%rbp), %rdi
leaq 0x1ed5b(%rip), %rsi     # 0x7a5a8
callq 0x3210
cmpl $0x0, %eax
je 0x5b8b7
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq 0x28(%rbp), %rcx
xorl %edx, %edx
callq 0x5bbd0
cmpl $0x0, %eax
jne 0x5b8a3
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %r8
leaq 0x1ed2a(%rip), %rsi     # 0x7a5a8
xorl %edx, %edx
leaq 0x1f02b(%rip), %rcx     # 0x7a8b2
callq 0x5bc40
cmpl $0x0, %eax
jne 0x5b8a3
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x5bcc0
cmpl $0x0, %eax
je 0x5b8b5
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5baa5
jmp 0x5b8ea
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %r8
xorl %edx, %edx
leaq 0x1efe6(%rip), %rcx     # 0x7a8b2
callq 0x5bc40
cmpl $0x0, %eax
je 0x5b8e8
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5baa5
jmp 0x5b8ea
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x5ba96
movq -0x40(%rbp), %rax
movsbl 0x20(%rax), %eax
cmpl $0x3, %eax
je 0x5ba94
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x5b95b
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x19288, %rsi          # imm = 0x19288
addq $0x18, %rsi
movq -0x10(%rbp), %rdx
addq $0x19288, %rdx          # imm = 0x19288
addq $0x20, %rdx
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movslq 0x8(%rax), %r8
callq 0x5be40
movq %rax, -0x50(%rbp)
jmp 0x5b995
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x19228, %rsi          # imm = 0x19228
addq $0x50, %rsi
movq -0x10(%rbp), %rdx
addq $0x19228, %rdx          # imm = 0x19228
addq $0x58, %rdx
movq -0x30(%rbp), %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movslq 0x8(%rax), %r8
callq 0x5be40
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x5b9b6
movq -0x10(%rbp), %rax
movl $0x14, 0x19214(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5baa5
movq -0x38(%rbp), %rdi
leaq 0x1eef6(%rip), %rsi     # 0x7a8b7
movl $0x4, %edx
callq 0x3080
cmpl $0x0, %eax
jne 0x5ba5d
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x5ba4b
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3100
movq -0x60(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x518f0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0x5ba49
movq -0x58(%rbp), %rax
movb $0x3c, (%rax)
movq -0x58(%rbp), %rdi
addq $0x1, %rdi
movq -0x38(%rbp), %rsi
addq $0x4, %rsi
callq 0x3090
movq -0x58(%rbp), %rdi
leaq 0x1ef95(%rip), %rsi     # 0x7a9cd
callq 0x3360
movq -0x58(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x5ba5b
movq -0x38(%rbp), %rcx
addq $0x4, %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x5ba69
movq -0x38(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x18(%rax)
movq 0x10(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x20(%rax)
movq 0x18(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x50(%rbp), %rax
movl $0x3, 0x30(%rax)
movq -0x40(%rbp), %rax
movb $0x3, 0x20(%rax)
jmp 0x5ba9e
movq -0x40(%rbp), %rax
movb $0x3, 0x21(%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop