#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 main(void) {
  int a = 3;
  int b = 4;
  int *p1 = &a;
  int *p2 = &b;
  printf("%p,%d\n", p1, *p1);
  printf("%p,%d\n", p2, *p2);
  printf("%ld\n", p2 - p1);
  printf("%ld\n", p1 - p2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rax
sub    %rax,%rsi
sar    $0x2,%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rax
sub    %rax,%rsi
sar    $0x2,%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x3,0xc(%rsp)
movl   $0x4,0x8(%rsp)
lea    0xed0(%rip),%r14
lea    0xc(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rsi
sub    %rbx,%rsi
sar    $0x2,%rsi
lea    0xe98(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
sub    %r15,%rbx
sar    $0x2,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%p,%d\0A\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32 0, i32* %1
store i32 3, i32* %2
store i32 4, i32* %3
store i32* %2, i32** %4
store i32* %3, i32** %5
%6 = load i32*, i32** %4
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %6, i32 %8)
%10 = load i32*, i32** %5
%11 = load i32*, i32** %5
%12 = load i32, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %10, i32 %12)
%14 = load i32*, i32** %5
%15 = load i32*, i32** %4
%16 = ptrtoint i32* %14 to i64
%17 = ptrtoint i32* %15 to i64
%18 = sub i64 %16, %17
%19 = sdiv exact i64 %18, 4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %19)
%21 = load i32*, i32** %4
%22 = load i32*, i32** %5
%23 = ptrtoint i32* %21 to i64
%24 = ptrtoint i32* %22 to i64
%25 = sub i64 %23, %24
%26 = sdiv exact i64 %25, 4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%p,%d\0A\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 3, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 4, i32* %2
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %1, i32 3)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32* %2, i32 4)
%7 = ptrtoint i32* %2 to i64
%8 = ptrtoint i32* %1 to i64
%9 = sub i64 %7, %8
%10 = ashr exact i64 %9, 2
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%12 = sub i64 %8, %7
%13 = ashr exact i64 %12, 2
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %13)
ret i32 0
}