#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 *, ...);
void foolAroundWithArrays(void) {
  int numbers[10] = {1, 2, 3};
  for (int i = 0; i < 3; i++) {
    printf("value is %d, address is %p\n", numbers[i], &numbers[i]);
    printf("value is %d, address is %p\n", *(numbers + i), numbers + i);
  }
  int *numberRef = numbers;
  printf("numberRef is %p, value is %d\n", numberRef, *numberRef);
  for (; *numberRef != 0; numberRef++) {
    printf("value is %d, address is %p\n", *numberRef, numberRef);
  }
}


x86 assembly (clang, -O0):
<foolAroundWithArrays>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movl   $0x1,-0x30(%rbp)
movl   $0x2,-0x2c(%rbp)
movl   $0x3,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    11b6 <foolAroundWithArrays+0x96>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rdx
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%esi
lea    -0x30(%rbp),%rdx
movslq -0x34(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1154 <foolAroundWithArrays+0x34>
lea    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x40(%rbp),%rax
mov    (%rax),%edx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
cmpl   $0x0,(%rax)
je     120c <foolAroundWithArrays+0xec>
mov    -0x40(%rbp),%rax
mov    (%rax),%esi
mov    -0x40(%rbp),%rdx
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
jmp    11d6 <foolAroundWithArrays+0xb6>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foolAroundWithArrays>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movabs $0x200000001,%rax
mov    %rax,(%rsp)
lea    0x4(%rsp),%r12
lea    0x8(%rsp),%r14
movl   $0x3,0x8(%rsp)
lea    0xea9(%rip),%r15
mov    %rsp,%rbx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%esi
mov    %r15,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%esi
mov    %r15,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%esi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%edx
lea    0xe52(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%esi
test   %esi,%esi
je     1208 <foolAroundWithArrays+0xf8>
lea    0xe1e(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rbx),%esi
add    $0x4,%rbx
test   %esi,%esi
jne    11f0 <foolAroundWithArrays+0xe0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"value is %d, address is %p\0A\00"
@.str.1 = [30 x i8] c"numberRef is %p, value is %d\0A\00"
define void @foolAroundWithArrays() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = alloca i32*
%4 = bitcast [10 x i32]* %1 to i8*
%5 = bitcast i8* %4 to [10 x i32]*
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i32 0, i32 0
store i32 1, i32* %6
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i32 0, i32 1
store i32 2, i32* %7
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i32 0, i32 2
store i32 3, i32* %8
store i32 0, i32* %2
br label %9
9: ; preds = %31, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %34
12: ; preds = %9
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %16, i32* %19)
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %25, i32* %29)
br label %31
31: ; preds = %12
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %9
34: ; preds = %9
%35 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
store i32* %35, i32** %3
%36 = load i32*, i32** %3
%37 = load i32*, i32** %3
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32* %36, i32 %38)
br label %40
40: ; preds = %49, %34
%41 = load i32*, i32** %3
%42 = load i32, i32* %41
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %52
44: ; preds = %40
%45 = load i32*, i32** %3
%46 = load i32, i32* %45
%47 = load i32*, i32** %3
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %46, i32* %47)
br label %49
49: ; preds = %44
%50 = load i32*, i32** %3
%51 = getelementptr inbounds i32, i32* %50, i32 1
store i32* %51, i32** %3
br label %40
52: ; preds = %40
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"value is %d, address is %p\0A\00"
@.str.1 = [30 x i8] c"numberRef is %p, value is %d\0A\00"
define void @foolAroundWithArrays() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
store i32 1, i32* %3
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
store i32 2, i32* %4
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
store i32 3, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 1, i32* %3)
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %7, i32* %3)
%9 = load i32, i32* %4
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %9, i32* %4)
%11 = load i32, i32* %4
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %11, i32* %4)
%13 = load i32, i32* %5
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %13, i32* %5)
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %15, i32* %5)
%17 = load i32, i32* %3
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32 %17)
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %0, %21
%22 = phi i32 [ %26, %21 ], [ %19, %0 ]
%23 = phi i32* [ %25, %21 ], [ %3, %0 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %22, i32* %23)
%25 = getelementptr inbounds i32, i32* %23, i64 1
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %21
28: ; preds = %21, %0
ret void
}