// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorl %r13d, %r13d
testb $-0x80, 0x4(%rdi)
je 0x40630
movq %rdi, %rbx
leaq 0x19278(%rdi), %r15
leaq 0x19258(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x16538(%rdi), %r14
movq (%r15), %r15
testq %r15, %r15
je 0x4062d
movq 0x10(%r15), %rax
movq %rax, 0x19230(%rbx)
movq 0x18(%r15), %rdx
movq %rdx, 0x19258(%rbx)
movq 0x20(%r15), %rcx
movq %rcx, 0x19260(%rbx)
movq 0x28(%r15), %r8
movq %r8, 0x19268(%rbx)
movb $0x18, 0x19248(%rbx)
movq 0x6070(%rbx), %rax
testq %rax, %rax
je 0x4051e
movq 0x8(%r15), %rsi
movq %rbx, %rdi
callq *%rax
movq %rax, %r12
testq %rax, %rax
jne 0x4046c
cmpl $0x0, 0x19214(%rbx)
je 0x4051e
testq %r12, %r12
je 0x4054f
movq 0x10(%r15), %rbp
testq %rbp, %rbp
movl %r13d, 0xc(%rsp)
je 0x40566
cmpq $0x0, (%r15)
jne 0x40494
orb $0x2, 0x19248(%rbx)
movq %rbx, %rdi
callq 0x47d97
testl %eax, %eax
jne 0x4054f
movl $0x400, %eax            # imm = 0x400
movq %rbp, %rcx
cmpq %rax, %rbp
jb 0x404b6
movl $0x400, %ecx            # imm = 0x400
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq *0x6090(%rbx)
testq %rax, %rax
je 0x404ea
movq %rax, %r13
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x376e8
testl %eax, %eax
setne %al
je 0x404e5
xorl %r13d, %r13d
subq %r13, %rbp
jmp 0x404f6
movl $0xffffffff, 0x19214(%rbx) # imm = 0xFFFFFFFF
movb $0x1, %al
testb %al, %al
jne 0x404ff
testq %rbp, %rbp
jne 0x404a4
xorl %edx, %edx
subl 0x19230(%rbx), %edx
andl $0x3, %edx
movq %rbx, %rdi
leaq 0x11c4d(%rip), %rsi     # 0x52161
callq 0x376e8
jmp 0x40604
cmpq $0x0, (%r15)
jne 0x4052b
orb $0x2, 0x19248(%rbx)
movq %rbx, %rdi
callq 0x47d97
testl %eax, %eax
jne 0x4054f
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
movq %rbx, %rdi
callq 0x47eb4
testl %eax, %eax
je 0x40625
movl 0x19214(%rbx), %r13d
xorl %ebp, %ebp
testb %bpl, %bpl
jne 0x403ff
jmp 0x40630
testb $0x42, 0x4(%rbx)
je 0x40487
movq 0x10(%rsp), %rbp
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 0x405ad
andb $-0x2, %al
movb %al, 0x19248(%rbx)
cmpq $0x0, (%r15)
jne 0x405b5
orb $0x2, %al
jmp 0x405af
orb $0x1, %al
movb %al, 0x19248(%rbx)
movq %r13, 0x19230(%rbx)
movq %rbx, %rdi
callq 0x47d97
testl %eax, %eax
jne 0x40604
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x47eb4
testl %eax, %eax
jne 0x40604
cmpq $0x0, (%rbp)
je 0x405f7
andb $-0x15, 0x19248(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rbp)
movq $0x0, 0x10(%rbp)
cmpq $0x3ff, %r13            # imm = 0x3FF
ja 0x40575
movq 0x6080(%rbx), %rax
movb $0x1, %bpl
testq %rax, %rax
je 0x4061b
movq %rbx, %rdi
movq %r12, %rsi
callq *%rax
movl 0xc(%rsp), %r13d
jmp 0x40558
movb $0x1, %bpl
jmp 0x40558
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq