void array_test() {
  int arr[] = {1, 2, 3};
  print_i(arr);
  print_i(&arr);
  print_i(*arr);
  int *p;
  p = &arr;
  print_i(p);
  print_i(*p);
  print_i(p + 1);
  print_i(*(p + 1));
  print_i(p[2]);
  int *q = arr;
  print_i(q);
  print_i(*q);
  int *w = &arr;
  print_i(w);
  print_i(*w);
}


x86 assembly (clang, -O0):
<array_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x0,%al
call   1030 <print_i@plt>
lea    -0xc(%rbp),%rdi
mov    $0x0,%al
call   1030 <print_i@plt>
mov    -0xc(%rbp),%edi
mov    $0x0,%al
call   1030 <print_i@plt>
lea    -0xc(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1030 <print_i@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <print_i@plt>
mov    -0x18(%rbp),%rdi
add    $0x4,%rdi
mov    $0x0,%al
call   1030 <print_i@plt>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edi
mov    $0x0,%al
call   1030 <print_i@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edi
mov    $0x0,%al
call   1030 <print_i@plt>
lea    -0xc(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1030 <print_i@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <print_i@plt>
lea    -0xc(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x0,%al
call   1030 <print_i@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
mov    $0x0,%al
call   1030 <print_i@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_test>:
push   %rbx
sub    $0x10,%rsp
mov    0xeed(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xeda(%rip),%rax
mov    %rax,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    (%rsp),%edi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    (%rsp),%edi
xor    %eax,%eax
call   1030 <print_i@plt>
lea    0x4(%rsp),%rdi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    0x4(%rsp),%edi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    0x8(%rsp),%edi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    (%rsp),%edi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <print_i@plt>
mov    (%rsp),%edi
xor    %eax,%eax
call   1030 <print_i@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.array_test.arr = [3 x i32] [i32 1, i32 2, i32 3]
define void @array_test() {
%1 = alloca [3 x i32]
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = bitcast [3 x i32]* %1 to i8*
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%7 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %6)
%8 = call i32 ([3 x i32]*, ...) bitcast (i32 (...)* @print_i to i32 ([3 x i32]*, ...)*)([3 x i32]* %1)
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%10 = load i32, i32* %9
%11 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %10)
%12 = bitcast [3 x i32]* %1 to i32*
store i32* %12, i32** %2
%13 = load i32*, i32** %2
%14 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %13)
%15 = load i32*, i32** %2
%16 = load i32, i32* %15
%17 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %16)
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 1
%20 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %19)
%21 = load i32*, i32** %2
%22 = getelementptr inbounds i32, i32* %21, i64 1
%23 = load i32, i32* %22
%24 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %23)
%25 = load i32*, i32** %2
%26 = getelementptr inbounds i32, i32* %25, i64 2
%27 = load i32, i32* %26
%28 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %27)
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
store i32* %29, i32** %3
%30 = load i32*, i32** %3
%31 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %30)
%32 = load i32*, i32** %3
%33 = load i32, i32* %32
%34 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %33)
%35 = bitcast [3 x i32]* %1 to i32*
store i32* %35, i32** %4
%36 = load i32*, i32** %4
%37 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %36)
%38 = load i32*, i32** %4
%39 = load i32, i32* %38
%40 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %39)
ret void
}

LLVM IR (-O2):
@__const.array_test.arr = [3 x i32] [i32 1, i32 2, i32 3]
define void @array_test() {
%1 = alloca [3 x i32]
%2 = bitcast [3 x i32]* %1 to i8*
%3 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%4 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %3)
%5 = call i32 ([3 x i32]*, ...) bitcast (i32 (...)* @print_i to i32 ([3 x i32]*, ...)*)([3 x i32]* %1)
%6 = load i32, i32* %3
%7 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %6)
%8 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %3)
%9 = load i32, i32* %3
%10 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %9)
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%12 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %11)
%13 = load i32, i32* %11
%14 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %13)
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%16 = load i32, i32* %15
%17 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %16)
%18 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %3)
%19 = load i32, i32* %3
%20 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %19)
%21 = call i32 (i32*, ...) bitcast (i32 (...)* @print_i to i32 (i32*, ...)*)(i32* %3)
%22 = load i32, i32* %3
%23 = call i32 (i32, ...) bitcast (i32 (...)* @print_i to i32 (i32, ...)*)(i32 %22)
ret void
}