#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*/ assert(int);
scalar_t__ bucket_start(unsigned int *const, int);
int /*<<< orphan*/ printf(char *, ...);
void printpointers(unsigned int **const buckets,
                   unsigned int *const bucket_storage) {
  int i;
  printf("Bucket pointers:\n");
  for (i = 0; i < (1 << 7); i++) {
    char *start = (char *)bucket_start(bucket_storage, i);
    char *end = (char *)(buckets[i]);
    printf("%p - %p, len = %zu\n", start, end, end - start);
    assert((size_t)(end - start) <
           ((size_t)1 << (27 - 7)) * sizeof(unsigned int));
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printpointers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x80,-0x14(%rbp)
jge    11cf <printpointers+0x9f>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <bucket_start@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
sub    %rax,%rcx
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x400000,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1155 <printpointers+0x25>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printpointers>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8e(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
call   1070 <bucket_start@plt>
mov    (%r12,%rbx,8),%rdx
mov    %rdx,%r13
sub    %rax,%r13
mov    %r15,%rdi
mov    %rax,%rsi
mov    %r13,%rcx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
cmp    $0x400000,%r13
setb   %dil
call   1060 <assert@plt>
add    $0x1,%rbx
cmp    $0x80,%rbx
jne    1180 <printpointers+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Bucket pointers:\0A\00"
@.str.1 = [20 x i8] c"%p - %p, len = %zu\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @printpointers(i32** %0, i32* %1) {
%3 = alloca i32**
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i32** %0, i32*** %3
store i32* %1, i32** %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %9
9: ; preds = %39, %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 128
br i1 %11, label %12, label %42
12: ; preds = %9
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = call i64 @bucket_start(i32* %13, i32 %14)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %6
%17 = load i32**, i32*** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32*, i32** %17, i64 %19
%21 = load i32*, i32** %20
%22 = bitcast i32* %21 to i8*
store i8* %22, i8** %7
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = load i8*, i8** %7
%26 = load i8*, i8** %6
%27 = ptrtoint i8* %25 to i64
%28 = ptrtoint i8* %26 to i64
%29 = sub i64 %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %24, i64 %29)
%31 = load i8*, i8** %7
%32 = load i8*, i8** %6
%33 = ptrtoint i8* %31 to i64
%34 = ptrtoint i8* %32 to i64
%35 = sub i64 %33, %34
%36 = icmp ult i64 %35, 4194304
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
br label %39
39: ; preds = %12
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %9
42: ; preds = %9
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"%p - %p, len = %zu\0A\00"
@str = [17 x i8] c"Bucket pointers:\00"
define void @printpointers(i32** nocapture %0, i32* %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %2, %4
%5 = phi i64 [ 0, %2 ], [ %18, %4 ]
%6 = trunc i64 %5 to i32
%7 = tail call i64 @bucket_start(i32* %1, i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = getelementptr inbounds i32*, i32** %0, i64 %5
%10 = bitcast i32** %9 to i8**
%11 = load i8*, i8** %10
%12 = ptrtoint i8* %11 to i64
%13 = sub i64 %12, %7
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %8, i8* %11, i64 %13)
%15 = icmp ult i64 %13, 4194304
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = add nuw nsw i64 %5, 1
%19 = icmp eq i64 %18, 128
br i1 %19, label %20, label %4
20: ; preds = %4
%21 = tail call i32 @putchar(i32 10)
ret void
}