#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(void) {
  int a[] = {1, 2, 3, 5, 7};
  int *ptr = a;
  printf("adres %p, wartość %i\n", (void *)ptr, *ptr);
  ptr += 10;
  printf("adres %p, wartość %i\n", (void *)ptr, *ptr);
  ptr = a - 10;
  printf("adres %p, wartość %i\n", (void *)ptr, *ptr);
  ptr = a + 5;
  printf("adres %p, wartość %i\n", (void *)ptr, *ptr);
  *ptr = 10;
  printf("adres %p, wartość %i\n", (void *)ptr, *ptr);
  for (int i = 0; i < 6;)
    printf("a[%i] = %i\n", i, a[i++]);
  int b[] = {5, 7};
  int *ptr1 = a, *ptr2 = b;
  int diff = ptr2 - ptr1;
  printf("%i\n", diff);
  diff = a - b;
  printf("%i\n", diff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed5(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x28,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rax
add    $0xffffffffffffffd8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
movl   $0xa,(%rax)
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x6,-0x2c(%rbp)
jge    122e <main+0x11e>
mov    -0x2c(%rbp),%esi
mov    -0x2c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x2c(%rbp)
cltq
mov    -0x20(%rbp,%rax,4),%edx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fd <main+0xed>
mov    0xe03(%rip),%rax
mov    %rax,-0x34(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x34(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%esi
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rax
lea    -0x34(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%esi
lea    0xdac(%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    $0x20,%rsp
mov    0xef1(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
lea    0xedc(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x28(%rsp),%rsi
mov    0x28(%rsp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    -0x28(%rsp),%rsi
mov    -0x28(%rsp),%edx
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x14(%rsp),%r15
mov    0x14(%rsp),%edx
mov    %r14,%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0xa,0x14(%rsp)
mov    %r14,%rdi
mov    %r15d,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%edx
lea    0xe83(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%edx
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%edx
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rsp),%edx
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x14(%rsp),%edx
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movabs $0x700000005,%rax
mov    %rax,0x18(%rsp)
lea    0x18(%rsp),%r15
mov    %r15,%rsi
sub    %rbx,%rsi
shr    $0x2,%rsi
lea    0xdfb(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
sub    %r15,%rbx
shr    $0x2,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
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 5, i32 7]
@.str = [24 x i8] c"adres %p, warto\C5\9B\C4\87 %i\0A\00"
@.str.1 = [12 x i8] c"a[%i] = %i\0A\00"
@__const.main.b = [2 x i32] [i32 5, i32 7]
@.str.2 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %1
%9 = bitcast [5 x i32]* %2 to i8*
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = bitcast i32* %11 to i8*
%13 = ptrtoint i8* %12 to i32
%14 = load i32*, i32** %3
%15 = load i32, i32* %14
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %15)
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 10
store i32* %18, i32** %3
%19 = load i32*, i32** %3
%20 = bitcast i32* %19 to i8*
%21 = ptrtoint i8* %20 to i32
%22 = load i32*, i32** %3
%23 = load i32, i32* %22
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %23)
%25 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%26 = getelementptr inbounds i32, i32* %25, i64 -10
store i32* %26, i32** %3
%27 = load i32*, i32** %3
%28 = bitcast i32* %27 to i8*
%29 = ptrtoint i8* %28 to i32
%30 = load i32*, i32** %3
%31 = load i32, i32* %30
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %31)
%33 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%34 = getelementptr inbounds i32, i32* %33, i64 5
store i32* %34, i32** %3
%35 = load i32*, i32** %3
%36 = bitcast i32* %35 to i8*
%37 = ptrtoint i8* %36 to i32
%38 = load i32*, i32** %3
%39 = load i32, i32* %38
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %37, i32 %39)
%41 = load i32*, i32** %3
store i32 10, i32* %41
%42 = load i32*, i32** %3
%43 = bitcast i32* %42 to i8*
%44 = ptrtoint i8* %43 to i32
%45 = load i32*, i32** %3
%46 = load i32, i32* %45
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %44, i32 %46)
store i32 0, i32* %4
br label %48
48: ; preds = %51, %0
%49 = load i32, i32* %4
%50 = icmp slt i32 %49, 6
br i1 %50, label %51, label %59
51: ; preds = %48
%52 = load i32, i32* %4
%53 = load i32, i32* %4
%54 = add nsw i32 %53, 1
store i32 %54, i32* %4
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %52, i32 %57)
br label %48
59: ; preds = %48
%60 = bitcast [2 x i32]* %5 to i8*
%61 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
store i32* %61, i32** %6
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
store i32* %62, i32** %7
%63 = load i32*, i32** %7
%64 = load i32*, i32** %6
%65 = ptrtoint i32* %63 to i64
%66 = ptrtoint i32* %64 to i64
%67 = sub i64 %65, %66
%68 = sdiv exact i64 %67, 4
%69 = trunc i64 %68 to i32
store i32 %69, i32* %8
%70 = load i32, i32* %8
%71 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %70)
%72 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%74 = ptrtoint i32* %72 to i64
%75 = ptrtoint i32* %73 to i64
%76 = sub i64 %74, %75
%77 = sdiv exact i64 %76, 4
%78 = trunc i64 %77 to i32
store i32 %78, i32* %8
%79 = load i32, i32* %8
%80 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %79)
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [5 x i32] [i32 1, i32 2, i32 3, i32 5, i32 7]
@.str = [24 x i8] c"adres %p, warto\C5\9B\C4\87 %i\0A\00"
@.str.1 = [12 x i8] c"a[%i] = %i\0A\00"
@.str.2 = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca i64
%3 = bitcast [5 x i32]* %1 to i8*
%4 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%5 = ptrtoint [5 x i32]* %1 to i64
%6 = trunc i64 %5 to i32
%7 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %6, i32 1)
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 10
%9 = ptrtoint i32* %8 to i64
%10 = trunc i64 %9 to i32
%11 = load i32, i32* %8
%12 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 -10
%14 = ptrtoint i32* %13 to i64
%15 = trunc i64 %14 to i32
%16 = load i32, i32* %13
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 5
%19 = ptrtoint i32* %18 to i64
%20 = trunc i64 %19 to i32
%21 = load i32, i32* %18
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
store i32 10, i32* %18
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %20, i32 10)
%24 = load i32, i32* %4
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %24)
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %27)
%29 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%30 = load i32, i32* %29
%31 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 2, i32 %30)
%32 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%33 = load i32, i32* %32
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 3, i32 %33)
%35 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%36 = load i32, i32* %35
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 4, i32 %36)
%38 = load i32, i32* %18
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 %38)
%40 = bitcast i64* %2 to i8*
store i64 30064771077, i64* %2
%41 = ptrtoint i64* %2 to i64
%42 = sub i64 %41, %5
%43 = lshr exact i64 %42, 2
%44 = trunc i64 %43 to i32
%45 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = sub i64 %5, %41
%47 = lshr exact i64 %46, 2
%48 = trunc i64 %47 to i32
%49 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %48)
ret i32 0
}