// File: ef-gy[P]libefgy/src/test-case/range.cpp
// Function: testRange(std::ostream&)
bool testRange(std::ostream &log) {
  std::array<int, 5> a5{0, 1, 2, 3, 4};
  std::array<int, 5> b5{1000, 1001, 1002, 1003, 1004};
  std::array<int, 8> a8n{49, 48, 47, 46, 45, 44, 43, 42};

  for (int i : range<int>(0, 4)) {
    std::cerr << i << "\n";
  }

  std::array<int, 8> a1{42, 43, 44, 45, 46, 47, 48, 49};
  std::size_t p = 0;

  for (int i : range<int, 8>(42)) {
    if (i != a1[p]) {
      log << "range<int, 8>(42) did not produce the expected results.\n";
      return false;
    }

    p++;
  }

  if (!std::equal(a1.begin(), a1.end(), range<int, 8>(42).begin())) {
    log << "range iterator did not produce the expected results.\n";
    return false;
  }

  std::array<int, 8> a2{49, 48, 47, 46, 45, 44, 43, 42};

  if (!std::equal(a2.begin(), a2.end(), range<int, 8>(49, 42).begin())) {
    log << "range iterator did not produce the expected results.\n";
    return false;
  }

  if (!std::equal(a2.begin(), a2.end(), range<int>(49, 42, 8, true).begin())) {
    log << "range iterator did not produce the expected results.\n";
    return false;
  }

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x10(%rbp)
movq 0x2e56e(%rip), %rax     # 0x34124
movq %rax, -0x24(%rbp)
movq 0x2e56b(%rip), %rax     # 0x3412c
movq %rax, -0x1c(%rbp)
movl 0x2e569(%rip), %eax     # 0x34134
movl %eax, -0x14(%rbp)
movq 0x2e563(%rip), %rax     # 0x34138
movq %rax, -0x38(%rbp)
movq 0x2e560(%rip), %rax     # 0x34140
movq %rax, -0x30(%rbp)
movl 0x2e55e(%rip), %eax     # 0x34148
movl %eax, -0x28(%rbp)
movq 0x2f010(%rip), %rax     # 0x34c04
movq %rax, -0x58(%rbp)
movq 0x2f00d(%rip), %rax     # 0x34c0c
movq %rax, -0x50(%rbp)
movq 0x2f00a(%rip), %rax     # 0x34c14
movq %rax, -0x48(%rbp)
movq 0x2f007(%rip), %rax     # 0x34c1c
movq %rax, -0x40(%rbp)
movl $0x0, -0x74(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x74(%rbp), %rsi
movl $0x1, %edx
callq 0x6850
leaq -0x70(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x68b0
movq %rax, -0x88(%rbp)
movq %rdx, -0x80(%rbp)
movq -0x60(%rbp), %rdi
callq 0x68f0
movq %rax, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x6930
testb $0x1, %al
jne 0x5c7e
jmp 0x5cbf
leaq -0x88(%rbp), %rdi
callq 0x6990
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %esi
movq 0x4834b(%rip), %rdi     # 0x4dfe8
callq 0x5580
movq %rax, %rdi
leaq 0x2e5f6(%rip), %rsi     # 0x342a2
callq 0x5350
leaq -0x88(%rbp), %rdi
callq 0x69b0
jmp 0x5c65
movq 0x2ef5e(%rip), %rax     # 0x34c24
movq %rax, -0xbc(%rbp)
movq 0x2ef58(%rip), %rax     # 0x34c2c
movq %rax, -0xb4(%rbp)
movq 0x2ef52(%rip), %rax     # 0x34c34
movq %rax, -0xac(%rbp)
movq 0x2ef4c(%rip), %rax     # 0x34c3c
movq %rax, -0xa4(%rbp)
movq $0x0, -0xc8(%rbp)
movl $0x2a, -0xdc(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xdc(%rbp), %rsi
callq 0x69d0
leaq -0xd8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x6a00
movq %rax, -0xf0(%rbp)
movq %rdx, -0xe8(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x6a40
movq %rax, -0x100(%rbp)
movq %rdx, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0x6930
testb $0x1, %al
jne 0x5d7a
jmp 0x5df4
leaq -0xf0(%rbp), %rdi
callq 0x6990
movl %eax, -0x104(%rbp)
movl -0x104(%rbp), %eax
movl %eax, -0x194(%rbp)
movq -0xc8(%rbp), %rsi
leaq -0xbc(%rbp), %rdi
callq 0x6a80
movq %rax, %rcx
movl -0x194(%rbp), %eax
cmpl (%rcx), %eax
je 0x5dd1
movq -0x10(%rbp), %rdi
leaq 0x2e42b(%rip), %rsi     # 0x341ee
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x603c
movq -0xc8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xc8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x69b0
jmp 0x5d61
leaq -0xbc(%rbp), %rdi
callq 0x6b00
movq %rax, -0x1a8(%rbp)
leaq -0xbc(%rbp), %rdi
callq 0x6b20
movq %rax, -0x1a0(%rbp)
movl $0x2a, -0x124(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x124(%rbp), %rsi
callq 0x69d0
leaq -0x120(%rbp), %rdi
callq 0x6a00
movq -0x1a8(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
movq %rax, -0x118(%rbp)
movq %rdx, -0x110(%rbp)
movq -0x118(%rbp), %rdx
movq -0x110(%rbp), %rcx
callq 0x6ab0
xorb $-0x1, %al
testb $0x1, %al
jne 0x5e7a
jmp 0x5e93
movq -0x10(%rbp), %rdi
leaq 0x2e3a2(%rip), %rsi     # 0x34227
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x603c
movq 0x2ed6a(%rip), %rax     # 0x34c04
movq %rax, -0x144(%rbp)
movq 0x2ed64(%rip), %rax     # 0x34c0c
movq %rax, -0x13c(%rbp)
movq 0x2ed5e(%rip), %rax     # 0x34c14
movq %rax, -0x134(%rbp)
movq 0x2ed58(%rip), %rax     # 0x34c1c
movq %rax, -0x12c(%rbp)
leaq -0x144(%rbp), %rdi
callq 0x6b00
movq %rax, -0x1b8(%rbp)
leaq -0x144(%rbp), %rdi
callq 0x6b20
movq %rax, -0x1b0(%rbp)
movl $0x31, -0x164(%rbp)
movl $0x2a, -0x168(%rbp)
leaq -0x160(%rbp), %rdi
leaq -0x164(%rbp), %rsi
leaq -0x168(%rbp), %rdx
movl $0x1, %ecx
callq 0x6b40
leaq -0x160(%rbp), %rdi
callq 0x6a00
movq -0x1b8(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
movq %rax, -0x158(%rbp)
movq %rdx, -0x150(%rbp)
movq -0x158(%rbp), %rdx
movq -0x150(%rbp), %rcx
callq 0x6ab0
xorb $-0x1, %al
testb $0x1, %al
jne 0x5f67
jmp 0x5f80
movq -0x10(%rbp), %rdi
leaq 0x2e2b5(%rip), %rsi     # 0x34227
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x603c
leaq -0x144(%rbp), %rdi
callq 0x6b00
movq %rax, -0x1c8(%rbp)
leaq -0x144(%rbp), %rdi
callq 0x6b20
movq %rax, -0x1c0(%rbp)
movl $0x31, -0x18c(%rbp)
movl $0x2a, -0x190(%rbp)
leaq -0x188(%rbp), %rdi
leaq -0x18c(%rbp), %rsi
leaq -0x190(%rbp), %rdx
movl $0x8, %ecx
movl $0x1, %r8d
callq 0x6ba0
leaq -0x188(%rbp), %rdi
callq 0x68b0
movq -0x1c8(%rbp), %rdi
movq -0x1c0(%rbp), %rsi
movq %rax, -0x178(%rbp)
movq %rdx, -0x170(%rbp)
movq -0x178(%rbp), %rdx
movq -0x170(%rbp), %rcx
callq 0x6ab0
xorb $-0x1, %al
testb $0x1, %al
jne 0x6022
jmp 0x6038
movq -0x10(%rbp), %rdi
leaq 0x2e1fa(%rip), %rsi     # 0x34227
callq 0x5350
movb $0x0, -0x1(%rbp)
jmp 0x603c
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
nopw (%rax,%rax)