// File: kdungs[P]cpp-prelude/test_prelude.cc
// Function: test_splitAt()
auto test_splitAt() -> void {
  using Prelude::splitAt;
  auto expectL = std::vector<int>{1, 2, 3, 4};
  auto expectR = std::vector<int>{5, 6, 7, 8};
  std::vector<int> resultL, resultR;
  std::tie(resultL, resultR) =
      splitAt(4, std::vector<int>{1, 2, 3, 4, 5, 6, 7, 8});
  assert(resultL == expectL);
  assert(resultR == expectR);
  // empty first half
  expectL = std::vector<int>{};
  expectR = std::vector<int>{1, 2, 3, 4};
  std::tie(resultL, resultR) = splitAt(0, std::vector<int>{1, 2, 3, 4});
  assert(resultL == expectL);
  assert(resultR == expectR);
  // empty second half
  expectL = std::vector<int>{1, 2, 3, 4};
  expectR = std::vector<int>{};
  std::tie(resultL, resultR) = splitAt(10, std::vector<int>{1, 2, 3, 4});
  assert(resultL == expectL);
  assert(resultR == expectR);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3e0, %rsp            # imm = 0x3E0
movl $0x1, -0x38(%rbp)
movl $0x2, -0x34(%rbp)
movl $0x3, -0x30(%rbp)
movl $0x4, -0x2c(%rbp)
leaq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x4, -0x20(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0xa900
movq -0x318(%rbp), %rcx
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x18(%rbp), %rdi
callq 0xa920
jmp 0x5871
leaq -0x39(%rbp), %rdi
callq 0xaa00
movl $0x5, -0x88(%rbp)
movl $0x6, -0x84(%rbp)
movl $0x7, -0x80(%rbp)
movl $0x8, -0x7c(%rbp)
leaq -0x88(%rbp), %rax
movq %rax, -0x78(%rbp)
movq $0x4, -0x70(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0x320(%rbp)
callq 0xa900
movq -0x320(%rbp), %rcx
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0xa920
jmp 0x58dc
leaq -0x89(%rbp), %rdi
callq 0xaa00
leaq -0xa8(%rbp), %rdi
callq 0xaf60
leaq -0xc0(%rbp), %rdi
callq 0xaf60
movups 0x1885d(%rip), %xmm0    # 0x1e164
movaps %xmm0, -0x130(%rbp)
movups 0x1883f(%rip), %xmm0    # 0x1e154
movaps %xmm0, -0x140(%rbp)
leaq -0x140(%rbp), %rax
movq %rax, -0x118(%rbp)
movq $0x8, -0x110(%rbp)
leaq -0x141(%rbp), %rdi
movq %rdi, -0x328(%rbp)
callq 0xa900
movq -0x328(%rbp), %rcx
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdx
leaq -0x108(%rbp), %rdi
callq 0xa920
jmp 0x596b
leaq -0xf0(%rbp), %rdi
movl $0x4, %esi
leaq -0x108(%rbp), %rdx
callq 0xb700
jmp 0x5985
leaq -0x158(%rbp), %rdi
movq %rdi, -0x348(%rbp)
leaq -0xa8(%rbp), %rsi
movq %rsi, -0x338(%rbp)
leaq -0xc0(%rbp), %rdx
callq 0xb7b0
movq -0x348(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
movq %rsi, -0x340(%rbp)
callq 0xb7f0
movq -0x340(%rbp), %rdi
callq 0xb830
leaq -0x108(%rbp), %rdi
callq 0xa9a0
leaq -0x141(%rbp), %rdi
callq 0xaa00
movq -0x338(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xabe0
movb %al, -0x329(%rbp)
jmp 0x5a03
movb -0x329(%rbp), %al
testb $0x1, %al
jne 0x5a0f
jmp 0x5a14
jmp 0x5ab2
leaq 0x18d83(%rip), %rdi     # 0x1e79e
leaq 0x18859(%rip), %rsi     # 0x1e27b
movl $0xe2, %edx
leaq 0x18d83(%rip), %rcx     # 0x1e7b1
callq 0x2110
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0xaa00
jmp 0x60ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x89(%rbp), %rdi
callq 0xaa00
jmp 0x60c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x5a90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0xa9a0
leaq -0x141(%rbp), %rdi
callq 0xaa00
jmp 0x60a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x60a4
leaq -0xc0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xabe0
movb %al, -0x349(%rbp)
jmp 0x5aca
movb -0x349(%rbp), %al
testb $0x1, %al
jne 0x5ad6
jmp 0x5ad8
jmp 0x5af7
leaq 0x18ce6(%rip), %rdi     # 0x1e7c5
leaq 0x18795(%rip), %rsi     # 0x1e27b
movl $0xe3, %edx
leaq 0x18cbf(%rip), %rcx     # 0x1e7b1
callq 0x2110
xorps %xmm0, %xmm0
movaps %xmm0, -0x170(%rbp)
movq $0x0, -0x160(%rbp)
leaq -0x170(%rbp), %rdi
movq %rdi, -0x360(%rbp)
callq 0xaf60
movq -0x360(%rbp), %rsi
leaq -0x18(%rbp), %rdi
callq 0xb600
movq -0x360(%rbp), %rdi
callq 0xa9a0
movl $0x1, -0x1a8(%rbp)
movl $0x2, -0x1a4(%rbp)
movl $0x3, -0x1a0(%rbp)
movl $0x4, -0x19c(%rbp)
leaq -0x1a8(%rbp), %rax
movq %rax, -0x198(%rbp)
movq $0x4, -0x190(%rbp)
leaq -0x1a9(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0xa900
movq -0x358(%rbp), %rcx
movq -0x198(%rbp), %rsi
movq -0x190(%rbp), %rdx
leaq -0x188(%rbp), %rdi
callq 0xa920
jmp 0x5bb2
leaq -0x68(%rbp), %rdi
leaq -0x188(%rbp), %rsi
movq %rsi, -0x370(%rbp)
callq 0xb600
movq -0x370(%rbp), %rdi
callq 0xa9a0
leaq -0x1a9(%rbp), %rdi
callq 0xaa00
movl $0x1, -0x218(%rbp)
movl $0x2, -0x214(%rbp)
movl $0x3, -0x210(%rbp)
movl $0x4, -0x20c(%rbp)
leaq -0x218(%rbp), %rax
movq %rax, -0x208(%rbp)
movq $0x4, -0x200(%rbp)
leaq -0x219(%rbp), %rdi
movq %rdi, -0x368(%rbp)
callq 0xa900
movq -0x368(%rbp), %rcx
movq -0x208(%rbp), %rsi
movq -0x200(%rbp), %rdx
leaq -0x1f8(%rbp), %rdi
callq 0xa920
jmp 0x5c58
xorl %eax, %eax
movl %eax, %esi
leaq -0x1e0(%rbp), %rdi
leaq -0x1f8(%rbp), %rdx
callq 0xb700
jmp 0x5c71
leaq -0x230(%rbp), %rdi
movq %rdi, -0x390(%rbp)
leaq -0xa8(%rbp), %rsi
movq %rsi, -0x380(%rbp)
leaq -0xc0(%rbp), %rdx
callq 0xb7b0
movq -0x390(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
movq %rsi, -0x388(%rbp)
callq 0xb7f0
movq -0x388(%rbp), %rdi
callq 0xb830
leaq -0x1f8(%rbp), %rdi
callq 0xa9a0
leaq -0x219(%rbp), %rdi
callq 0xaa00
movq -0x380(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xabe0
movb %al, -0x371(%rbp)
jmp 0x5cef
movb -0x371(%rbp), %al
testb $0x1, %al
jne 0x5cfb
jmp 0x5cfd
jmp 0x5d70
leaq 0x18a9a(%rip), %rdi     # 0x1e79e
leaq 0x18570(%rip), %rsi     # 0x1e27b
movl $0xe8, %edx
leaq 0x18a9a(%rip), %rcx     # 0x1e7b1
callq 0x2110
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1a9(%rbp), %rdi
callq 0xaa00
jmp 0x60a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x5d5f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x1f8(%rbp), %rdi
callq 0xa9a0
leaq -0x219(%rbp), %rdi
callq 0xaa00
jmp 0x60a4
leaq -0xc0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xabe0
movb %al, -0x391(%rbp)
jmp 0x5d88
movb -0x391(%rbp), %al
testb $0x1, %al
jne 0x5d94
jmp 0x5d96
jmp 0x5db5
leaq 0x18a28(%rip), %rdi     # 0x1e7c5
leaq 0x184d7(%rip), %rsi     # 0x1e27b
movl $0xe9, %edx
leaq 0x18a01(%rip), %rcx     # 0x1e7b1
callq 0x2110
movl $0x1, -0x268(%rbp)
movl $0x2, -0x264(%rbp)
movl $0x3, -0x260(%rbp)
movl $0x4, -0x25c(%rbp)
leaq -0x268(%rbp), %rax
movq %rax, -0x258(%rbp)
movq $0x4, -0x250(%rbp)
leaq -0x269(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0xa900
movq -0x3a0(%rbp), %rcx
movq -0x258(%rbp), %rsi
movq -0x250(%rbp), %rdx
leaq -0x248(%rbp), %rdi
callq 0xa920
jmp 0x5e2c
leaq -0x18(%rbp), %rdi
leaq -0x248(%rbp), %rsi
movq %rsi, -0x3b8(%rbp)
callq 0xb600
movq -0x3b8(%rbp), %rdi
callq 0xa9a0
leaq -0x269(%rbp), %rdi
callq 0xaa00
xorps %xmm0, %xmm0
movaps %xmm0, -0x290(%rbp)
movq $0x0, -0x280(%rbp)
leaq -0x290(%rbp), %rdi
movq %rdi, -0x3b0(%rbp)
callq 0xaf60
movq -0x3b0(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0xb600
movq -0x3b0(%rbp), %rdi
callq 0xa9a0
movl $0x1, -0x2f8(%rbp)
movl $0x2, -0x2f4(%rbp)
movl $0x3, -0x2f0(%rbp)
movl $0x4, -0x2ec(%rbp)
leaq -0x2f8(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movq $0x4, -0x2e0(%rbp)
leaq -0x2f9(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0xa900
movq -0x3a8(%rbp), %rcx
movq -0x2e8(%rbp), %rsi
movq -0x2e0(%rbp), %rdx
leaq -0x2d8(%rbp), %rdi
callq 0xa920
jmp 0x5f16
leaq -0x2c0(%rbp), %rdi
movl $0xa, %esi
leaq -0x2d8(%rbp), %rdx
callq 0xb700
jmp 0x5f30
leaq -0x310(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
leaq -0xa8(%rbp), %rsi
movq %rsi, -0x3c8(%rbp)
leaq -0xc0(%rbp), %rdx
callq 0xb7b0
movq -0x3d8(%rbp), %rdi
leaq -0x2c0(%rbp), %rsi
movq %rsi, -0x3d0(%rbp)
callq 0xb7f0
movq -0x3d0(%rbp), %rdi
callq 0xb830
leaq -0x2d8(%rbp), %rdi
callq 0xa9a0
leaq -0x2f9(%rbp), %rdi
callq 0xaa00
movq -0x3c8(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xabe0
movb %al, -0x3b9(%rbp)
jmp 0x5fae
movb -0x3b9(%rbp), %al
testb $0x1, %al
jne 0x5fba
jmp 0x5fbc
jmp 0x602c
leaq 0x187db(%rip), %rdi     # 0x1e79e
leaq 0x182b1(%rip), %rsi     # 0x1e27b
movl $0xee, %edx
leaq 0x187db(%rip), %rcx     # 0x1e7b1
callq 0x2110
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x269(%rbp), %rdi
callq 0xaa00
jmp 0x60a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x601e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0xa9a0
leaq -0x2f9(%rbp), %rdi
callq 0xaa00
jmp 0x60a4
leaq -0xc0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0xabe0
movb %al, -0x3d9(%rbp)
jmp 0x6044
movb -0x3d9(%rbp), %al
testb $0x1, %al
jne 0x6050
jmp 0x6052
jmp 0x6071
leaq 0x1876c(%rip), %rdi     # 0x1e7c5
leaq 0x1821b(%rip), %rsi     # 0x1e27b
movl $0xef, %edx
leaq 0x18745(%rip), %rcx     # 0x1e7b1
callq 0x2110
leaq -0xc0(%rbp), %rdi
callq 0xa9a0
leaq -0xa8(%rbp), %rdi
callq 0xa9a0
leaq -0x68(%rbp), %rdi
callq 0xa9a0
leaq -0x18(%rbp), %rdi
callq 0xa9a0
addq $0x3e0, %rsp            # imm = 0x3E0
popq %rbp
retq
leaq -0xc0(%rbp), %rdi
callq 0xa9a0
leaq -0xa8(%rbp), %rdi
callq 0xa9a0
leaq -0x68(%rbp), %rdi
callq 0xa9a0
leaq -0x18(%rbp), %rdi
callq 0xa9a0
movq -0x48(%rbp), %rdi
callq 0x22b0
nopw (%rax,%rax)