int main(void) {
  int tab[] = {1, 2, 3};
  int *ptr, val;
  printf("tab[] = { 1, 2, 3 }\n");
  ptr = &tab[1];
  printf("ptr = &tab[1], *ptr=%i\n", *ptr);
  val = ptr[1];
  printf("val = ptr[1], val=%i\n", val);
  ptr = tab + 1;
  printf("ptr = tab + 1;, *ptr=%i\n", *ptr);
  printf("1[tab]=%i\n", 1 [tab]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xed8(%rip),%eax
mov    %eax,-0x8(%rbp)
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed1(%rip),%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.tab = [3 x i32] [i32 1, i32 2, i32 3]
@.str = [21 x i8] c"tab[] = { 1, 2, 3 }\0A\00"
@.str.1 = [24 x i8] c"ptr = &tab[1], *ptr=%i\0A\00"
@.str.2 = [22 x i8] c"val = ptr[1], val=%i\0A\00"
@.str.3 = [25 x i8] c"ptr = tab + 1;, *ptr=%i\0A\00"
@.str.4 = [11 x i8] c"1[tab]=%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i32]
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [3 x i32]* %2 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32*, i32** %3
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = load i32, i32* %12
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32* %17, i32** %3
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [24 x i8] c"ptr = &tab[1], *ptr=%i\0A\00"
@.str.2 = [22 x i8] c"val = ptr[1], val=%i\0A\00"
@.str.3 = [25 x i8] c"ptr = tab + 1;, *ptr=%i\0A\00"
@.str.4 = [11 x i8] c"1[tab]=%i\0A\00"
@str = [20 x i8] c"tab[] = { 1, 2, 3 }\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 2)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 3)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 2)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 2)
ret i32 0
}