// File: /workspace/github_c_makefile_star2_O1/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 %r13d, %r13d
testb $0x1, 0x5(%rdi)
je 0x407d8
movq %rdi, %rbx
cmpq $0x0, 0x19288(%rdi)
je 0x407d8
leaq 0x192a0(%rbx), %r14
leaq 0x16538(%rbx), %r15
movq (%r14), %r14
testq %r14, %r14
je 0x407ea
movq 0x60a0(%rbx), %rax
testq %rax, %rax
je 0x4074a
movq 0x8(%r14), %rsi
movq 0x18(%r14), %rdx
movq 0x20(%r14), %rcx
movq 0x40(%r14), %r8
movq %rbx, %rdi
callq *%rax
movq %rax, %r12
testq %rax, %rax
jne 0x406bf
cmpl $0x0, 0x19214(%rbx)
je 0x4074a
testq %r12, %r12
je 0x4076d
movq 0x10(%r14), %rbp
movq %rbx, %rdi
movq %r14, %rsi
callq 0x48bc2
testl %eax, %eax
jne 0x4076d
movl %r13d, 0x4(%rsp)
testq %rbp, %rbp
je 0x40786
movl $0x400, %eax            # imm = 0x400
movq %rbp, %rcx
cmpq %rax, %rbp
jb 0x406ff
movl $0x400, %ecx            # imm = 0x400
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq *0x60c0(%rbx)
testq %rax, %rax
je 0x40733
movq %rax, %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x376e8
testl %eax, %eax
setne %al
je 0x4072e
xorl %r13d, %r13d
subq %r13, %rbp
jmp 0x4073f
movl $0xffffffff, 0x19214(%rbx) # imm = 0xFFFFFFFF
movb $0x1, %al
testb %al, %al
jne 0x407ba
testq %rbp, %rbp
jne 0x406ed
jmp 0x407ba
movq %rbx, %rdi
movq %r14, %rsi
callq 0x48bc2
testl %eax, %eax
jne 0x4076d
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
movq %rbx, %rdi
callq 0x376e8
testl %eax, %eax
je 0x40781
movl 0x19214(%rbx), %r13d
xorl %ebp, %ebp
testb %bpl, %bpl
jne 0x40679
jmp 0x407d8
movb $0x1, %bpl
jmp 0x40776
testb $0x42, 0x4(%rbx)
je 0x407ba
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 0x376e8
testq %r13, %r13
je 0x407ba
testl %eax, %eax
je 0x4078c
movq 0x60b0(%rbx), %rax
movb $0x1, %bpl
testq %rax, %rax
je 0x407d1
movq %rbx, %rdi
movq %r12, %rsi
callq *%rax
movl 0x4(%rsp), %r13d
jmp 0x40776
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x19288(%rbx), %rdx
leaq 0x120ea(%rip), %rsi     # 0x528e2
leaq 0x120e5(%rip), %rcx     # 0x528e4
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x379ee