#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int, ...);
int main(void) {
  int a[] = {10, 20, 30};
  printf("a[1]=%d, *(p+1)=%d, p[2]=%d\n", a[1], *(a + 1), *(&a[2]));
  int *p = a;
  p++;
  *p = 22;
  p[1] = 33;
  p[-1] = 11;
  for (int i = 0; i < 3; i++)
    printf("a[%d] = %d, ", i, a[i]);
}


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)
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x16,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x21,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0xb,-0x4(%rax)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11b6 <main+0xa6>
mov    -0x1c(%rbp),%esi
movslq -0x1c(%rbp),%rax
mov    -0x10(%rbp,%rax,4),%edx
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1185 <main+0x75>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rdi
mov    $0x14,%esi
mov    $0x14,%edx
mov    $0x1e,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xb,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x16,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x21,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.a = [3 x i32] [i32 10, i32 20, i32 30]
@.str = [29 x i8] c"a[1]=%d, *(p+1)=%d, p[2]=%d\0A\00"
@.str.1 = [13 x i8] c"a[%d] = %d, \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 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%12 = load i32, i32* %11
%13 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10, i32 %12)
%14 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32* %14, i32** %3
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i32 1
store i32* %16, i32** %3
%17 = load i32*, i32** %3
store i32 22, i32* %17
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 1
store i32 33, i32* %19
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 -1
store i32 11, i32* %21
store i32 0, i32* %4
br label %22
22: ; preds = %32, %0
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 3
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load i32, i32* %4
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %30)
br label %32
32: ; preds = %25
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %22
35: ; preds = %22
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [29 x i8] c"a[1]=%d, *(p+1)=%d, p[2]=%d\0A\00"
@.str.1 = [13 x i8] c"a[%d] = %d, \00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 20, i32 20, i32 30)
%2 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 11)
%3 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 22)
%4 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 33)
ret i32 0
}