#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 main04() {
  int array[100] = {0};
  int *p = array;
  p += 5;
  p -= 2;
  p[3] = 20;
  int i;
  for (i = 0; i < 10; i++)
    printf("array[%d] = %d\n", i, array[i]);
  printf("----------------------\n");
  int *p1 = &array[2];
  int *p2 = &array[5];
  p1 += 2;
  p2 -= 1;
  if (p1 == p2) {
    printf("p1 == p2\n");
  } else
    printf("p1 <> p2\n");
  printf("%d\n", p2 - p1);
  return 0;
}


x86 assembly (clang, -O0):
<main04>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
lea    -0x190(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
lea    -0x190(%rbp),%rax
mov    %rax,-0x198(%rbp)
mov    -0x198(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x198(%rbp)
mov    -0x198(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %rax,-0x198(%rbp)
mov    -0x198(%rbp),%rax
movl   $0x14,0xc(%rax)
movl   $0x0,-0x19c(%rbp)
cmpl   $0xa,-0x19c(%rbp)
jge    11cb <main04+0xab>
mov    -0x19c(%rbp),%esi
movslq -0x19c(%rbp),%rax
mov    -0x190(%rbp,%rax,4),%edx
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x19c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x19c(%rbp)
jmp    1188 <main04+0x68>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x190(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x1a8(%rbp)
lea    -0x190(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x1a8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x1a8(%rbp)
mov    -0x1b0(%rbp),%rax
add    $0xfffffffffffffffc,%rax
mov    %rax,-0x1b0(%rbp)
mov    -0x1a8(%rbp),%rax
cmp    -0x1b0(%rbp),%rax
jne    1248 <main04+0x128>
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1256 <main04+0x136>
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1b0(%rbp),%rsi
mov    -0x1a8(%rbp),%rax
sub    %rax,%rsi
sar    $0x2,%rsi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main04>:
push   %rbx
lea    0xed8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x14,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe37(%rip),%rdi
call   1030 <puts@plt>
lea    0xe42(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1b(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"array[%d] = %d\0A\00"
@.str.1 = [24 x i8] c"----------------------\0A\00"
@.str.2 = [10 x i8] c"p1 == p2\0A\00"
@.str.3 = [10 x i8] c"p1 <> p2\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
define i32 @main04() {
%1 = alloca [100 x i32]
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = bitcast [100 x i32]* %1 to i8*
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i64 5
store i32* %9, i32** %2
%10 = load i32*, i32** %2
%11 = getelementptr inbounds i32, i32* %10, i64 -2
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = getelementptr inbounds i32, i32* %12, i64 3
store i32 20, i32* %13
store i32 0, i32* %3
br label %14
14: ; preds = %24, %0
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load i32, i32* %3
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %14
27: ; preds = %14
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 2
store i32* %29, i32** %4
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 5
store i32* %30, i32** %5
%31 = load i32*, i32** %4
%32 = getelementptr inbounds i32, i32* %31, i64 2
store i32* %32, i32** %4
%33 = load i32*, i32** %5
%34 = getelementptr inbounds i32, i32* %33, i64 -1
store i32* %34, i32** %5
%35 = load i32*, i32** %4
%36 = load i32*, i32** %5
%37 = icmp eq i32* %35, %36
br i1 %37, label %38, label %40
38: ; preds = %27
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %42
40: ; preds = %27
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %42
42: ; preds = %40, %38
%43 = load i32*, i32** %5
%44 = load i32*, i32** %4
%45 = ptrtoint i32* %43 to i64
%46 = ptrtoint i32* %44 to i64
%47 = sub i64 %45, %46
%48 = sdiv exact i64 %47, 4
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"array[%d] = %d\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [23 x i8] c"----------------------\00"
@str.5 = [9 x i8] c"p1 == p2\00"
define i32 @main04() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 0, i32 0)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 1, i32 0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 2, i32 0)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 3, i32 0)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 4, i32 0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 5, i32 0)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 6, i32 20)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 7, i32 0)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 8, i32 0)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 9, i32 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.5, i64 0, i64 0))
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64 0)
ret i32 0
}