#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 main(void) {
  int i = 0;
  int a[5] = {1, 2, 3, 4, 5};
  int *p = a;
  for (i = 0; i < 5; i++) {
    printf("&a[%d] = %p p+%d = %p\n", i, &a[i], i, p + i);
  }
  printf("&a = %p &p = %p\n", &a, &p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    0xed3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xece(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    119e <main+0x8e>
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rax
lea    -0x20(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
mov    -0x8(%rbp),%ecx
mov    -0x28(%rbp),%r8
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%r8
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x44>
lea    0xe86(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0xef1(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x10(%rsp),%r14
mov    %rsp,%r15
mov    %r15,0x18(%rsp)
lea    0xed2(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %r15,%r8
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%ecx
mov    %rdx,%r8
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%ecx
mov    %rdx,%r8
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%ecx
mov    %rdx,%r8
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r14,%rdx
mov    $0x4,%ecx
mov    %r14,%r8
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe60(%rip),%rdi
lea    0x18(%rsp),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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