#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*/ assert(int);
int main() {
  int x;
  int *q = &x + 2;
  int *r = &x + 4;
  assert(r - q == 2);
  assert(r - 4 == &x);
  int a[5];
  int *b = a + 3;
  assert(b - a == 3);
  assert(b - 3 == a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
lea    -0x8(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
cmp    $0x2,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
add    $0xfffffffffffffff0,%rax
lea    -0x8(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
lea    -0x30(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
lea    -0x30(%rbp),%rcx
sub    %rcx,%rax
sar    $0x2,%rax
cmp    $0x3,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x38(%rbp),%rax
add    $0xfffffffffffffff4,%rax
lea    -0x30(%rbp),%rcx
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [5 x i32]
%6 = alloca i32*
store i32 0, i32* %1
%7 = getelementptr inbounds i32, i32* %2, i64 2
store i32* %7, i32** %3
%8 = getelementptr inbounds i32, i32* %2, i64 4
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = load i32*, i32** %3
%11 = ptrtoint i32* %9 to i64
%12 = ptrtoint i32* %10 to i64
%13 = sub i64 %11, %12
%14 = sdiv exact i64 %13, 4
%15 = icmp eq i64 %14, 2
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32*, i32** %4
%19 = getelementptr inbounds i32, i32* %18, i64 -4
%20 = icmp eq i32* %19, %2
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%24 = getelementptr inbounds i32, i32* %23, i64 3
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%27 = ptrtoint i32* %25 to i64
%28 = ptrtoint i32* %26 to i64
%29 = sub i64 %27, %28
%30 = sdiv exact i64 %29, 4
%31 = icmp eq i64 %30, 3
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i32*, i32** %6
%35 = getelementptr inbounds i32, i32* %34, i64 -3
%36 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%37 = icmp eq i32* %35, %36
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @assert(i32 1)
%2 = tail call i32 @assert(i32 1)
%3 = tail call i32 @assert(i32 1)
%4 = tail call i32 @assert(i32 1)
ret i32 0
}