// File: /workspace/github_c_makefile_star2_O2/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_putdime
SOAP_FMAC2
soap_putdime(struct soap *soap)
{ struct soap_multipart *content;
  if (!(soap->mode & SOAP_ENC_DIME))
    return SOAP_OK;
  for (content = soap->dime.first; content; content = content->next)
  { void *handle;
    soap->dime.size = content->size;
    soap->dime.id = content->id;
    soap->dime.type = content->type;
    soap->dime.options = content->options;
    soap->dime.flags = SOAP_DIME_VERSION | SOAP_DIME_MEDIA;
    if (soap->fdimereadopen && ((handle = soap->fdimereadopen(soap, (void*)content->ptr, content->id, content->type, content->options)) || soap->error))
    { size_t size = content->size;
      if (!handle)
      { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadopen failed\n"));
        return soap->error;
      }
      if (!size && ((soap->mode & SOAP_ENC_XML) || (soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_IO) == SOAP_IO_STORE))
      { size_t chunksize = sizeof(soap->tmpbuf);
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked streaming DIME\n"));
        do 
        { size = soap->fdimeread(soap, handle, soap->tmpbuf, chunksize);
          DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread returned %lu bytes\n", (unsigned long)size));
          if (size < chunksize)
          { soap->dime.flags &= ~SOAP_DIME_CF;
            if (!content->next)
              soap->dime.flags |= SOAP_DIME_ME;
          }
          else
            soap->dime.flags |= SOAP_DIME_CF;
          soap->dime.size = size;
          if (soap_putdimehdr(soap)
           || soap_putdimefield(soap, soap->tmpbuf, size))
            break;
          if (soap->dime.id)
          { soap->dime.flags &= ~(SOAP_DIME_MB | SOAP_DIME_MEDIA);
            soap->dime.id = NULL;
            soap->dime.type = NULL;
            soap->dime.options = NULL;
          }  
        } while (size >= chunksize);
      }
      else
      { if (!content->next)
          soap->dime.flags |= SOAP_DIME_ME;
        if (soap_putdimehdr(soap))
          return soap->error;
        do
        { size_t bufsize;
          if (size < sizeof(soap->tmpbuf))
            bufsize = size;
          else
            bufsize = sizeof(soap->tmpbuf);
          if (!(bufsize = soap->fdimeread(soap, handle, soap->tmpbuf, bufsize)))
          { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimeread failed: insufficient data (%lu bytes remaining from %lu bytes)\n", (unsigned long)size, (unsigned long)content->size));
            soap->error = SOAP_EOF;
            break;
          }
          if (soap_send_raw(soap, soap->tmpbuf, bufsize))
            break;
          size -= bufsize;
        } while (size);
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n"));
        soap_send_raw(soap, SOAP_STR_PADDING, -(long)soap->dime.size&3);
      }
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fdimereadclose\n"));
      if (soap->fdimereadclose)
        soap->fdimereadclose(soap, handle);
    }
    else
    { if (!content->next)
        soap->dime.flags |= SOAP_DIME_ME;
      if (soap_putdimehdr(soap)
       || soap_putdimefield(soap, (char*)content->ptr, content->size))
        return soap->error;
    }
  }
  return SOAP_OK;
}

// Assembly:
xorl %eax, %eax
testb $-0x80, 0x4(%rdi)
je 0x3c716
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x19278(%rdi), %rbp
leaq 0x19258(%rdi), %rax
movq %rax, (%rsp)
leaq 0x16538(%rdi), %r14
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x3c706
movq 0x10(%rbp), %rax
movq %rax, 0x19230(%rbx)
movq 0x18(%rbp), %rdx
movq %rdx, 0x19258(%rbx)
movq 0x20(%rbp), %rcx
movq %rcx, 0x19260(%rbx)
movq 0x28(%rbp), %r8
movq %r8, 0x19268(%rbx)
movb $0x18, 0x19248(%rbx)
movq 0x6070(%rbx), %rax
testq %rax, %rax
je 0x3c5e2
movq 0x8(%rbp), %rsi
movq %rbx, %rdi
callq *%rax
testq %rax, %rax
je 0x3c5d4
movq %rax, %r12
movq 0x10(%rbp), %r15
testq %r15, %r15
je 0x3c65b
cmpq $0x0, (%rbp)
jne 0x3c57b
orb $0x2, 0x19248(%rbx)
movq %rbx, %rdi
callq 0x430cd
testl %eax, %eax
jne 0x3c6fe
movl $0x400, %eax            # imm = 0x400
movq %r15, %rcx
cmpq %rax, %r15
jb 0x3c59d
movl $0x400, %ecx            # imm = 0x400
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq *0x6090(%rbx)
testq %rax, %rax
je 0x3c61d
movq %rax, %r13
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x347c4
testl %eax, %eax
je 0x3c5c9
xorl %r13d, %r13d
testl %eax, %eax
jne 0x3c624
subq %r13, %r15
jne 0x3c58b
jmp 0x3c624
movl 0x19214(%rbx), %eax
testl %eax, %eax
jne 0x3c708
cmpq $0x0, (%rbp)
jne 0x3c5f0
orb $0x2, 0x19248(%rbx)
movq %rbx, %rdi
callq 0x430cd
testl %eax, %eax
jne 0x3c6fe
movq 0x8(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq %rbx, %rdi
callq 0x431e8
testl %eax, %eax
je 0x3c4ff
jmp 0x3c6fe
orl $-0x1, 0x19214(%rbx)
xorl %edx, %edx
subl 0x19230(%rbx), %edx
andl $0x3, %edx
movq %rbx, %rdi
leaq 0x10b28(%rip), %rsi     # 0x4d161
callq 0x347c4
movq 0x6080(%rbx), %rax
testq %rax, %rax
je 0x3c4ff
movq %rbx, %rdi
movq %r12, %rsi
callq *%rax
jmp 0x3c4ff
testb $0x42, 0x4(%rbx)
je 0x3c56d
movq (%rsp), %r15
movl $0x400, %ecx            # imm = 0x400
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq *0x6090(%rbx)
movq %rax, %r13
movb 0x19248(%rbx), %al
cmpq $0x3ff, %r13            # imm = 0x3FF
ja 0x3c6a2
andb $-0x2, %al
movb %al, 0x19248(%rbx)
cmpq $0x0, (%rbp)
jne 0x3c6aa
orb $0x2, %al
jmp 0x3c6a4
orb $0x1, %al
movb %al, 0x19248(%rbx)
movq %r13, 0x19230(%rbx)
movq %rbx, %rdi
callq 0x430cd
testl %eax, %eax
jne 0x3c63e
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x431e8
testl %eax, %eax
jne 0x3c63e
cmpq $0x0, (%r15)
je 0x3c6ec
andb $-0x15, 0x19248(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
andq $0x0, 0x10(%r15)
cmpq $0x3ff, %r13            # imm = 0x3FF
ja 0x3c669
jmp 0x3c63e
movl 0x19214(%rbx), %eax
jmp 0x3c708
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq