// File: /workspace/github_c_makefile_star2_O3/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 0x4052d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x19278(%rdi), %rbp
testq %rbp, %rbp
je 0x4051f
leaq 0x19258(%rbx), %rax
movq %rax, (%rsp)
leaq 0x16538(%rbx), %r14
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 0x403eb
movq 0x8(%rbp), %rsi
movq %rbx, %rdi
callq *%rax
testq %rax, %rax
je 0x403dd
movq %rax, %r12
movq 0x10(%rbp), %r15
testq %r15, %r15
je 0x4046c
cmpq $0x0, (%rbp)
jne 0x40384
orb $0x2, 0x19248(%rbx)
movq %rbx, %rdi
callq 0x47727
testl %eax, %eax
jne 0x40515
movl $0x400, %eax            # imm = 0x400
movq %r15, %rcx
cmpq %rax, %r15
jb 0x403a6
movl $0x400, %ecx            # imm = 0x400
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq *0x6090(%rbx)
testq %rax, %rax
je 0x40422
movq %rax, %r13
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x379c8
testl %eax, %eax
je 0x403d2
xorl %r13d, %r13d
testl %eax, %eax
jne 0x4042c
subq %r13, %r15
jne 0x40394
jmp 0x4042c
movl 0x19214(%rbx), %eax
testl %eax, %eax
jne 0x4051f
cmpq $0x0, (%rbp)
jne 0x403f9
orb $0x2, 0x19248(%rbx)
movq %rbx, %rdi
callq 0x47727
testl %eax, %eax
jne 0x40515
movq 0x8(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq %rbx, %rdi
callq 0x47844
testl %eax, %eax
je 0x4045a
jmp 0x40515
movl $0xffffffff, 0x19214(%rbx) # imm = 0xFFFFFFFF
xorl %edx, %edx
subl 0x19230(%rbx), %edx
andl $0x3, %edx
movq %rbx, %rdi
leaq 0x11d20(%rip), %rsi     # 0x52161
callq 0x379c8
movq 0x6080(%rbx), %rax
testq %rax, %rax
je 0x4045a
movq %rbx, %rdi
movq %r12, %rsi
callq *%rax
movq (%rbp), %rbp
testq %rbp, %rbp
jne 0x40315
jmp 0x4051d
testb $0x42, 0x4(%rbx)
je 0x40376
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 0x404af
andb $-0x2, %al
movb %al, 0x19248(%rbx)
cmpq $0x0, (%rbp)
jne 0x404b7
orb $0x2, %al
jmp 0x404b1
orb $0x1, %al
movb %al, 0x19248(%rbx)
movq %r13, 0x19230(%rbx)
movq %rbx, %rdi
callq 0x47727
testl %eax, %eax
jne 0x40446
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x47844
testl %eax, %eax
jne 0x40446
movq (%rsp), %rax
cmpq $0x0, (%rax)
je 0x40503
andb $-0x15, 0x19248(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
cmpq $0x3ff, %r13            # imm = 0x3FF
ja 0x40476
jmp 0x40446
movl 0x19214(%rbx), %eax
jmp 0x4051f
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq