// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
movq 0x6110(%rdi), %rbx
movl 0x4(%rdi), %ebp
movl %ebp, %eax
andl $0x280, %eax            # imm = 0x280
cmpl $0x80, %eax
jne 0x4a5ab
movq 0x19278(%r15), %r14
testq %r14, %r14
je 0x4a5ab
movq 0x10(%r14), %rax
movq 0x18(%r14), %rdi
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rbx
addq $0xc, %rbx
testq %rdi, %rdi
je 0x4a570
callq 0x3110
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rbx
movq 0x20(%r14), %rdi
testq %rdi, %rdi
je 0x4a589
callq 0x3110
addq $0x3, %rax
andq $-0x4, %rax
addq %rax, %rbx
movq 0x28(%r14), %rax
testq %rax, %rax
je 0x4a5a6
movzwl 0x2(%rax), %eax
rolw $0x8, %ax
movzwl %ax, %eax
addl $0x7, %eax
andl $-0x4, %eax
addq %rax, %rbx
movq (%r14), %r14
jmp 0x4a53f
btl $0x8, %ebp
jae 0x4a6a5
movq 0x19288(%r15), %rdi
testq %rdi, %rdi
je 0x4a6a5
callq 0x3110
movq %rax, %r14
movq 0x192a0(%r15), %r15
testq %r15, %r15
je 0x4a69e
leaq 0x6(%r14), %r12
leaq 0x26ea8(%rip), %r13     # 0x71490
leaq 0x26f11(%rip), %rbp     # 0x71500
addq %r12, %rbx
movq 0x20(%r15), %rdi
testq %rdi, %rdi
je 0x4a607
callq 0x3110
addq %rax, %rbx
addq $0x10, %rbx
movl 0x30(%r15), %eax
movq %r13, %rcx
cmpq $0x1, %rax
je 0x4a630
movq %r13, %rdx
cmpq $0x0, 0x8(%rdx)
je 0x4a62d
leaq 0x10(%rdx), %rcx
cmpq %rax, 0x10(%rdx)
movq %rcx, %rdx
jne 0x4a617
jmp 0x4a630
movq %rbp, %rcx
movq 0x8(%rcx), %rdi
testq %rdi, %rdi
je 0x4a645
callq 0x3110
addq %rax, %rbx
addq $0x1d, %rbx
movq 0x18(%r15), %rdi
testq %rdi, %rdi
je 0x4a65a
callq 0x3110
addq %rax, %rbx
addq $0xe, %rbx
movq 0x38(%r15), %rdi
testq %rdi, %rdi
je 0x4a66f
callq 0x3110
addq %rax, %rbx
addq $0x14, %rbx
movq 0x40(%r15), %rdi
testq %rdi, %rdi
je 0x4a684
callq 0x3110
addq %rax, %rbx
addq $0x17, %rbx
movq 0x10(%r15), %rax
movq (%r15), %rcx
addq %rax, %rbx
addq $0x2, %rbx
movq %rcx, %r15
testq %rcx, %rcx
jne 0x4a5ef
addq %r14, %rbx
addq $0x6, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq