// File: tdv[P]boss/boss/examples/simple_enum/main.cpp
// Function: SetMyOffers(Boss::RefObjPtr<Boss::IEnum>, unsigned int, unsigned int)
void SetMyOffers(Boss::RefObjPtr<Boss::IEnum> collection,
                 unsigned minPercent, unsigned maxPercent)
{
  Boss::EnumHelper<MyNs::IFaces::IBestOffer> Collection(collection);
  for (auto i = Collection.First(); i.Get() ; i = Collection.Next())
  {
    Boss::RefObjQIPtr<MyNs::IFaces::IFixPrice> FixPrice(i);
    if (!FixPrice.Get())
      throw std::runtime_error("Failed to get price object.");
    double Price = 0;
    if (FixPrice->GetPrice(&Price) != Boss::Status::Ok)
      throw std::runtime_error("Failed to get price for \"BestOffer\".");
    if (i->MyOffer(Price + (Price * minPercent) / 100) != Boss::Status::Ok)
      throw std::runtime_error("Failed to set my min offer for \"BestOffer\".");
    if (i->MyOffer(Price + (Price * maxPercent) / 100) != Boss::Status::Ok)
      throw std::runtime_error("Failed to set my max offer for \"BestOffer\".");
  }
}

// Assembly:
subq $0xb8, %rsp
movl %esi, %eax
movq %rdi, %rsi
movq %rsi, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
movl %edx, 0xa8(%rsp)
leaq 0x98(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x1a2b0
movq 0x60(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x1ae00
jmp 0x190a8
leaq 0x98(%rsp), %rdi
callq 0x1a3b0
leaq 0x80(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x1aeb0
jmp 0x190cc
jmp 0x190ce
leaq 0x80(%rsp), %rdi
callq 0x1af40
movq %rax, 0x58(%rsp)
jmp 0x190e2
movq 0x58(%rsp), %rax
cmpq $0x0, %rax
jne 0x19157
leaq 0x80(%rsp), %rdi
callq 0x1b160
jmp 0x19490
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x1a3b0
jmp 0x194b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
jmp 0x194a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
jmp 0x19481
leaq 0x78(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1af50
jmp 0x1916b
leaq 0x78(%rsp), %rdi
callq 0x1a4c0
movq %rax, 0x50(%rsp)
jmp 0x1917c
movq 0x50(%rsp), %rax
cmpq $0x0, %rax
jne 0x19203
movl $0x10, %edi
callq 0x23000
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x48(%rsp)
leaq 0xae033(%rip), %rsi     # 0xc71d6
callq 0x365a0
jmp 0x191aa
movq 0x48(%rsp), %rdi
leaq 0xe96fa(%rip), %rsi     # 0x1028b0
leaq 0x13a63(%rip), %rdx     # 0x2cc20
callq 0x24050
jmp 0x194bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
jmp 0x19457
movq 0x48(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
callq 0x23060
jmp 0x19457
movq $0x0, 0x70(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x1a4d0
movq %rax, 0x40(%rsp)
jmp 0x1921d
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
leaq 0x70(%rsp), %rsi
callq *%rax
movl %eax, 0x3c(%rsp)
jmp 0x19236
movl 0x3c(%rsp), %eax
cmpl $0x0, %eax
je 0x192a2
movl $0x10, %edi
callq 0x23000
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x30(%rsp)
leaq 0xadf97(%rip), %rsi     # 0xc71f2
callq 0x365a0
jmp 0x19262
movq 0x30(%rsp), %rdi
leaq 0xe9642(%rip), %rsi     # 0x1028b0
leaq 0x139ab(%rip), %rdx     # 0x2cc20
callq 0x24050
jmp 0x194bf
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
callq 0x23060
jmp 0x19457
leaq 0x80(%rsp), %rdi
callq 0x1afa0
movq %rax, 0x28(%rsp)
jmp 0x192b6
movq 0x28(%rsp), %rdi
movsd 0x70(%rsp), %xmm0
movl 0xac(%rsp), %eax
cvtsi2sd %rax, %xmm2
movaps %xmm0, %xmm1
mulsd %xmm2, %xmm1
movsd 0xadd54(%rip), %xmm2    # 0xc7030
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movl %eax, 0x24(%rsp)
jmp 0x192f3
movl 0x24(%rsp), %eax
cmpl $0x0, %eax
je 0x1935f
movl $0x10, %edi
callq 0x23000
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x18(%rsp)
leaq 0xadeff(%rip), %rsi     # 0xc7217
callq 0x365a0
jmp 0x1931f
movq 0x18(%rsp), %rdi
leaq 0xe9585(%rip), %rsi     # 0x1028b0
leaq 0x138ee(%rip), %rdx     # 0x2cc20
callq 0x24050
jmp 0x194bf
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
callq 0x23060
jmp 0x19457
leaq 0x80(%rsp), %rdi
callq 0x1afa0
movq %rax, 0x10(%rsp)
jmp 0x19373
movq 0x10(%rsp), %rdi
movsd 0x70(%rsp), %xmm0
movl 0xa8(%rsp), %eax
cvtsi2sd %rax, %xmm2
movaps %xmm0, %xmm1
mulsd %xmm2, %xmm1
movsd 0xadc97(%rip), %xmm2    # 0xc7030
divsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movq (%rdi), %rax
movq 0x28(%rax), %rax
callq *%rax
movl %eax, 0xc(%rsp)
jmp 0x193b0
movl 0xc(%rsp), %eax
cmpl $0x0, %eax
je 0x19416
movl $0x10, %edi
callq 0x23000
movq %rax, %rdi
movq %rdi, %rax
movq %rax, (%rsp)
leaq 0xade6f(%rip), %rsi     # 0xc7243
callq 0x365a0
jmp 0x193db
movq (%rsp), %rdi
leaq 0xe94ca(%rip), %rsi     # 0x1028b0
leaq 0x13833(%rip), %rdx     # 0x2cc20
callq 0x24050
jmp 0x194bf
movq (%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
callq 0x23060
jmp 0x19457
leaq 0x78(%rsp), %rdi
callq 0x1a4e0
leaq 0x68(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x1afb0
jmp 0x19434
leaq 0x80(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x1b120
jmp 0x19448
leaq 0x68(%rsp), %rdi
callq 0x1b160
jmp 0x190ce
leaq 0x78(%rsp), %rdi
callq 0x1a4e0
jmp 0x19481
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0x68(%rsp), %rdi
callq 0x1b160
leaq 0x80(%rsp), %rdi
callq 0x1b160
jmp 0x194a5
leaq 0xa0(%rsp), %rdi
callq 0x1b180
addq $0xb8, %rsp
retq
leaq 0xa0(%rsp), %rdi
callq 0x1b180
movq 0x90(%rsp), %rdi
callq 0xc42f0
nop