#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  int arr[10] = {11, 22, 33, 44, 55, 66, 77, 88, 99, 100};
  int *ap;
  ap = arr;
  printf("get first element: %d\n", *arr);
  printf("print element 1: %d\n", *(arr + 1));
  printf("print element 2: %d\n", *(ap + 2));
  *(arr + 2) = 2189;
  *(ap + 3) = 8768;
  puts("After indirection:");
  while (ap < &arr[10]) {
    printf("%d, ", *ap);
    ap++;
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%esi
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
movl   $0x88d,-0x28(%rbp)
mov    -0x38(%rbp),%rax
movl   $0x2240,0xc(%rax)
lea    0xec3(%rip),%rdi
call   1030 <puts@plt>
mov    -0x38(%rbp),%rax
lea    -0x30(%rbp),%rcx
add    $0x28,%rcx
cmp    %rcx,%rax
jae    11e3 <main+0xb3>
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
jmp    11ab <main+0x7b>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xef0(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xed5(%rip),%rdi
mov    $0xb,%esi
call   1040 <printf@plt>
lea    0xedb(%rip),%rdi
mov    $0x16,%esi
call   1040 <printf@plt>
lea    0xedf(%rip),%rdi
mov    $0x21,%esi
call   1040 <printf@plt>
movabs $0x22400000088d,%rax
mov    %rax,0x8(%rsp)
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
lea    0x28(%rsp),%r14
lea    0xed6(%rip),%r15
mov    %r15,%rdi
mov    $0xb,%esi
call   1040 <printf@plt>
lea    0x4(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
add    $0x4,%rbx
cmp    %r14,%rbx
jb     11c0 <main+0xa0>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.arr = [10 x i32] [i32 11, i32 22, i32 33, i32 44, i32 55, i32 66, i32 77, i32 88, i32 99, i32 100]
@.str = [23 x i8] c"get first element: %d\0A\00"
@.str.1 = [21 x i8] c"print element 1: %d\0A\00"
@.str.2 = [21 x i8] c"print element 2: %d\0A\00"
@.str.3 = [19 x i8] c"After indirection:\00"
@.str.4 = [5 x i8] c"%d, \00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32*
store i32 0, i32* %1
%4 = bitcast [10 x i32]* %2 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32* %5, i32** %3
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%7 = load i32, i32* %6
%8 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 2
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%18 = getelementptr inbounds i32, i32* %17, i64 2
store i32 2189, i32* %18
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 3
store i32 8768, i32* %20
%21 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %26, %0
%23 = load i32*, i32** %3
%24 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 10
%25 = icmp ult i32* %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i32*, i32** %3
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i32 1
store i32* %31, i32** %3
br label %22
32: ; preds = %22
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}

LLVM IR (-O2):
@__const.main.arr = [10 x i32] [i32 11, i32 22, i32 33, i32 44, i32 55, i32 66, i32 77, i32 88, i32 99, i32 100]
@.str = [23 x i8] c"get first element: %d\0A\00"
@.str.1 = [21 x i8] c"print element 1: %d\0A\00"
@.str.2 = [21 x i8] c"print element 2: %d\0A\00"
@.str.3 = [19 x i8] c"After indirection:\00"
@.str.4 = [5 x i8] c"%d, \00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 11)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 22)
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 33)
store i32 2189, i32* %5
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
store i32 8768, i32* %7
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 10
%10 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 11)
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
br label %12
12: ; preds = %0, %12
%13 = phi i32* [ %11, %0 ], [ %16, %12 ]
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds i32, i32* %13, i64 1
%17 = icmp ult i32* %16, %9
br i1 %17, label %12, label %18
18: ; preds = %12
%19 = load i32, i32* @EXIT_SUCCESS
ret i32 %19
}