#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int *, int);
void test_arr() {
  int a[] = {
      [1] = 2,
      4,
      [5] = 6,
  };
  for (int i = 0, len = sizeof(a) / sizeof(int); i < len; i++) {
    printf("&a[%d]=%p %d\n", i, &a[i], a[i]);
  }
}


x86 assembly (clang, -O0):
<test_arr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x6,-0x28(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    1187 <test_arr+0x77>
mov    -0x24(%rbp),%esi
movslq -0x24(%rbp),%rax
lea    -0x20(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <test_arr+0x37>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_arr>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0xef2(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%r14
lea    0xede(%rip),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %ecx,%ecx
call   1030 <printf@plt>
lea    0x4(%rsp),%rdx
mov    0x4(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
lea    0x8(%rsp),%rdx
mov    0x8(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
lea    0xc(%rsp),%rdx
mov    0xc(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <printf@plt>
mov    0x10(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r14,%rdx
call   1030 <printf@plt>
lea    0x14(%rsp),%rdx
mov    0x14(%rsp),%ecx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_arr.a = [6 x i32] [i32 0, i32 2, i32 4, i32 0, i32 0, i32 6]
@.str = [14 x i8] c"&a[%d]=%p %d\0A\00"
define void @test_arr() {
%1 = alloca [6 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = bitcast [6 x i32]* %1 to i8*
store i32 0, i32* %2
store i32 6, i32* %3
br label %5
5: ; preds = %19, %0
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 %12
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %10, i32* %13, i32 %17)
br label %19
19: ; preds = %9
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %5
22: ; preds = %5
ret void
}

LLVM IR (-O2):
@__const.test_arr.a = [6 x i32] [i32 0, i32 2, i32 4, i32 0, i32 0, i32 6]
@.str = [14 x i8] c"&a[%d]=%p %d\0A\00"
define void @test_arr() {
%1 = alloca [6 x i32]
%2 = bitcast [6 x i32]* %1 to i8*
%3 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 0
%4 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0, i32* %3, i32 0)
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 1
%6 = load i32, i32* %5
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 1, i32* %5, i32 %6)
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 2
%9 = load i32, i32* %8
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 2, i32* %8, i32 %9)
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 3
%12 = load i32, i32* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 3, i32* %11, i32 %12)
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 4
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 4, i32* %14, i32 %15)
%17 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 5
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 5, i32* %17, i32 %18)
ret void
}