#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*/ fprintf(int /*<<< orphan*/, char *, unsigned int *,
                           unsigned int *, int);
int /*<<< orphan*/ stderr;
int sall_dump(unsigned *ptr) {
  int n = 0;
  while (ptr != 0) {
    fprintf(stderr, "%p - %p (%d)\n", ptr, (((unsigned **)ptr)[0]),
            (((unsigned **)ptr)[0]) - ptr);
    ptr = (((unsigned **)ptr)[1]);
    ++n;
  }
  return n;
}


x86 assembly (clang, -O0):
<sall_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     117d <sall_dump+0x6d>
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rsi
sub    %rsi,%rax
sar    $0x2,%rax
mov    %eax,%r8d
lea    0xea2(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <sall_dump+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sall_dump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1159 <sall_dump+0x49>
mov    %rdi,%rbx
xor    %ebp,%ebp
mov    0x2eb8(%rip),%r15
lea    0xed1(%rip),%r14
nop
mov    (%r15),%edi
mov    (%rbx),%rcx
mov    %rcx,%r8
sub    %rbx,%r8
shr    $0x2,%r8
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    0x8(%rbx),%rbx
add    $0x1,%ebp
test   %rbx,%rbx
jne    1130 <sall_dump+0x20>
jmp    115b <sall_dump+0x4b>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [14 x i8] c"%p - %p (%d)\0A\00"
define i32 @sall_dump(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
br label %4
4: ; preds = %7, %1
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
br i1 %6, label %7, label %31
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = load i32*, i32** %2
%10 = load i32*, i32** %2
%11 = bitcast i32* %10 to i32**
%12 = getelementptr inbounds i32*, i32** %11, i64 0
%13 = load i32*, i32** %12
%14 = load i32*, i32** %2
%15 = bitcast i32* %14 to i32**
%16 = getelementptr inbounds i32*, i32** %15, i64 0
%17 = load i32*, i32** %16
%18 = load i32*, i32** %2
%19 = ptrtoint i32* %17 to i64
%20 = ptrtoint i32* %18 to i64
%21 = sub i64 %19, %20
%22 = sdiv exact i64 %21, 4
%23 = trunc i64 %22 to i32
%24 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32* %9, i32* %13, i32 %23)
%25 = load i32*, i32** %2
%26 = bitcast i32* %25 to i32**
%27 = getelementptr inbounds i32*, i32** %26, i64 1
%28 = load i32*, i32** %27
store i32* %28, i32** %2
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %4
31: ; preds = %4
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [14 x i8] c"%p - %p (%d)\0A\00"
define i32 @sall_dump(i32* %0) {
%2 = icmp eq i32* %0, null
br i1 %2, label %20, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %18, %3 ], [ 0, %1 ]
%5 = phi i32* [ %17, %3 ], [ %0, %1 ]
%6 = load i32, i32* @stderr
%7 = bitcast i32* %5 to i32**
%8 = load i32*, i32** %7
%9 = ptrtoint i32* %8 to i64
%10 = ptrtoint i32* %5 to i64
%11 = sub i64 %9, %10
%12 = lshr exact i64 %11, 2
%13 = trunc i64 %12 to i32
%14 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %8, i32 %13)
%15 = getelementptr inbounds i32, i32* %5, i64 2
%16 = bitcast i32* %15 to i32**
%17 = load i32*, i32** %16
%18 = add nuw nsw i32 %4, 1
%19 = icmp eq i32* %17, null
br i1 %19, label %20, label %3
20: ; preds = %3, %1
%21 = phi i32 [ 0, %1 ], [ %18, %3 ]
ret i32 %21
}