void nested_vectors_with_constant_indices() {
  int vec[3] = {1, 2, 3};
  int vec_in_vec[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
  int vec_in_vec2[3][3][2] = {{{1, 2}, {3, 4}, {5, 6}},
                              {{7, 8}, {9, 10}, {11, 12}},
                              {{13, 14}, {15, 16}, {17, 18}}};
  printf("%d\n", vec[1]);
  printf("%d\n", 1 [vec]);
  printf("%d\n", vec_in_vec[1][2]);
  printf("%d\n", 1 [vec_in_vec[2]]);
  printf("%d\n", 1 [2 [vec_in_vec]]);
  printf("%d\n", 2 [vec_in_vec][1]);
  printf("%d\n", vec_in_vec2[1][2][3]);
  printf("%d\n", 3 [vec_in_vec2[1][2]]);
  printf("%d\n", 3 [2 [vec_in_vec2[1]]]);
  printf("%d\n", 3 [2 [1 [vec_in_vec2]]]);
}


x86 assembly (clang, -O0):
<nested_vectors_with_constant_indices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    0xece(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xecc(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
lea    -0x80(%rbp),%rdi
lea    0xee1(%rip),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%esi
lea    0xf15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xf04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xef3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4c(%rbp),%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nested_vectors_with_constant_indices>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.nested_vectors_with_constant_indices.vec = [3 x i32] [i32 1, i32 2, i32 3]
@__const.nested_vectors_with_constant_indices.vec_in_vec = [3 x [3 x i32]] [[3 x i32] [i32 1, i32 2, i32 3], [3 x i32] [i32 4, i32 5, i32 6], [3 x i32] [i32 7, i32 8, i32 9]]
@__const.nested_vectors_with_constant_indices.vec_in_vec2 = [3 x [3 x [2 x i32]]] [[3 x [2 x i32]] [[2 x i32] [i32 1, i32 2], [2 x i32] [i32 3, i32 4], [2 x i32] [i32 5, i32 6]], [3 x [2 x i32]] [[2 x i32] [i32 7, i32 8], [2 x i32] [i32 9, i32 10], [2 x i32] [i32 11, i32 12]], [3 x [2 x i32]] [[2 x i32] [i32 13, i32 14], [2 x i32] [i32 15, i32 16], [2 x i32] [i32 17, i32 18]]]
@.str = [4 x i8] c"%d\0A\00"
define void @nested_vectors_with_constant_indices() {
%1 = alloca [3 x i32]
%2 = alloca [3 x [3 x i32]]
%3 = alloca [3 x [3 x [2 x i32]]]
%4 = bitcast [3 x i32]* %1 to i8*
%5 = bitcast [3 x [3 x i32]]* %2 to i8*
%6 = bitcast [3 x [3 x [2 x i32]]]* %3 to i8*
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%8 = load i32, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%11 = load i32, i32* %10
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 1
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %13, i64 0, i64 2
%15 = load i32, i32* %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 2
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %17, i64 0, i64 1
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 2
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %21, i64 0, i64 1
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [3 x [3 x i32]], [3 x [3 x i32]]* %2, i64 0, i64 2
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %25, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [3 x [3 x [2 x i32]]], [3 x [3 x [2 x i32]]]* %3, i64 0, i64 1
%30 = getelementptr inbounds [3 x [2 x i32]], [3 x [2 x i32]]* %29, i64 0, i64 2
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %30, i64 0, i64 3
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [3 x [3 x [2 x i32]]], [3 x [3 x [2 x i32]]]* %3, i64 0, i64 1
%35 = getelementptr inbounds [3 x [2 x i32]], [3 x [2 x i32]]* %34, i64 0, i64 2
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %35, i64 0, i64 3
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %37)
%39 = getelementptr inbounds [3 x [3 x [2 x i32]]], [3 x [3 x [2 x i32]]]* %3, i64 0, i64 1
%40 = getelementptr inbounds [3 x [2 x i32]], [3 x [2 x i32]]* %39, i64 0, i64 2
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %40, i64 0, i64 3
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds [3 x [3 x [2 x i32]]], [3 x [3 x [2 x i32]]]* %3, i64 0, i64 1
%45 = getelementptr inbounds [3 x [2 x i32]], [3 x [2 x i32]]* %44, i64 0, i64 2
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %45, i64 0, i64 3
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %47)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @nested_vectors_with_constant_indices() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 2)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 6)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 8)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 14)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 14)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 14)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 14)
ret void
}