void trick2() {
  int arr[] = {1, 2, 3};
  *arr = 5;
  printf("arr[0] = %d, arr[1] = %d, arr[2] = %d\n", arr[0], arr[1], arr[2]);
  *(arr + 1) = 10;
  printf("arr[0] = %d, arr[1] = %d, arr[2] = %d\n", arr[0], arr[1], arr[2]);
  2 [arr] = 15;
  printf("0[arr] = %d, 1[arr] = %d, 2[arr] = %d\n", 0 [arr], 1 [arr], 2 [arr]);
}


x86 assembly (clang, -O0):
<trick2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0x4(%rbp)
movl   $0x5,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xa,-0x8(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xf,-0x4(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trick2>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x2,%edx
mov    $0x3,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0xa,%edx
mov    $0x3,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x5,%esi
mov    $0xa,%edx
mov    $0xf,%ecx
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.trick2.arr = [3 x i32] [i32 1, i32 2, i32 3]
@.str = [39 x i8] c"arr[0] = %d, arr[1] = %d, arr[2] = %d\0A\00"
@.str.1 = [39 x i8] c"0[arr] = %d, 1[arr] = %d, 2[arr] = %d\0A\00"
define void @trick2() {
%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
store i32 5, i32* %3
%4 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%5 = load i32, i32* %4
%6 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7, i32 %9)
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32 10, i32* %12
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %16, i32 %18)
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
store i32 15, i32* %20
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 0
%22 = load i32, i32* %21
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 1
%24 = load i32, i32* %23
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 2
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %24, i32 %26)
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"arr[0] = %d, arr[1] = %d, arr[2] = %d\0A\00"
@.str.1 = [39 x i8] c"0[arr] = %d, 1[arr] = %d, 2[arr] = %d\0A\00"
define void @trick2() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 5, i32 2, i32 3)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 5, i32 10, i32 3)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 10, i32 15)
ret void
}