#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 *, ...);
void check_pointer() {
  int length = 123;
  int *length_ptr;
  printf("length, value       %d\n", length);
  printf("length, address     %p\n", &length);
  length_ptr = &length;
  printf("length_ptr, value   %p\n", length_ptr);
  printf("length_ptr, value   %d\n", *length_ptr);
  printf("-------------------------\n");
  *length_ptr = 678;
  printf("length, value       %d\n", length);
  printf("length_ptr, value   %d\n", *length_ptr);
  printf("length_ptr, address %p\n", &length_ptr);
}


x86 assembly (clang, -O0):
<check_pointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x7b,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xedb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
movl   $0x2a6,(%rax)
mov    -0x4(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_pointer>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x7b,0xc(%rsp)
lea    0xeca(%rip),%r14
mov    %r14,%rdi
mov    $0x7b,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0xc(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,0x10(%rsp)
lea    0xec9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xecc(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeeb(%rip),%rdi
call   1030 <puts@plt>
movl   $0x2a6,0xc(%rsp)
mov    %r14,%rdi
mov    $0x2a6,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea2(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"length, value %d\0A\00"
@.str.1 = [24 x i8] c"length, address %p\0A\00"
@.str.2 = [24 x i8] c"length_ptr, value %p\0A\00"
@.str.3 = [24 x i8] c"length_ptr, value %d\0A\00"
@.str.4 = [27 x i8] c"-------------------------\0A\00"
@.str.5 = [24 x i8] c"length_ptr, address %p\0A\00"
define void @check_pointer() {
%1 = alloca i32
%2 = alloca i32*
store i32 123, i32* %1
%3 = load i32, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32* %1)
store i32* %1, i32** %2
%6 = load i32*, i32** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%8 = load i32*, i32** %2
%9 = load i32, i32* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%12 = load i32*, i32** %2
store i32 678, i32* %12
%13 = load i32, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32*, i32** %2
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32** %2)
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"length, value %d\0A\00"
@.str.1 = [24 x i8] c"length, address %p\0A\00"
@.str.2 = [24 x i8] c"length_ptr, value %p\0A\00"
@.str.3 = [24 x i8] c"length_ptr, value %d\0A\00"
@.str.5 = [24 x i8] c"length_ptr, address %p\0A\00"
@str = [26 x i8] c"-------------------------\00"
define void @check_pointer() {
%1 = alloca i32
%2 = alloca i32*
%3 = bitcast i32* %1 to i8*
store i32 123, i32* %1
%4 = bitcast i32** %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 123)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32* %1)
store i32* %1, i32** %2
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
store i32 678, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 678)
%12 = load i32, i32* %1
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32** %2)
ret void
}