// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x5d1a9
movl $0x0, -0x4(%rbp)
jmp 0x5d58a
movq -0x10(%rbp), %rax
movq 0x19278(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x5d583
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x19230(%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x19258(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x19260(%rax)
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x19268(%rax)
movq -0x10(%rbp), %rax
movb $0x18, 0x19248(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x6070(%rax)
je 0x5d516
movq -0x10(%rbp), %rax
movq 0x6070(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rsi
movq -0x18(%rbp), %rcx
movq 0x18(%rcx), %rdx
movq -0x18(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq -0x18(%rbp), %r8
movq 0x28(%r8), %r8
callq *%rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x5d278
movq -0x10(%rbp), %rax
cmpl $0x0, 0x19214(%rax)
je 0x5d516
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5d29d
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d58a
cmpq $0x0, -0x28(%rbp)
jne 0x5d3fb
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
jne 0x5d2d9
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x3, %eax
je 0x5d2d9
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jne 0x5d3fb
movq $0x400, -0x30(%rbp)     # imm = 0x400
movq -0x10(%rbp), %rax
movq 0x6090(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x16538, %rdx          # imm = 0x16538
movq -0x30(%rbp), %rcx
callq *%rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x5d347
movq -0x10(%rbp), %rax
movsbl 0x19248(%rax), %ecx
andl $-0x2, %ecx
movb %cl, 0x19248(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x5d345
movq -0x10(%rbp), %rax
movsbl 0x19248(%rax), %ecx
orl $0x2, %ecx
movb %cl, 0x19248(%rax)
jmp 0x5d35b
movq -0x10(%rbp), %rax
movsbl 0x19248(%rax), %ecx
orl $0x1, %ecx
movb %cl, 0x19248(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x19230(%rax)
movq -0x10(%rbp), %rdi
callq 0x68b10
cmpl $0x0, %eax
jne 0x5d395
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x16538, %rsi          # imm = 0x16538
movq -0x28(%rbp), %rdx
callq 0x68d30
cmpl $0x0, %eax
je 0x5d397
jmp 0x5d3f6
movq -0x10(%rbp), %rax
cmpq $0x0, 0x19258(%rax)
je 0x5d3e6
movq -0x10(%rbp), %rax
movsbl 0x19248(%rax), %ecx
andl $-0x15, %ecx
movb %cl, 0x19248(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x19258(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x19260(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x19268(%rax)
jmp 0x5d3e8
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jae 0x5d2e1
jmp 0x5d4f1
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x5d419
movq -0x10(%rbp), %rax
movsbl 0x19248(%rax), %ecx
orl $0x2, %ecx
movb %cl, 0x19248(%rax)
movq -0x10(%rbp), %rdi
callq 0x68b10
cmpl $0x0, %eax
je 0x5d439
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d58a
jmp 0x5d43b
cmpq $0x400, -0x28(%rbp)     # imm = 0x400
jae 0x5d44f
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x5d457
movq $0x400, -0x38(%rbp)     # imm = 0x400
movq -0x10(%rbp), %rax
movq 0x6090(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x10(%rbp), %rdx
addq $0x16538, %rdx          # imm = 0x16538
movq -0x38(%rbp), %rcx
callq *%rax
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x5d495
movq -0x10(%rbp), %rax
movl $0xffffffff, 0x19214(%rax) # imm = 0xFFFFFFFF
jmp 0x5d4ce
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x16538, %rsi          # imm = 0x16538
movq -0x38(%rbp), %rdx
callq 0x4eeb0
cmpl $0x0, %eax
je 0x5d4b4
jmp 0x5d4ce
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x5d43b
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %edx
subq 0x19230(%rax), %rdx
andq $0x3, %rdx
leaq 0x1cf95(%rip), %rsi     # 0x7a481
callq 0x4eeb0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x6080(%rax)
je 0x5d514
movq -0x10(%rbp), %rax
movq 0x6080(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq *%rax
jmp 0x5d571
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x5d534
movq -0x10(%rbp), %rax
movsbl 0x19248(%rax), %ecx
orl $0x2, %ecx
movb %cl, 0x19248(%rax)
movq -0x10(%rbp), %rdi
callq 0x68b10
cmpl $0x0, %eax
jne 0x5d560
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
callq 0x68d30
cmpl $0x0, %eax
je 0x5d56f
movq -0x10(%rbp), %rax
movl 0x19214(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x5d58a
jmp 0x5d571
jmp 0x5d573
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x5d1b8
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)