#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 main(int argc, char **argv) {
  int primes[] = {2, 3, 5, 7, 11, 13, 17, 19};
  int *p;
  p = primes;
  printf("*p == %d\n", *p);
  printf("*p + 4 == %d    (integer arithmetic)\n\n", *p + 4);
  printf("*(p + 4) == %d (dereferenced at offset)\n", *(p + 4));
  printf("p[4] == %d     (shorthand)\n", p[4]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xed3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xecd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%esi
add    $0x4,%esi
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%esi
lea    0xec2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%esi
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x2,%esi
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x6,%esi
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0xb,%esi
call   1030 <printf@plt>
lea    0xf0f(%rip),%rdi
mov    $0xb,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.primes = [8 x i32] [i32 2, i32 3, i32 5, i32 7, i32 11, i32 13, i32 17, i32 19]
@.str = [10 x i8] c"*p == %d\0A\00"
@.str.1 = [39 x i8] c"*p + 4 == %d (integer arithmetic)\0A\0A\00"
@.str.2 = [41 x i8] c"*(p + 4) == %d (dereferenced at offset)\0A\00"
@.str.3 = [28 x i8] c"p[4] == %d (shorthand)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i32]
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [8 x i32]* %6 to i8*
%9 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 0
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = load i32, i32* %10
%12 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32*, i32** %7
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 4
%16 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %7
%18 = getelementptr inbounds i32, i32* %17, i64 4
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i32*, i32** %7
%22 = getelementptr inbounds i32, i32* %21, i64 4
%23 = load i32, i32* %22
%24 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"*p == %d\0A\00"
@.str.1 = [39 x i8] c"*p + 4 == %d (integer arithmetic)\0A\0A\00"
@.str.2 = [41 x i8] c"*(p + 4) == %d (dereferenced at offset)\0A\00"
@.str.3 = [28 x i8] c"p[4] == %d (shorthand)\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 6)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 11)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 11)
ret i32 0
}