// File: /workspace/github_c_makefile_star2_O3/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 0x406d8
movq %rdi, %rbx
movq 0x19288(%rdi), %rdx
testq %rdx, %rdx
je 0x406d8
movq 0x192a0(%rbx), %r14
testq %r14, %r14
je 0x406ae
leaq 0x16538(%rbx), %r15
movq 0x60a0(%rbx), %rax
testq %rax, %rax
je 0x4061b
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 0x4060d
movq %rax, %r12
movq 0x10(%r14), %rbp
movq %rbx, %rdi
movq %r14, %rsi
callq 0x484e8
testl %eax, %eax
jne 0x406d2
testq %rbp, %rbp
je 0x40647
movl $0x400, %eax            # imm = 0x400
movq %rbp, %rcx
cmpq %rax, %rbp
jb 0x405ce
movl $0x400, %ecx            # imm = 0x400
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq *0x60c0(%rbx)
testq %rax, %rax
je 0x4067d
movq %rax, %r13
movq %rbx, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x379c8
testl %eax, %eax
je 0x405fe
xorl %r13d, %r13d
testl %eax, %eax
jne 0x40687
subq %r13, %rbp
jne 0x405bc
jmp 0x40687
movl 0x19214(%rbx), %eax
testl %eax, %eax
jne 0x406d8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x484e8
testl %eax, %eax
jne 0x406d2
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
movq %rbx, %rdi
callq 0x379c8
testl %eax, %eax
je 0x4069b
jmp 0x406d2
testb $0x42, 0x4(%rbx)
je 0x40687
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 0x379c8
testq %r13, %r13
je 0x40687
testl %eax, %eax
je 0x4064d
jmp 0x40687
movl $0xffffffff, 0x19214(%rbx) # imm = 0xFFFFFFFF
movq 0x60b0(%rbx), %rax
testq %rax, %rax
je 0x4069b
movq %rbx, %rdi
movq %r12, %rsi
callq *%rax
movq (%r14), %r14
testq %r14, %r14
jne 0x4056f
movq 0x19288(%rbx), %rdx
leaq 0x1222d(%rip), %rsi     # 0x528e2
leaq 0x12228(%rip), %rcx     # 0x528e4
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37cd1
movl 0x19214(%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq