#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 */
typedef scalar_t__ bp;

/* Variables and functions */
int /*<<< orphan*/ checkheap(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, void *);
void printblock(void *bp) {
  size_t hsize, halloc, fsize, falloc;
  checkheap(0);
  hsize = ((*(unsigned int *)(((char *)(bp)-4))) & ~0x7);
  halloc = ((*(unsigned int *)(((char *)(bp)-4))) & 0x1);
  fsize = ((*(unsigned int *)(((char *)(bp) +
                               ((*(unsigned int *)(((char *)(bp)-4))) & ~0x7) -
                               8))) &
           ~0x7);
  falloc = ((*(unsigned int *)(((char *)(bp) +
                                ((*(unsigned int *)(((char *)(bp)-4))) & ~0x7) -
                                8))) &
            0x1);
  if (hsize == 0) {
    printf("%p: EOL\n", bp);
    return;
  }
}


x86 assembly (clang, -O0):
<printblock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
call   1040 <checkheap@plt>
mov    -0x8(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0xfffffff8,%eax
mov    %eax,%eax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0x1,%eax
mov    %eax,%eax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x4(%rcx),%ecx
and    $0xfffffff8,%ecx
mov    %ecx,%ecx
mov    -0x8(%rax,%rcx,1),%eax
and    $0xfffffff8,%eax
mov    %eax,%eax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x4(%rcx),%ecx
and    $0xfffffff8,%ecx
mov    %ecx,%ecx
mov    -0x8(%rax,%rcx,1),%eax
and    $0x1,%eax
mov    %eax,%eax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a8 <printblock+0x88>
mov    -0x8(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printblock>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <checkheap@plt>
cmpl   $0x7,-0x4(%rbx)
ja     1141 <printblock+0x21>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1030 <printf@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%p: EOL\0A\00"
define void @printblock(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %2
%7 = call i32 @checkheap(i32 0)
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 -4
%10 = bitcast i8* %9 to i32*
%11 = load i32, i32* %10
%12 = and i32 %11, -8
%13 = zext i32 %12 to i64
store i64 %13, i64* %3
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 -4
%16 = bitcast i8* %15 to i32*
%17 = load i32, i32* %16
%18 = and i32 %17, 1
%19 = zext i32 %18 to i64
store i64 %19, i64* %4
%20 = load i8*, i8** %2
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 -4
%23 = bitcast i8* %22 to i32*
%24 = load i32, i32* %23
%25 = and i32 %24, -8
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %20, i64 %26
%28 = getelementptr inbounds i8, i8* %27, i64 -8
%29 = bitcast i8* %28 to i32*
%30 = load i32, i32* %29
%31 = and i32 %30, -8
%32 = zext i32 %31 to i64
store i64 %32, i64* %5
%33 = load i8*, i8** %2
%34 = load i8*, i8** %2
%35 = getelementptr inbounds i8, i8* %34, i64 -4
%36 = bitcast i8* %35 to i32*
%37 = load i32, i32* %36
%38 = and i32 %37, -8
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %33, i64 %39
%41 = getelementptr inbounds i8, i8* %40, i64 -8
%42 = bitcast i8* %41 to i32*
%43 = load i32, i32* %42
%44 = and i32 %43, 1
%45 = zext i32 %44 to i64
store i64 %45, i64* %6
%46 = load i64, i64* %3
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %1
%49 = load i8*, i8** %2
%50 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %49)
br label %51
51: ; preds = %48, %1
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%p: EOL\0A\00"
define void @printblock(i8* %0) {
%2 = tail call i32 @checkheap(i32 0)
%3 = getelementptr inbounds i8, i8* %0, i64 -4
%4 = bitcast i8* %3 to i32*
%5 = load i32, i32* %4
%6 = icmp ult i32 %5, 8
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %1, %7
ret void
}