#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);
void pointer(int n, int arr[][n]) {
  int(*p)[n], (*q)[n], (*t)[n];
  p = &arr[1];
  q = &arr[10 - 3];
  printf("diff: %ld, %ld\n", q - p, q + 1 - p);
  t = q - 5;
  (*t)[4] = 3333;
  t[0][n - 1] = 9127684;
  printf("deref: %d, %d\n", (*t)[1], (*t)[n - 3]);
}


x86 assembly (clang, -O0):
<pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%edx
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rdx,%rsi
shl    $0x0,%rsi
shl    $0x2,%rsi
add    %rsi,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x7,%rdx,%rdx
shl    $0x2,%rdx
add    %rdx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rdx
sub    %rdx,%rax
mov    %rcx,%rsi
shl    $0x2,%rsi
cqto
idiv   %rsi
mov    %eax,%esi
mov    -0x20(%rbp),%rax
mov    %rcx,%rdx
shl    $0x0,%rdx
shl    $0x2,%rdx
add    %rdx,%rax
mov    -0x18(%rbp),%rdx
sub    %rdx,%rax
shl    $0x2,%rcx
cqto
idiv   %rcx
mov    %eax,%edx
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
imul   $0xfffffffffffffffb,%rdx,%rdx
shl    $0x2,%rdx
add    %rdx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0xd05,0x10(%rax)
mov    -0x28(%rbp),%rax
imul   $0x0,%rcx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movl   $0x8b4704,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x28(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe07(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointer>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    %edi,%ecx
lea    (%rsi,%rcx,4),%rdi
lea    (%rcx,%rcx,8),%rax
lea    (%rax,%rax,2),%rbx
add    %rcx,%rbx
add    %rsi,%rbx
mov    %rbx,%rax
sub    %rdi,%rax
lea    0x0(,%rcx,4),%rbp
mov    %rax,%rdx
or     %rbp,%rdx
shr    $0x20,%rdx
je     114f <pointer+0x3f>
cqto
idiv   %rbp
mov    %rax,%rsi
jmp    1155 <pointer+0x45>
xor    %edx,%edx
div    %ebp
mov    %eax,%esi
lea    (%rbx,%rcx,4),%rax
sub    %rdi,%rax
mov    %rax,%rcx
or     %rbp,%rcx
shr    $0x20,%rcx
je     116f <pointer+0x5f>
cqto
idiv   %rbp
jmp    1173 <pointer+0x63>
xor    %edx,%edx
div    %ebp
lea    0xe86(%rip),%rdi
mov    %eax,%edx
call   1030 <printf@plt>
lea    0x0(,%rbp,4),%rax
add    %rbp,%rax
sub    %rax,%rbx
movl   $0xd05,0x10(%rbx)
movslq %r14d,%rax
movl   $0x8b4704,-0x4(%rbx,%rax,4)
mov    0x4(%rbx),%esi
mov    -0xc(%rbx,%rax,4),%edx
lea    0xe61(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"diff: %ld, %ld\0A\00"
@.str.1 = [15 x i8] c"deref: %d, %d\0A\00"
define void @pointer(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = load i32, i32* %3
%9 = zext i32 %8 to i64
%10 = load i32, i32* %3
%11 = zext i32 %10 to i64
%12 = load i32, i32* %3
%13 = zext i32 %12 to i64
%14 = load i32, i32* %3
%15 = zext i32 %14 to i64
%16 = load i32*, i32** %4
%17 = mul nsw i64 1, %9
%18 = getelementptr inbounds i32, i32* %16, i64 %17
store i32* %18, i32** %5
%19 = load i32*, i32** %4
%20 = mul nsw i64 7, %9
%21 = getelementptr inbounds i32, i32* %19, i64 %20
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = load i32*, i32** %5
%24 = ptrtoint i32* %22 to i64
%25 = ptrtoint i32* %23 to i64
%26 = sub i64 %24, %25
%27 = mul nuw i64 4, %13
%28 = sdiv exact i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = load i32*, i32** %6
%31 = mul nsw i64 1, %13
%32 = getelementptr inbounds i32, i32* %30, i64 %31
%33 = load i32*, i32** %5
%34 = ptrtoint i32* %32 to i64
%35 = ptrtoint i32* %33 to i64
%36 = sub i64 %34, %35
%37 = mul nuw i64 4, %13
%38 = sdiv exact i64 %36, %37
%39 = trunc i64 %38 to i32
%40 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %29, i32 %39)
%41 = load i32*, i32** %6
%42 = mul nsw i64 -5, %13
%43 = getelementptr inbounds i32, i32* %41, i64 %42
store i32* %43, i32** %7
%44 = load i32*, i32** %7
%45 = getelementptr inbounds i32, i32* %44, i64 4
store i32 3333, i32* %45
%46 = load i32*, i32** %7
%47 = mul nsw i64 0, %15
%48 = getelementptr inbounds i32, i32* %46, i64 %47
%49 = load i32, i32* %3
%50 = sub nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i32, i32* %48, i64 %51
store i32 9127684, i32* %52
%53 = load i32*, i32** %7
%54 = getelementptr inbounds i32, i32* %53, i64 1
%55 = load i32, i32* %54
%56 = load i32*, i32** %7
%57 = load i32, i32* %3
%58 = sub nsw i32 %57, 3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %56, i64 %59
%61 = load i32, i32* %60
%62 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %55, i32 %61)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"diff: %ld, %ld\0A\00"
@.str.1 = [15 x i8] c"deref: %d, %d\0A\00"
define void @pointer(i32 %0, i32* %1) {
%3 = zext i32 %0 to i64
%4 = getelementptr inbounds i32, i32* %1, i64 %3
%5 = mul nuw nsw i64 %3, 7
%6 = getelementptr inbounds i32, i32* %1, i64 %5
%7 = ptrtoint i32* %6 to i64
%8 = ptrtoint i32* %4 to i64
%9 = sub i64 %7, %8
%10 = shl nuw nsw i64 %3, 2
%11 = sdiv exact i64 %9, %10
%12 = trunc i64 %11 to i32
%13 = getelementptr inbounds i32, i32* %6, i64 %3
%14 = ptrtoint i32* %13 to i64
%15 = sub i64 %14, %8
%16 = sdiv exact i64 %15, %10
%17 = trunc i64 %16 to i32
%18 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %17)
%19 = mul nsw i64 %3, -5
%20 = getelementptr inbounds i32, i32* %6, i64 %19
%21 = getelementptr inbounds i32, i32* %20, i64 4
store i32 3333, i32* %21
%22 = add nsw i32 %0, -1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %20, i64 %23
store i32 9127684, i32* %24
%25 = getelementptr inbounds i32, i32* %20, i64 1
%26 = load i32, i32* %25
%27 = add nsw i32 %0, -3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %20, i64 %28
%30 = load i32, i32* %29
%31 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %30)
ret void
}