// File: /workspace/github_cpp_makefile_star2_O2/A-deLuna[P]encora-cpp-test/main.cpp
// Function: testFindSum()
void testFindSum() {
  struct TestCase {
    uint32_t T;
    std::vector<uint32_t> I;
    bool emptySet;
    uint32_t S;
  };

  std::vector<uint32_t> thousandOnes(1000, 1);
  std::vector<TestCase> cases = {
      {.T = 11, .I = {1, 2, 3, 4, 5, 6, 7}, .emptySet = false, .S = 11},
      {.T = 7, .I = {2, 9, 1, 5}, .emptySet = false, .S = 7},
      {.T = 5, .I = {10, 20}, .emptySet = true, .S = 0},
      {.T = 40, .I = {10, 20}, .emptySet = false, .S = 30},
      {.T = 10,
       .I = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
       .emptySet = false,
       .S = 10},
      {.T = 0, .I = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, .emptySet = true, .S = 0},
      {.T = 10, .I = {}, .emptySet = true, .S = 0},
      {.T = 10, .I = {0, 0, 0}, .emptySet = true, .S = 0},
      {.T = 1000, .I = std::move(thousandOnes), .emptySet = false, .S = 1000},
  };
  int failedCases = 0;

  std::vector<uint32_t> M;
  uint32_t S;
  for (size_t i = 0; i < cases.size(); i++) {
    const TestCase& c = cases[i];
    find_largest_sum(c.T, c.I, M, S);

    if (S != c.S) {
      std::cout << "Error in case " << i << " expected S to be " << c.S << "\n";
      std::cout << "but got " << S << "\n";
      failedCases++;
      continue;
    }
    uint32_t sum = 0;
    for (auto i : M)
      sum += i;

    if (sum != c.S) {
      std::cout << "Error in case " << i << " expected M sum to be " << c.S
                << "\n";
      std::cout << "but got " << sum << "\n";
      failedCases++;
      continue;
    }

    if (M.empty() && !c.emptySet) {
      std::cout << "Error in case " << i
                << " M is empty but was not expected\n";
      failedCases++;
      continue;
    }
    if (!M.empty() && c.emptySet) {
      std::cout << "Error in case " << i
                << " M is not empty but was expected to be\n";
      failedCases++;
      continue;
    }
  }
  if (failedCases == 0) {
    std::cout << "find_largest_sum: All cases succeeded\n";
  } else {
    std::cout << "find_largest_sum: failed a total of " << failedCases
              << " cases\n";
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
leaq 0x90(%rsp), %rbx
movl $0x1, (%rbx)
leaq 0x30(%rsp), %rdi
leaq 0x50(%rsp), %rcx
movl $0x3e8, %esi            # imm = 0x3E8
movq %rbx, %rdx
callq 0x2346
movl $0xb, (%rbx)
leaq 0x98(%rsp), %rdi
movups 0x1421(%rip), %xmm0     # 0x310c
leaq 0x220(%rsp), %rsi
movups %xmm0, 0xc(%rsi)
movups 0x1402(%rip), %xmm0     # 0x3100
movaps %xmm0, (%rsi)
pushq $0x7
popq %rdx
leaq 0xf(%rsp), %rcx
callq 0x239c
leaq 0xb8(%rsp), %r14
movb $0x0, -0x8(%r14)
movabsq $0x70000000b, %rax      # imm = 0x70000000B
movq %rax, -0x4(%r14)
leaq 0xc0(%rsp), %rdi
movaps 0x1338(%rip), %xmm0     # 0x3070
leaq 0x210(%rsp), %rsi
movaps %xmm0, (%rsi)
pushq $0x4
popq %rdx
leaq 0xe(%rsp), %rcx
callq 0x239c
leaq 0xe0(%rsp), %r14
movb $0x0, -0x8(%r14)
movabsq $0x500000007, %rax      # imm = 0x500000007
movq %rax, -0x4(%r14)
leaq 0xe8(%rsp), %rdi
movabsq $0x140000000a, %r15     # imm = 0x140000000A
leaq 0x88(%rsp), %rsi
movq %r15, (%rsi)
pushq $0x2
popq %rdx
leaq 0xd(%rsp), %rcx
callq 0x239c
leaq 0x108(%rsp), %r14
movb $0x1, -0x8(%r14)
movabsq $0x2800000000, %rax     # imm = 0x2800000000
movq %rax, -0x4(%r14)
leaq 0x110(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movq %r15, (%rsi)
pushq $0x2
popq %rdx
leaq 0xc(%rsp), %rcx
callq 0x239c
leaq 0x130(%rsp), %r14
movb $0x0, -0x8(%r14)
movabsq $0xa0000001e, %rax      # imm = 0xA0000001E
movq %rax, -0x4(%r14)
leaq 0x138(%rsp), %rdi
movups 0x1332(%rip), %xmm0     # 0x312c
leaq 0x50(%rsp), %rsi
movaps %xmm0, 0x10(%rsi)
movups 0x1312(%rip), %xmm0     # 0x311c
movaps %xmm0, (%rsi)
movabsq $0x100000001, %r15      # imm = 0x100000001
movq %r15, 0x20(%rsi)
pushq $0xa
popq %rdx
leaq 0xb(%rsp), %rcx
callq 0x239c
leaq 0x158(%rsp), %r14
movb $0x0, -0x8(%r14)
movq $0xa, -0x4(%r14)
leaq 0x160(%rsp), %rdi
leaq 0x240(%rsp), %rsi
movups 0x12d8(%rip), %xmm0     # 0x312c
movaps %xmm0, 0x10(%rsi)
movups 0x12bd(%rip), %xmm0     # 0x311c
movaps %xmm0, (%rsi)
movq %r15, 0x20(%rsi)
pushq $0xa
popq %rdx
leaq 0xa(%rsp), %rcx
callq 0x239c
movb $0x1, %al
leaq 0x1a8(%rsp), %r14
movb %al, -0x30(%r14)
movabsq $0xa00000000, %rcx      # imm = 0xA00000000
movq %rcx, -0x2c(%r14)
andq $0x0, -0x10(%r14)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%r14)
movb %al, -0x8(%r14)
movq %rcx, -0x4(%r14)
leaq 0x204(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x1b0(%rsp), %rdi
andl $0x0, 0x8(%rsi)
pushq $0x3
popq %rdx
leaq 0x9(%rsp), %rcx
callq 0x239c
movb $0x1, 0x1c8(%rsp)
movabsq $0x3e800000000, %rax    # imm = 0x3E800000000
movq %rax, 0x1cc(%rsp)
movaps 0x30(%rsp), %xmm0
movups %xmm0, 0x1d8(%rsp)
movq 0x40(%rsp), %rax
andq $0x0, 0x40(%rsp)
movq %rax, 0x1e8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movb $0x0, 0x1f0(%rsp)
movl $0x3e8, 0x1f4(%rsp) # imm = 0x3E8
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movl $0x168, %edi            # imm = 0x168
callq 0x10e0
movq %rax, %r14
movq %rax, 0x10(%rsp)
addq $0x168, %rax            # imm = 0x168
movq %rax, 0x20(%rsp)
xorl %r15d, %r15d
cmpq $0x168, %r15            # imm = 0x168
je 0x1f84
leaq (%rsp,%r15), %rsi
addq $0x98, %rsi
movl -0x8(%rsi), %eax
movl %eax, (%r14,%r15)
leaq (%r14,%r15), %rdi
addq $0x8, %rdi
callq 0x24c4
movq 0xb0(%rsp,%r15), %rax
movq %rax, 0x20(%r14,%r15)
addq $0x28, %r15
jmp 0x1f49
addq %r15, %r14
movq %r14, 0x18(%rsp)
movl $0x148, %ebx            # imm = 0x148
leaq (%rsp,%rbx), %rdi
addq $0x90, %rdi
callq 0x23fe
addq $-0x28, %rbx
cmpq $-0x20, %rbx
jne 0x1f91
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rax
andq $0x0, 0x10(%rax)
movaps %xmm0, (%rax)
movq 0x10(%rsp), %r15
movq 0x18(%rsp), %rax
subq %r15, %rax
pushq $0x28
popq %rcx
cqto
idivq %rcx
movq %rax, 0x48(%rsp)
xorl %ebx, %ebx
movq 0x3ff7(%rip), %r14      # 0x5fd8
xorl %r13d, %r13d
cmpq 0x48(%rsp), %r13
je 0x219b
imulq $0x28, %r13, %rbp
leaq (%r15,%rbp), %rsi
addq $0x8, %rsi
movl -0x8(%rsi), %edi
leaq 0x90(%rsp), %rdx
leaq 0x50(%rsp), %rcx
callq 0x1380
addq %r15, %rbp
movl 0x50(%rsp), %ecx
cmpl 0x24(%rbp), %ecx
jne 0x2040
movq 0x90(%rsp), %rax
movq 0x98(%rsp), %rdx
xorl %r12d, %r12d
movq %rax, %rsi
cmpq %rdx, %rsi
je 0x20b2
addl (%rsi), %r12d
addq $0x4, %rsi
jmp 0x2032
movq %r14, %rdi
leaq 0x11da(%rip), %rsi      # 0x3224
callq 0x10d0
movq %rax, %rdi
movq %r13, %rsi
callq 0x1090
movq %rax, %rdi
leaq 0x11cf(%rip), %rsi      # 0x3233
callq 0x10d0
movl 0x24(%rbp), %esi
movq %rax, %rdi
callq 0x1090
movq %rax, %rdi
leaq 0x110a(%rip), %rsi      # 0x3188
callq 0x10d0
movq %r14, %rdi
leaq 0x11b9(%rip), %rsi      # 0x3246
callq 0x10d0
movl 0x50(%rsp), %esi
movq %rax, %rdi
callq 0x1090
movq %rax, %rdi
leaq 0x10e0(%rip), %rsi      # 0x3188
callq 0x10d0
jmp 0x2162
cmpl %ecx, %r12d
jne 0x20f6
movb 0x20(%rbp), %cl
cmpq %rdx, %rax
je 0x216c
testb %cl, %cl
je 0x2164
movq %r14, %rdi
leaq 0x114f(%rip), %rsi      # 0x3224
callq 0x10d0
movq %rax, %rdi
movq %r13, %rsi
callq 0x1090
movq %rax, %rdi
leaq 0x1199(%rip), %rsi      # 0x3288
callq 0x10d0
jmp 0x2162
movq %r14, %rdi
leaq 0x1124(%rip), %rsi      # 0x3224
callq 0x10d0
movq %rax, %rdi
movq %r13, %rsi
callq 0x1090
movq %rax, %rdi
leaq 0x1135(%rip), %rsi      # 0x324f
callq 0x10d0
movl 0x24(%rbp), %esi
movq %rax, %rdi
callq 0x1090
movq %rax, %rdi
leaq 0x1054(%rip), %rsi      # 0x3188
callq 0x10d0
movq %r14, %rdi
leaq 0x1103(%rip), %rsi      # 0x3246
callq 0x10d0
movl %r12d, %esi
movq %rax, %rdi
callq 0x1090
movq %rax, %rdi
leaq 0x102b(%rip), %rsi      # 0x3188
callq 0x10d0
incl %ebx
incq %r13
jmp 0x1fe4
testb %cl, %cl
jne 0x2164
movq %r14, %rdi
leaq 0x10aa(%rip), %rsi      # 0x3224
callq 0x10d0
movq %rax, %rdi
movq %r13, %rsi
callq 0x1090
movq %rax, %rdi
leaq 0x10d2(%rip), %rsi      # 0x3266
callq 0x10d0
jmp 0x2162
testl %ebx, %ebx
je 0x21c8
movq 0x3e32(%rip), %rdi      # 0x5fd8
leaq 0x112a(%rip), %rsi      # 0x32d7
callq 0x10d0
movq %rax, %rdi
movl %ebx, %esi
callq 0x1150
movq %rax, %r14
leaq 0x1056(%rip), %rsi      # 0x321c
jmp 0x21cf
leaq 0x10e1(%rip), %rsi      # 0x32b0
movq %r14, %rdi
callq 0x10d0
leaq 0x90(%rsp), %rdi
callq 0x23fe
leaq 0x10(%rsp), %rdi
callq 0x22e2
leaq 0x30(%rsp), %rdi
callq 0x23fe
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
jmp 0x2250
jmp 0x2219
jmp 0x2219
jmp 0x2219
jmp 0x2219
jmp 0x2219
movq %rax, %r15
xorl %eax, %eax
jmp 0x2284
movq %rax, %r15
jmp 0x22d0
jmp 0x22b6
movq %rax, %rdi
callq 0x1060
movq %r14, %rsi
addq %r15, %rsi
movq %r14, %rdi
callq 0x2320
callq 0x1100
movq %rax, %r15
callq 0x1130
leaq 0x1d0(%rsp), %r14
leaq 0x10(%rsp), %rdi
callq 0x2308
movl $0x148, %r12d           # imm = 0x148
leaq (%rsp,%r12), %rdi
addq $0x90, %rdi
callq 0x23fe
addq $-0x28, %r12
cmpq $-0x20, %r12
jne 0x2268
movb $0x1, %al
cmpq %r14, %rbx
sete %cl
testb %al, %al
jne 0x22d0
testb %cl, %cl
jne 0x22d0
leaq -0x28(%r14), %r12
addq $-0x20, %r14
movq %r14, %rdi
callq 0x23fe
movq %r12, %r14
cmpq %rbx, %r12
jne 0x2292
jmp 0x22d0
movq %rax, %rdi
callq 0x166b
jmp 0x22b6
movq %rax, %r15
leaq 0x90(%rsp), %rdi
callq 0x23fe
leaq 0x10(%rsp), %rdi
callq 0x22e2
leaq 0x30(%rsp), %rdi
callq 0x23fe
movq %r15, %rdi
callq 0x1160