// File: /workspace/github_c_makefile_star2_O2/loversmile[P]sugarcrm/sugar_stdsoap2.c
// Function: soap_putmime
SOAP_FMAC2
soap_putmime(struct soap *soap)
{ struct soap_multipart *content;
  if (!(soap->mode & SOAP_ENC_MIME) || !soap->mime.boundary)
    return SOAP_OK;
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Sending MIME attachments\n"));
  for (content = soap->mime.first; content; content = content->next)
  { void *handle;
    if (soap->fmimereadopen && ((handle = soap->fmimereadopen(soap, (void*)content->ptr, content->id, content->type, content->description)) || soap->error))
    { size_t size = content->size;
      if (!handle)
      { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fmimereadopen failed\n"));
        return soap->error;
      }
      if (soap_putmimehdr(soap, content))
        return soap->error;
      if (!size)
      { if ((soap->mode & SOAP_ENC_XML) || (soap->mode & SOAP_IO) == SOAP_IO_CHUNK || (soap->mode & SOAP_IO) == SOAP_IO_STORE)
        { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Chunked streaming MIME\n"));
          do 
          { size = soap->fmimeread(soap, handle, soap->tmpbuf, sizeof(soap->tmpbuf));
            DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fmimeread returned %lu bytes\n", (unsigned long)size));
            if (soap_send_raw(soap, soap->tmpbuf, size))
              break;
          } while (size); 
        }
        else
        { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "Error: cannot chunk streaming MIME (no HTTP chunking)\n"));
        }
      }
      else
      { do
        { size_t bufsize;
          if (size < sizeof(soap->tmpbuf))
            bufsize = size;
          else
            bufsize = sizeof(soap->tmpbuf);
          if (!(bufsize = soap->fmimeread(soap, handle, soap->tmpbuf, bufsize)))
          { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "fmimeread 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);
      }
      if (soap->fmimereadclose)
        soap->fmimereadclose(soap, handle);
    }
    else
    { if (soap_putmimehdr(soap, content)
       || soap_send_raw(soap, content->ptr, content->size))
        return soap->error;
    }
  }
  return soap_send3(soap, "\r\n--", soap->mime.boundary, "--");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %eax, %eax
testb $0x1, 0x5(%rdi)
je 0x3c88a
movq %rdi, %rbx
cmpq $0x0, 0x19288(%rdi)
je 0x3c88a
leaq 0x192a0(%rbx), %r14
leaq 0x16538(%rbx), %r15
movq (%r14), %r14
testq %r14, %r14
je 0x3c899
movq 0x60a0(%rbx), %rax
testq %rax, %rax
je 0x3c801
movq 0x8(%r14), %rsi
movq 0x18(%r14), %rdx
movq 0x20(%r14), %rcx
movq 0x40(%r14), %r8
movq %rbx, %rdi
callq *%rax
testq %rax, %rax
je 0x3c7f3
movq %rax, %r12
movq 0x10(%r14), %rbp
movq %rbx, %rdi
movq %r14, %rsi
callq 0x43d53
testl %eax, %eax
jne 0x3c884
testq %rbp, %rbp
je 0x3c82a
movl $0x400, %eax            # imm = 0x400
movq %rbp, %rcx
cmpq %rax, %rbp
jb 0x3c7b8
movl $0x400, %ecx            # imm = 0x400
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq *0x60c0(%rbx)
testq %rax, %rax
je 0x3c860
movq %rax, %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x347c4
testl %eax, %eax
je 0x3c7e8
xorl %r13d, %r13d
testl %eax, %eax
jne 0x3c867
subq %r13, %rbp
jne 0x3c7a6
jmp 0x3c867
movl 0x19214(%rbx), %eax
testl %eax, %eax
jne 0x3c88a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x43d53
testl %eax, %eax
jne 0x3c884
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
movq %rbx, %rdi
callq 0x347c4
testl %eax, %eax
je 0x3c74d
jmp 0x3c884
testb $0x42, 0x4(%rbx)
je 0x3c867
movl $0x400, %ecx            # imm = 0x400
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq *0x60c0(%rbx)
movq %rax, %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x347c4
testq %r13, %r13
je 0x3c867
testl %eax, %eax
je 0x3c830
jmp 0x3c867
orl $-0x1, 0x19214(%rbx)
movq 0x60b0(%rbx), %rax
testq %rax, %rax
je 0x3c74d
movq %rbx, %rdi
movq %r12, %rsi
callq *%rax
jmp 0x3c74d
movl 0x19214(%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x19288(%rbx), %rdx
leaq 0x1103b(%rip), %rsi     # 0x4d8e2
leaq 0x11036(%rip), %rcx     # 0x4d8e4
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x34aa2