void Array1() {
  int a[] = {1, 2, 3, 4};
  int *p = a;
  printf("%d, %d\n", a, p);
  printf("%d, %d, %d, %d\n", a[2], *(a + 2), *(2 + a), 2 [a]);
  printf("%d, %d\n", sizeof(a), sizeof(p));
}


x86 assembly (clang, -O0):
<Array1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x8(%rbp),%r8d
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    $0x10,%esi
mov    $0x8,%edx
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Array1>:
push   %rbx
sub    $0x10,%rsp
movaps 0xee4(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xef1(%rip),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %rdx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%ecx
lea    0xece(%rip),%rdi
mov    %ecx,%esi
mov    %ecx,%edx
mov    %ecx,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x10,%esi
mov    $0x8,%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.Array1.a = [4 x i32] [i32 1, i32 2, i32 3, i32 4]
@.str = [8 x i8] c"%d, %d\0A\00"
@.str.1 = [16 x i8] c"%d, %d, %d, %d\0A\00"
define void @Array1() {
%1 = alloca [4 x i32]
%2 = bitcast [4 x i32]* %1 to i8*
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %3, i32* %3)
%5 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 2
%6 = load i32, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %6, i32 %6, i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 16, i64 8)
ret void
}