void pointer_op_test() {
  char *p1 = 0, *p2;
  short *p3 = 0, *p4;
  int *p5 = 0, *p6;
  p2 = p1 + 1;
  p4 = p3 + 1;
  p6 = p5 + 1;
  printf("p1=%.8x, p2=%.8x\n", p1, p2);
  printf("p3=%.8x, p4=%.8x\n", p3, p4);
  printf("p5=%.8x, p6=%.8x\n", p5, p6);
}


x86 assembly (clang, -O0):
<pointer_op_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pointer_op_test>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x1,%edx
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x2,%edx
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
mov    $0x4,%edx
xor    %esi,%esi
xor    %eax,%eax
pop    %rcx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"p1=%.8x, p2=%.8x\0A\00"
@.str.1 = [18 x i8] c"p3=%.8x, p4=%.8x\0A\00"
@.str.2 = [18 x i8] c"p5=%.8x, p6=%.8x\0A\00"
define void @pointer_op_test() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i16*
%4 = alloca i16*
%5 = alloca i32*
%6 = alloca i32*
store i8* null, i8** %1
store i16* null, i16** %3
store i32* null, i32** %5
%7 = load i8*, i8** %1
%8 = getelementptr inbounds i8, i8* %7, i64 1
store i8* %8, i8** %2
%9 = load i16*, i16** %3
%10 = getelementptr inbounds i16, i16* %9, i64 1
store i16* %10, i16** %4
%11 = load i32*, i32** %5
%12 = getelementptr inbounds i32, i32* %11, i64 1
store i32* %12, i32** %6
%13 = load i8*, i8** %1
%14 = load i8*, i8** %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14)
%16 = load i16*, i16** %3
%17 = load i16*, i16** %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i16* %16, i16* %17)
%19 = load i32*, i32** %5
%20 = load i32*, i32** %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32* %19, i32* %20)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"p1=%.8x, p2=%.8x\0A\00"
@.str.1 = [18 x i8] c"p3=%.8x, p4=%.8x\0A\00"
@.str.2 = [18 x i8] c"p5=%.8x, p6=%.8x\0A\00"
define void @pointer_op_test() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* null, i8* inttoptr (i64 1 to i8*))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i16* null, i16* inttoptr (i64 2 to i16*))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32* null, i32* inttoptr (i64 4 to i32*))
ret void
}