// File: dsharlet[P]array/test/array_ref.cpp
// Function: nda::test_array_ref_indices_body()
TEST(array_ref_indices) {
  int data[100];
  for (int i = 0; i < 100; i++) {
    data[i] = i;
  }

  dense_array_ref<int, 1> ref_1d(data, {100});
  for_all_indices(ref_1d.shape(), [&](int x) { ASSERT_EQ(ref_1d(x), x); });

  dense_array_ref<int, 2> ref_2d(data, {20, 5});
  ASSERT_EQ(ref_2d.width(), 20);
  ASSERT_EQ(ref_2d.height(), 5);
  ASSERT_EQ(ref_2d.rows(), 20);
  ASSERT_EQ(ref_2d.columns(), 5);
  for_all_indices(ref_2d.shape(), [&](int x, int y) { ASSERT_EQ(ref_2d(x, y), y * 20 + x); });
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb00, %rsp            # imm = 0xB00
movl $0x0, -0x194(%rbp)
cmpl $0x64, -0x194(%rbp)
jge 0x8c7e3
movl -0x194(%rbp), %ecx
movslq -0x194(%rbp), %rax
movl %ecx, -0x190(%rbp,%rax,4)
movl -0x194(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x194(%rbp)
jmp 0x8c7b5
leaq -0x1d0(%rbp), %rdi
movq %rdi, -0x9b0(%rbp)
movl $0x64, %esi
callq 0x34210
movq -0x9b0(%rbp), %rdx
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x9a8(%rbp)
leaq -0x190(%rbp), %rsi
movq %rsi, -0x9a0(%rbp)
callq 0x968a0
movq -0x9a8(%rbp), %rdi
callq 0x968f0
movq %rax, %rdi
movq -0x9a8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x1d8(%rbp), %rsi
callq 0x8d130
leaq -0x240(%rbp), %rdi
movq %rdi, -0x998(%rbp)
movl $0x14, %esi
movl $0x5, %edx
callq 0x343e0
movq -0x9a0(%rbp), %rsi
movq -0x998(%rbp), %rdx
leaq -0x210(%rbp), %rdi
movq %rdi, -0x990(%rbp)
callq 0x96910
movq -0x990(%rbp), %rdi
callq 0x96960
subq $0x14, %rax
sete %al
movb %al, -0x981(%rbp)
leaq -0x3f1(%rbp), %rdi
movq %rdi, -0x980(%rbp)
callq 0x33b0
movq -0x980(%rbp), %rdx
leaq 0x15afd4(%rip), %rsi    # 0x1e7898
leaq -0x3f0(%rbp), %rdi
callq 0x10a90
jmp 0x8c8d2
movb -0x981(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x3d0(%rbp), %rdi
leaq -0x3f0(%rbp), %rdx
callq 0x10f80
jmp 0x8c8f3
leaq 0x14feeb(%rip), %rsi    # 0x1dc7e5
leaq -0x3d0(%rbp), %rdi
callq 0x34320
movq %rax, -0x9b8(%rbp)
jmp 0x8c90f
movq -0x9b8(%rbp), %rdi
leaq 0x15af90(%rip), %rsi    # 0x1e78ad
callq 0x36fb0
movq %rax, -0x9c0(%rbp)
jmp 0x8c92b
movq -0x9c0(%rbp), %rdi
leaq 0x153e73(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x9c8(%rbp)
jmp 0x8c947
leaq -0x210(%rbp), %rdi
callq 0x96960
movq %rax, -0x9d0(%rbp)
jmp 0x8c95c
movq -0x9c8(%rbp), %rdi
movq -0x9d0(%rbp), %rax
movq %rax, -0x410(%rbp)
leaq -0x410(%rbp), %rsi
callq 0x34510
movq %rax, -0x9d8(%rbp)
jmp 0x8c986
movq -0x9d8(%rbp), %rdi
leaq 0x14fe51(%rip), %rsi    # 0x1dc7e5
callq 0x34320
movq %rax, -0x9e0(%rbp)
jmp 0x8c9a2
movq -0x9e0(%rbp), %rdi
leaq 0x151dd8(%rip), %rsi    # 0x1de788
callq 0x34840
movq %rax, -0x9e8(%rbp)
jmp 0x8c9be
movq -0x9e8(%rbp), %rdi
leaq 0x153de0(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0x9f0(%rbp)
jmp 0x8c9da
movq -0x9f0(%rbp), %rdi
movl $0x14, -0x414(%rbp)
leaq -0x414(%rbp), %rsi
callq 0x343a0
movq %rax, -0x9f8(%rbp)
jmp 0x8ca00
movq -0x9f8(%rbp), %rdi
leaq 0x169a6d(%rip), %rsi    # 0x1f647b
callq 0x34320
jmp 0x8ca15
leaq -0x3d0(%rbp), %rdi
callq 0x10ff0
jmp 0x8ca23
leaq -0x3f0(%rbp), %rdi
callq 0x3100
leaq -0x3f1(%rbp), %rdi
callq 0x3290
leaq -0x210(%rbp), %rdi
callq 0x96980
subq $0x5, %rax
sete %al
movb %al, -0xa01(%rbp)
leaq -0x5c9(%rbp), %rdi
movq %rdi, -0xa00(%rbp)
callq 0x33b0
movq -0xa00(%rbp), %rdx
leaq 0x15ae47(%rip), %rsi    # 0x1e78bc
leaq -0x5c8(%rbp), %rdi
callq 0x10a90
jmp 0x8ca83
movb -0xa01(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x5a8(%rbp), %rdi
leaq -0x5c8(%rbp), %rdx
callq 0x10f80
jmp 0x8caa4
leaq 0x14fd3a(%rip), %rsi    # 0x1dc7e5
leaq -0x5a8(%rbp), %rdi
callq 0x34320
movq %rax, -0xa10(%rbp)
jmp 0x8cac0
movq -0xa10(%rbp), %rdi
leaq 0x15ae03(%rip), %rsi    # 0x1e78d1
callq 0x969a0
movq %rax, -0xa18(%rbp)
jmp 0x8cadc
movq -0xa18(%rbp), %rdi
leaq 0x153cc2(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0xa20(%rbp)
jmp 0x8caf8
leaq -0x210(%rbp), %rdi
callq 0x96980
movq %rax, -0xa28(%rbp)
jmp 0x8cb0d
movq -0xa20(%rbp), %rdi
movq -0xa28(%rbp), %rax
movq %rax, -0x5d8(%rbp)
leaq -0x5d8(%rbp), %rsi
callq 0x34510
movq %rax, -0xa30(%rbp)
jmp 0x8cb37
movq -0xa30(%rbp), %rdi
leaq 0x14fca0(%rip), %rsi    # 0x1dc7e5
callq 0x34320
movq %rax, -0xa38(%rbp)
jmp 0x8cb53
movq -0xa38(%rbp), %rdi
leaq 0x151bfc(%rip), %rsi    # 0x1de75d
callq 0x34320
movq %rax, -0xa40(%rbp)
jmp 0x8cb6f
movq -0xa40(%rbp), %rdi
leaq 0x153c2f(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0xa48(%rbp)
jmp 0x8cb8b
movq -0xa48(%rbp), %rdi
movl $0x5, -0x5dc(%rbp)
leaq -0x5dc(%rbp), %rsi
callq 0x343a0
movq %rax, -0xa50(%rbp)
jmp 0x8cbb1
movq -0xa50(%rbp), %rdi
leaq 0x1698bc(%rip), %rsi    # 0x1f647b
callq 0x34320
jmp 0x8cbc6
leaq -0x5a8(%rbp), %rdi
callq 0x10ff0
jmp 0x8cbd4
leaq -0x5c8(%rbp), %rdi
callq 0x3100
leaq -0x5c9(%rbp), %rdi
callq 0x3290
leaq -0x210(%rbp), %rdi
callq 0x969e0
subq $0x14, %rax
sete %al
movb %al, -0xa59(%rbp)
leaq -0x791(%rbp), %rdi
movq %rdi, -0xa58(%rbp)
callq 0x33b0
movq -0xa58(%rbp), %rdx
leaq 0x15acbb(%rip), %rsi    # 0x1e78e1
leaq -0x790(%rbp), %rdi
callq 0x10a90
jmp 0x8cc34
movb -0xa59(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x770(%rbp), %rdi
leaq -0x790(%rbp), %rdx
callq 0x10f80
jmp 0x8cc55
leaq 0x14fb89(%rip), %rsi    # 0x1dc7e5
leaq -0x770(%rbp), %rdi
callq 0x34320
movq %rax, -0xa68(%rbp)
jmp 0x8cc71
movq -0xa68(%rbp), %rdi
leaq 0x15ac76(%rip), %rsi    # 0x1e78f5
callq 0x347a0
movq %rax, -0xa70(%rbp)
jmp 0x8cc8d
movq -0xa70(%rbp), %rdi
leaq 0x153b11(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0xa78(%rbp)
jmp 0x8cca9
leaq -0x210(%rbp), %rdi
callq 0x969e0
movq %rax, -0xa80(%rbp)
jmp 0x8ccbe
movq -0xa78(%rbp), %rdi
movq -0xa80(%rbp), %rax
movq %rax, -0x7a0(%rbp)
leaq -0x7a0(%rbp), %rsi
callq 0x34510
movq %rax, -0xa88(%rbp)
jmp 0x8cce8
movq -0xa88(%rbp), %rdi
leaq 0x14faef(%rip), %rsi    # 0x1dc7e5
callq 0x34320
movq %rax, -0xa90(%rbp)
jmp 0x8cd04
movq -0xa90(%rbp), %rdi
leaq 0x151a76(%rip), %rsi    # 0x1de788
callq 0x34840
movq %rax, -0xa98(%rbp)
jmp 0x8cd20
movq -0xa98(%rbp), %rdi
leaq 0x153a7e(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0xaa0(%rbp)
jmp 0x8cd3c
movq -0xaa0(%rbp), %rdi
movl $0x14, -0x7a4(%rbp)
leaq -0x7a4(%rbp), %rsi
callq 0x343a0
movq %rax, -0xaa8(%rbp)
jmp 0x8cd62
movq -0xaa8(%rbp), %rdi
leaq 0x16970b(%rip), %rsi    # 0x1f647b
callq 0x34320
jmp 0x8cd77
leaq -0x770(%rbp), %rdi
callq 0x10ff0
jmp 0x8cd85
leaq -0x790(%rbp), %rdi
callq 0x3100
leaq -0x791(%rbp), %rdi
callq 0x3290
leaq -0x210(%rbp), %rdi
callq 0x96a00
subq $0x5, %rax
sete %al
movb %al, -0xab1(%rbp)
leaq -0x959(%rbp), %rdi
movq %rdi, -0xab0(%rbp)
callq 0x33b0
movq -0xab0(%rbp), %rdx
leaq 0x15ab2c(%rip), %rsi    # 0x1e7903
leaq -0x958(%rbp), %rdi
callq 0x10a90
jmp 0x8cde5
movb -0xab1(%rbp), %al
movzbl %al, %esi
andl $0x1, %esi
leaq -0x938(%rbp), %rdi
leaq -0x958(%rbp), %rdx
callq 0x10f80
jmp 0x8ce06
leaq 0x14f9d8(%rip), %rsi    # 0x1dc7e5
leaq -0x938(%rbp), %rdi
callq 0x34320
movq %rax, -0xac0(%rbp)
jmp 0x8ce22
movq -0xac0(%rbp), %rdi
leaq 0x15aae9(%rip), %rsi    # 0x1e7919
callq 0x34800
movq %rax, -0xac8(%rbp)
jmp 0x8ce3e
movq -0xac8(%rbp), %rdi
leaq 0x153960(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0xad0(%rbp)
jmp 0x8ce5a
leaq -0x210(%rbp), %rdi
callq 0x96a00
movq %rax, -0xad8(%rbp)
jmp 0x8ce6f
movq -0xad0(%rbp), %rdi
movq -0xad8(%rbp), %rax
movq %rax, -0x968(%rbp)
leaq -0x968(%rbp), %rsi
callq 0x34510
movq %rax, -0xae0(%rbp)
jmp 0x8ce99
movq -0xae0(%rbp), %rdi
leaq 0x14f93e(%rip), %rsi    # 0x1dc7e5
callq 0x34320
movq %rax, -0xae8(%rbp)
jmp 0x8ceb5
movq -0xae8(%rbp), %rdi
leaq 0x15189a(%rip), %rsi    # 0x1de75d
callq 0x34320
movq %rax, -0xaf0(%rbp)
jmp 0x8ced1
movq -0xaf0(%rbp), %rdi
leaq 0x1538cd(%rip), %rsi    # 0x1e07ac
callq 0x34320
movq %rax, -0xaf8(%rbp)
jmp 0x8ceed
movq -0xaf8(%rbp), %rdi
movl $0x5, -0x96c(%rbp)
leaq -0x96c(%rbp), %rsi
callq 0x343a0
movq %rax, -0xb00(%rbp)
jmp 0x8cf13
movq -0xb00(%rbp), %rdi
leaq 0x16955a(%rip), %rsi    # 0x1f647b
callq 0x34320
jmp 0x8cf28
leaq -0x938(%rbp), %rdi
callq 0x10ff0
jmp 0x8cf36
leaq -0x958(%rbp), %rdi
callq 0x3100
leaq -0x959(%rbp), %rdi
callq 0x3290
leaq -0x210(%rbp), %rdi
callq 0x96a20
movq %rax, %rdi
leaq -0x210(%rbp), %rax
movq %rax, -0x978(%rbp)
leaq -0x978(%rbp), %rsi
callq 0x8d160
addq $0xb00, %rsp            # imm = 0xB00
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x8cfd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x8cfca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
leaq -0x3d0(%rbp), %rdi
callq 0x10ff0
jmp 0x8cfc8
jmp 0x8cfca
leaq -0x3f0(%rbp), %rdi
callq 0x3100
leaq -0x3f1(%rbp), %rdi
callq 0x3290
jmp 0x8d114
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x8d03d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x8d031
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
leaq -0x5a8(%rbp), %rdi
callq 0x10ff0
jmp 0x8d02f
jmp 0x8d031
leaq -0x5c8(%rbp), %rdi
callq 0x3100
leaq -0x5c9(%rbp), %rdi
callq 0x3290
jmp 0x8d114
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x8d0a4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x8d098
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
leaq -0x770(%rbp), %rdi
callq 0x10ff0
jmp 0x8d096
jmp 0x8d098
leaq -0x790(%rbp), %rdi
callq 0x3100
leaq -0x791(%rbp), %rdi
callq 0x3290
jmp 0x8d114
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x8d108
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
jmp 0x8d0fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x400(%rbp)
movl %eax, -0x404(%rbp)
leaq -0x938(%rbp), %rdi
callq 0x10ff0
jmp 0x8d0fa
jmp 0x8d0fc
leaq -0x958(%rbp), %rdi
callq 0x3100
leaq -0x959(%rbp), %rdi
callq 0x3290
movq -0x400(%rbp), %rdi
callq 0x33a0
movq %rax, %rdi
callq 0x116d0
nopl (%rax,%rax)