#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(int argc, char const *argv[]) {
  int urn[5] = {100, 200, 300, 400, 500};
  int *ptr1, *ptr2, *ptr3;
  ptr1 = urn;
  ptr2 = &urn[2];
  printf("pointer value,dereferenced pointer, pointer address:\n");
  printf("ptr1 = %p, *ptr1 = %d, &ptr1 = %p\n", ptr1, *ptr1, &ptr1);
  ptr3 = ptr1 + 4;
  printf("\nadding an int to a pointer:\n");
  printf("ptr1 + 4 = %p, *(ptr4 + 3) = %d\n", ptr1 + 4, *(ptr1 + 3));
  ptr1++;
  printf("\nvalues after ptr1++\n");
  printf("ptr1 = %p, *ptr1 = %d,&ptr1 = %p\n", ptr1, *ptr1, &ptr1);
  ptr2--;
  printf("\nvalues after --ptr2\n");
  printf("ptr2 = %p, *ptr2 = %d, &ptr2 = %p\n", ptr2, *ptr2, &ptr2);
  --ptr1;
  ++ptr2;
  printf("\nPointers reset to original values:\n");
  printf("ptr1 = %p,ptr2 = %p\n", ptr1, ptr2);
  printf("\nsubtracting one pointer from another:\n");
  printf("ptr2 = %p,ptr1 = %p,ptr2 - ptr1 = %d\n", ptr2, ptr1, ptr2 - ptr1);
  printf("\nsubtracting an int from a pointer:\n");
  printf("ptr3 = %p, ptr3 - 2 = %p, *ptr3 = %d\n", ptr3, ptr3 - 2, *ptr3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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    0xece(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
lea    0xed2(%rip),%rdi
lea    -0x38(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x48(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
add    $0x10,%rsi
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%edx
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
lea    0xedd(%rip),%rdi
lea    -0x38(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x40(%rbp)
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsi
mov    -0x40(%rbp),%rax
mov    (%rax),%edx
lea    0xedf(%rip),%rdi
lea    -0x40(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x40(%rbp)
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsi
mov    -0x40(%rbp),%rdx
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%rax
sub    %rax,%rcx
sar    $0x2,%rcx
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rsi
mov    -0x48(%rbp),%rdx
add    $0xfffffffffffffff8,%rdx
mov    -0x48(%rbp),%rax
mov    (%rax),%ecx
lea    0xf0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xee1(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xec6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,(%rsp)
lea    0xfaf(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%edx
lea    0xeb5(%rip),%rdi
mov    %rsp,%r15
mov    %rbx,%rsi
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rbx
lea    0x10(%rbx),%r14
lea    0xfb5(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rsi
mov    0xc(%rsi),%edx
add    $0x10,%rsi
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
addq   $0x4,(%rsp)
lea    0xfa8(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rsi
mov    (%rsi),%edx
lea    0xe9e(%rip),%rdi
mov    %r15,%rcx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x14(%rsp),%r15
mov    %r15,0x8(%rsp)
lea    0xf90(%rip),%rdi
call   1030 <puts@plt>
mov    0x14(%rsp),%edx
lea    0xe95(%rip),%rdi
lea    0x8(%rsp),%rcx
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
addq   $0xfffffffffffffffc,(%rsp)
addq   $0x4,0x8(%rsp)
lea    0xf74(%rip),%rdi
call   1030 <puts@plt>
mov    (%rsp),%rsi
mov    0x8(%rsp),%rdx
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf75(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rsi
mov    (%rsp),%rdx
mov    %rsi,%rcx
sub    %rdx,%rcx
sar    $0x2,%rcx
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf6f(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rbx),%ecx
add    $0x8,%rbx
lea    0xe6f(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.urn = [5 x i32] [i32 100, i32 200, i32 300, i32 400, i32 500]
@.str = [54 x i8] c"pointer value,dereferenced pointer, pointer address:\0A\00"
@.str.1 = [35 x i8] c"ptr1 = %p, *ptr1 = %d, &ptr1 = %p\0A\00"
@.str.2 = [30 x i8] c"\0Aadding an int to a pointer:\0A\00"
@.str.3 = [33 x i8] c"ptr1 + 4 = %p, *(ptr4 + 3) = %d\0A\00"
@.str.4 = [22 x i8] c"\0Avalues after ptr1++\0A\00"
@.str.5 = [34 x i8] c"ptr1 = %p, *ptr1 = %d,&ptr1 = %p\0A\00"
@.str.6 = [22 x i8] c"\0Avalues after --ptr2\0A\00"
@.str.7 = [35 x i8] c"ptr2 = %p, *ptr2 = %d, &ptr2 = %p\0A\00"
@.str.8 = [37 x i8] c"\0APointers reset to original values:\0A\00"
@.str.9 = [21 x i8] c"ptr1 = %p,ptr2 = %p\0A\00"
@.str.10 = [40 x i8] c"\0Asubtracting one pointer from another:\0A\00"
@.str.11 = [38 x i8] c"ptr2 = %p,ptr1 = %p,ptr2 - ptr1 = %d\0A\00"
@.str.12 = [37 x i8] c"\0Asubtracting an int from a pointer:\0A\00"
@.str.13 = [38 x i8] c"ptr3 = %p, ptr3 - 2 = %p, *ptr3 = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i32]
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [5 x i32]* %6 to i8*
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
store i32* %11, i32** %7
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 2
store i32* %12, i32** %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%14 = load i32*, i32** %7
%15 = load i32*, i32** %7
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32* %14, i32 %16, i32** %7)
%18 = load i32*, i32** %7
%19 = getelementptr inbounds i32, i32* %18, i64 4
store i32* %19, i32** %9
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32*, i32** %7
%22 = getelementptr inbounds i32, i32* %21, i64 4
%23 = load i32*, i32** %7
%24 = getelementptr inbounds i32, i32* %23, i64 3
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32* %22, i32 %25)
%27 = load i32*, i32** %7
%28 = getelementptr inbounds i32, i32* %27, i32 1
store i32* %28, i32** %7
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%30 = load i32*, i32** %7
%31 = load i32*, i32** %7
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32* %30, i32 %32, i32** %7)
%34 = load i32*, i32** %8
%35 = getelementptr inbounds i32, i32* %34, i32 -1
store i32* %35, i32** %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%37 = load i32*, i32** %8
%38 = load i32*, i32** %8
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32* %37, i32 %39, i32** %8)
%41 = load i32*, i32** %7
%42 = getelementptr inbounds i32, i32* %41, i32 -1
store i32* %42, i32** %7
%43 = load i32*, i32** %8
%44 = getelementptr inbounds i32, i32* %43, i32 1
store i32* %44, i32** %8
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
%46 = load i32*, i32** %7
%47 = load i32*, i32** %8
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i32* %46, i32* %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0))
%50 = load i32*, i32** %8
%51 = load i32*, i32** %7
%52 = load i32*, i32** %8
%53 = load i32*, i32** %7
%54 = ptrtoint i32* %52 to i64
%55 = ptrtoint i32* %53 to i64
%56 = sub i64 %54, %55
%57 = sdiv exact i64 %56, 4
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i32* %50, i32* %51, i64 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0))
%60 = load i32*, i32** %9
%61 = load i32*, i32** %9
%62 = getelementptr inbounds i32, i32* %61, i64 -2
%63 = load i32*, i32** %9
%64 = load i32, i32* %63
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i32* %60, i32* %62, i32 %64)
ret i32 0
}

LLVM IR (-O2):
@__const.main.urn = [5 x i32] [i32 100, i32 200, i32 300, i32 400, i32 500]
@.str.1 = [35 x i8] c"ptr1 = %p, *ptr1 = %d, &ptr1 = %p\0A\00"
@.str.3 = [33 x i8] c"ptr1 + 4 = %p, *(ptr4 + 3) = %d\0A\00"
@.str.5 = [34 x i8] c"ptr1 = %p, *ptr1 = %d,&ptr1 = %p\0A\00"
@.str.7 = [35 x i8] c"ptr2 = %p, *ptr2 = %d, &ptr2 = %p\0A\00"
@.str.9 = [21 x i8] c"ptr1 = %p,ptr2 = %p\0A\00"
@.str.11 = [38 x i8] c"ptr2 = %p,ptr1 = %p,ptr2 - ptr1 = %d\0A\00"
@.str.13 = [38 x i8] c"ptr3 = %p, ptr3 - 2 = %p, *ptr3 = %d\0A\00"
@str = [53 x i8] c"pointer value,dereferenced pointer, pointer address:\00"
@str.14 = [29 x i8] c"\0Aadding an int to a pointer:\00"
@str.15 = [21 x i8] c"\0Avalues after ptr1++\00"
@str.16 = [21 x i8] c"\0Avalues after --ptr2\00"
@str.17 = [36 x i8] c"\0APointers reset to original values:\00"
@str.18 = [39 x i8] c"\0Asubtracting one pointer from another:\00"
@str.19 = [36 x i8] c"\0Asubtracting an int from a pointer:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x i32]
%4 = alloca i32*
%5 = alloca i32*
%6 = bitcast [5 x i32]* %3 to i8*
%7 = bitcast i32** %4 to i8*
%8 = bitcast i32** %5 to i8*
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
store i32* %9, i32** %4
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%11 = load i32, i32* %9
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32* %9, i32 %11, i32** %4)
%13 = load i32*, i32** %4
%14 = getelementptr inbounds i32, i32* %13, i64 4
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.14, i64 0, i64 0))
%16 = load i32*, i32** %4
%17 = getelementptr inbounds i32, i32* %16, i64 4
%18 = getelementptr inbounds i32, i32* %16, i64 3
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32* %17, i32 %19)
%21 = load i32*, i32** %4
%22 = getelementptr inbounds i32, i32* %21, i64 1
store i32* %22, i32** %4
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.15, i64 0, i64 0))
%24 = load i32*, i32** %4
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32* %24, i32 %25, i32** %4)
%27 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 1
store i32* %27, i32** %5
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.16, i64 0, i64 0))
%29 = load i32, i32* %27
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i32* %27, i32 %29, i32** %5)
%31 = load i32*, i32** %4
%32 = getelementptr inbounds i32, i32* %31, i64 -1
store i32* %32, i32** %4
%33 = load i32*, i32** %5
%34 = getelementptr inbounds i32, i32* %33, i64 1
store i32* %34, i32** %5
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.17, i64 0, i64 0))
%36 = load i32*, i32** %4
%37 = load i32*, i32** %5
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i32* %36, i32* %37)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.18, i64 0, i64 0))
%40 = load i32*, i32** %5
%41 = load i32*, i32** %4
%42 = ptrtoint i32* %40 to i64
%43 = ptrtoint i32* %41 to i64
%44 = sub i64 %42, %43
%45 = ashr exact i64 %44, 2
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i32* %40, i32* %41, i64 %45)
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.19, i64 0, i64 0))
%48 = getelementptr inbounds i32, i32* %13, i64 2
%49 = load i32, i32* %14
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.13, i64 0, i64 0), i32* %14, i32* %48, i32 %49)
ret i32 0
}