#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 main() {
  char s1[] = {'H', 'e', 'l', 'l', 'o'};
  int i = 0;
  char s2[] = {'W', 'o', 'r', 'l', 'd'};
  char *p0 = s1;
  char *p1 = &s1[3];
  char *p2 = s2;
  int *p = &i;
  printf("%d\n", p0 - p1);
  printf("%d\n", p0 - p2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xedb(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xed6(%rip),%al
mov    %al,-0x5(%rbp)
movl   $0x0,-0x10(%rbp)
mov    0xec7(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xec2(%rip),%al
mov    %al,-0x11(%rbp)
lea    -0x9(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x9(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x28(%rbp)
lea    -0x15(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xe88(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movb   $0x6f,0xc(%rsp)
movl   $0x6c6c6548,0x8(%rsp)
6c
movb   $0x64,0x4(%rsp)
movl   $0x6c726f57,(%rsp)
lea    0xed5(%rip),%rbx
mov    %rbx,%rdi
mov    $0xfffffffd,%esi
call   1030 <printf@plt>
mov    %rsp,%rax
lea    0x8(%rsp),%rsi
sub    %eax,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.main.s1 = [5 x i8] c"Hello"
@__const.main.s2 = [5 x i8] c"World"
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = ptrtoint [5 x i8]* %1 to i64
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 -3)
%7 = ptrtoint [5 x i8]* %2 to i64
%8 = sub i64 %5, %7
%9 = trunc i64 %8 to i32
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
ret i32 0
}