#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 *, long, ...);
int main() {
  int arr[] = {1, 4, 5, 8, 10};
  int num = 5;
  int *ptr = arr;
  int *defptr = arr;
  int *ptrnum = &num;
  long int ptrsize = sizeof(*ptr);
  printf("ptr val is %d;\t arr address is %p;\tptr address is %p\nptrnum val "
         "is %d; \tptrnum address is %p\n",
         *ptr, ptr, &ptr, *ptrnum, ptrnum);
  ptr++;
  printf("ptr + 1 val is %d;\t *ptr + 1 address is %p\n", *ptr, ptr);
  printf("Difference between ptr and defptr: %ld\n", ptr - defptr);
  printf("Ptr size is %ld\n", ptrsize);
  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)
movl   $0x5,-0x24(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    -0x24(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x4,-0x48(%rbp)
mov    -0x30(%rbp),%rax
movslq (%rax),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x40(%rbp),%rax
mov    (%rax),%r8d
mov    -0x40(%rbp),%r9
lea    0xe92(%rip),%rdi
lea    -0x30(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq (%rax),%rsi
mov    -0x30(%rbp),%rdx
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rax
sub    %rax,%rsi
sar    $0x2,%rsi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rsi
lea    0xeec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xef5(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x5,0xc(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,(%rsp)
lea    0xed1(%rip),%rdi
mov    %rsp,%rcx
lea    0xc(%rsp),%r9
mov    $0x1,%esi
mov    %rbx,%rdx
mov    $0x5,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%rax
lea    0x4(%rax),%rdx
mov    %rdx,(%rsp)
movslq 0x4(%rax),%rsi
lea    0xefb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%rsi
sub    %rbx,%rsi
sar    $0x2,%rsi
lea    0xf0e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf28(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr = [5 x i32] [i32 1, i32 4, i32 5, i32 8, i32 10]
@.str = [94 x i8] c"ptr val is %d;\09 arr address is %p;\09ptr address is %p\0Aptrnum val is %d; \09ptrnum address is %p\0A\00"
@.str.1 = [44 x i8] c"ptr + 1 val is %d;\09 *ptr + 1 address is %p\0A\00"
@.str.2 = [40 x i8] c"Difference between ptr and defptr: %ld\0A\00"
@.str.3 = [17 x i8] c"Ptr size is %ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
store i32 0, i32* %1
%8 = bitcast [5 x i32]* %2 to i8*
store i32 5, i32* %3
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
store i32* %9, i32** %4
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
store i32* %10, i32** %5
store i32* %3, i32** %6
store i64 4, i64* %7
%11 = load i32*, i32** %4
%12 = load i32, i32* %11
%13 = sext i32 %12 to i64
%14 = load i32*, i32** %4
%15 = load i32*, i32** %6
%16 = load i32, i32* %15
%17 = load i32*, i32** %6
%18 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str, i64 0, i64 0), i64 %13, i32* %14, i32** %4, i32 %16, i32* %17)
%19 = load i32*, i32** %4
%20 = getelementptr inbounds i32, i32* %19, i32 1
store i32* %20, i32** %4
%21 = load i32*, i32** %4
%22 = load i32, i32* %21
%23 = sext i32 %22 to i64
%24 = load i32*, i32** %4
%25 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i64 %23, i32* %24)
%26 = load i32*, i32** %4
%27 = load i32*, i32** %5
%28 = ptrtoint i32* %26 to i64
%29 = ptrtoint i32* %27 to i64
%30 = sub i64 %28, %29
%31 = sdiv exact i64 %30, 4
%32 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i64 %31)
%33 = load i64, i64* %7
%34 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i64 %33)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [5 x i32] [i32 1, i32 4, i32 5, i32 8, i32 10]
@.str = [94 x i8] c"ptr val is %d;\09 arr address is %p;\09ptr address is %p\0Aptrnum val is %d; \09ptrnum address is %p\0A\00"
@.str.1 = [44 x i8] c"ptr + 1 val is %d;\09 *ptr + 1 address is %p\0A\00"
@.str.2 = [40 x i8] c"Difference between ptr and defptr: %ld\0A\00"
@.str.3 = [17 x i8] c"Ptr size is %ld\0A\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = alloca i32
%3 = alloca i32*
%4 = bitcast [5 x i32]* %1 to i8*
%5 = bitcast i32* %2 to i8*
store i32 5, i32* %2
%6 = bitcast i32** %3 to i8*
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
store i32* %7, i32** %3
%8 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str, i64 0, i64 0), i64 1, i32* %7, i32** %3, i32 5, i32* %2)
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 1
store i32* %10, i32** %3
%11 = load i32, i32* %10
%12 = sext i32 %11 to i64
%13 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i64 %12, i32* %10)
%14 = load i32*, i32** %3
%15 = ptrtoint i32* %14 to i64
%16 = ptrtoint [5 x i32]* %1 to i64
%17 = sub i64 %15, %16
%18 = ashr exact i64 %17, 2
%19 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i64 %18)
%20 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i64 4)
ret i32 0
}