// File: /workspace/github_c_makefile_star2_O2/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_count_attachments
static size_t
soap_count_attachments(struct soap *soap)
{ 
#ifndef WITH_LEANER
  register struct soap_multipart *content;
  register size_t count = soap->count;
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the message size with attachments, current count=%lu\n", (unsigned long)count));
  if ((soap->mode & SOAP_ENC_DIME) && !(soap->mode & SOAP_ENC_MTOM))
  { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of DIME attachments\n"));
    for (content = soap->dime.first; content; content = content->next)
    { count += 12 + ((content->size+3)&(~3));
      if (content->id)
        count += ((strlen(content->id)+3)&(~3));
      if (content->type)
        count += ((strlen(content->type)+3)&(~3));
      if (content->options)
        count += ((((unsigned char)content->options[2] << 8) | ((unsigned char)content->options[3]))+7)&(~3);
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Size of DIME attachment content is %lu bytes\n", (unsigned long)content->size));
    }
  }
  if ((soap->mode & SOAP_ENC_MIME) && soap->mime.boundary)
  { register size_t n = strlen(soap->mime.boundary);
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Calculating the size of MIME attachments\n"));
    for (content = soap->mime.first; content; content = content->next)
    { register const char *s;
      /* count \r\n--boundary\r\n */
      count += 6 + n;
      /* count Content-Type: ...\r\n */
      if (content->type)
        count += 16 + strlen(content->type);
      /* count Content-Transfer-Encoding: ...\r\n */
      s = soap_code_str(mime_codes, content->encoding);
      if (s)
        count += 29 + strlen(s);
      /* count Content-ID: ...\r\n */
      if (content->id)
        count += 14 + strlen(content->id);
      /* count Content-Location: ...\r\n */
      if (content->location)
        count += 20 + strlen(content->location);
      /* count Content-Description: ...\r\n */
      if (content->description)
        count += 23 + strlen(content->description);
      /* count \r\n...content */
      count += 2 + content->size;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Size of MIME attachment content is %lu bytes\n", (unsigned long)content->size));
    }
    /* count \r\n--boundary-- */
    count += 6 + n;
  }
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "New count is %lu bytes\n", (unsigned long)count));
  return count;
#else
  return soap->count;
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r14
movq 0x6110(%rdi), %rbx
movl 0x4(%rdi), %ebp
movl %ebp, %eax
andl $0x280, %eax            # imm = 0x280
cmpl $0x80, %eax
jne 0x455da
leaq 0x19278(%r14), %r15
movq (%r15), %r15
testq %r15, %r15
je 0x455da
movq 0x10(%r15), %rax
movq 0x18(%r15), %rdi
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rbx
addq $0xc, %rbx
testq %rdi, %rdi
je 0x455a2
callq 0x3110
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rbx
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0x455bb
callq 0x3110
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rbx
movq 0x28(%r15), %rax
testq %rax, %rax
je 0x4556e
movzwl 0x2(%rax), %eax
rolw $0x8, %ax
movzwl %ax, %eax
addl $0x7, %eax
andl $-0x4, %eax
addq %rax, %rbx
jmp 0x4556e
btl $0x8, %ebp
jae 0x456a1
movq 0x19288(%r14), %rdi
testq %rdi, %rdi
je 0x456a1
callq 0x3110
movq %rax, %r15
addq $0x192a0, %r14          # imm = 0x192A0
addq $0x6, %r15
leaq 0x29e82(%rip), %r12     # 0x6f490
addq %r15, %rbx
movq (%r14), %r14
testq %r14, %r14
je 0x456a1
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x45632
callq 0x3110
addq %rax, %rbx
addq $0x10, %rbx
movl 0x30(%r14), %esi
movq %r12, %rdi
callq 0x35176
testq %rax, %rax
je 0x45652
movq %rax, %rdi
callq 0x3110
addq %rax, %rbx
addq $0x1d, %rbx
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0x45667
callq 0x3110
addq %rax, %rbx
addq $0xe, %rbx
movq 0x38(%r14), %rdi
testq %rdi, %rdi
je 0x4567c
callq 0x3110
addq %rax, %rbx
addq $0x14, %rbx
movq 0x40(%r14), %rdi
testq %rdi, %rdi
je 0x45691
callq 0x3110
addq %rax, %rbx
addq $0x17, %rbx
movq 0x10(%r14), %rax
addq %rax, %rbx
addq $0x2, %rbx
jmp 0x4560e
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq