#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 *, unsigned int, unsigned int, unsigned int,
                          unsigned int, ...);
void print_chunk(unsigned int *ptr) {
  int is_free = *((*(ptr - 1) & ~7) / 4 + (ptr - 1)) & 1;
  if (is_free) {
    printf("[ prev - 0x%08x ][ size - 0x%08x ][ data buffer (0x%08x) ----> ... "
           "] - Chunk 0x%08x - In use\n",
           *(ptr - 2), *(ptr - 1), (unsigned int)ptr, (unsigned int)(ptr - 2));
  } else {
    printf("[ prev - 0x%08x ][ size - 0x%08x ][ fd - 0x%08x ][ bk - 0x%08x ] - "
           "Chunk 0x%08x - Freed\n",
           *(ptr - 2), *(ptr - 1), *ptr, *(ptr + 1), (unsigned int)(ptr - 2));
  }
}


x86 assembly (clang, -O0):
<print_chunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x4(%rax),%ecx
and    $0xfffffff8,%ecx
shr    $0x2,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,%ecx
mov    -0x4(%rax,%rcx,4),%eax
and    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1175 <print_chunk+0x65>
mov    -0x8(%rbp),%rax
mov    -0x8(%rax),%esi
mov    -0x8(%rbp),%rax
mov    -0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %eax,%r8d
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <print_chunk+0x9a>
mov    -0x8(%rbp),%rax
mov    -0x8(%rax),%esi
mov    -0x8(%rbp),%rax
mov    -0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x8(%rbp),%rax
add    $0xfffffffffffffff8,%rax
mov    %eax,%r9d
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_chunk>:
mov    %rdi,%rax
mov    -0x8(%rdi),%esi
mov    -0x4(%rdi),%edx
mov    %edx,%ecx
and    $0xfffffff8,%ecx
lea    -0x8(%rdi),%r9
testb  $0x1,-0x4(%rdi,%rcx,1)
jne    113d <print_chunk+0x2d>
mov    (%rax),%ecx
mov    0x4(%rax),%r8d
lea    0xf28(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    %eax,%ecx
mov    %r9d,%r8d
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [94 x i8] c"[ prev - 0x%08x ][ size - 0x%08x ][ data buffer (0x%08x) ----> ... ] - Chunk 0x%08x - In use\0A\00"
@.str.1 = [89 x i8] c"[ prev - 0x%08x ][ size - 0x%08x ][ fd - 0x%08x ][ bk - 0x%08x ] - Chunk 0x%08x - Freed\0A\00"
define void @print_chunk(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = getelementptr inbounds i32, i32* %4, i64 -1
%6 = load i32, i32* %5
%7 = and i32 %6, -8
%8 = udiv i32 %7, 4
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i64 -1
%11 = zext i32 %8 to i64
%12 = getelementptr inbounds i32, i32* %10, i64 %11
%13 = load i32, i32* %12
%14 = and i32 %13, 1
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %1
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 -2
%20 = load i32, i32* %19
%21 = load i32*, i32** %2
%22 = getelementptr inbounds i32, i32* %21, i64 -1
%23 = load i32, i32* %22
%24 = load i32*, i32** %2
%25 = ptrtoint i32* %24 to i32
%26 = load i32*, i32** %2
%27 = getelementptr inbounds i32, i32* %26, i64 -2
%28 = ptrtoint i32* %27 to i32
%29 = call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %23, i32 %25, i32 %28)
br label %46
30: ; preds = %1
%31 = load i32*, i32** %2
%32 = getelementptr inbounds i32, i32* %31, i64 -2
%33 = load i32, i32* %32
%34 = load i32*, i32** %2
%35 = getelementptr inbounds i32, i32* %34, i64 -1
%36 = load i32, i32* %35
%37 = load i32*, i32** %2
%38 = load i32, i32* %37
%39 = load i32*, i32** %2
%40 = getelementptr inbounds i32, i32* %39, i64 1
%41 = load i32, i32* %40
%42 = load i32*, i32** %2
%43 = getelementptr inbounds i32, i32* %42, i64 -2
%44 = ptrtoint i32* %43 to i32
%45 = call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %36, i32 %38, i32 %41, i32 %44)
br label %46
46: ; preds = %30, %17
ret void
}

LLVM IR (-O2):
@.str = [94 x i8] c"[ prev - 0x%08x ][ size - 0x%08x ][ data buffer (0x%08x) ----> ... ] - Chunk 0x%08x - In use\0A\00"
@.str.1 = [89 x i8] c"[ prev - 0x%08x ][ size - 0x%08x ][ fd - 0x%08x ][ bk - 0x%08x ] - Chunk 0x%08x - Freed\0A\00"
define void @print_chunk(i32* %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 -1
%3 = load i32, i32* %2
%4 = lshr i32 %3, 2
%5 = and i32 %4, 1073741822
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds i32, i32* %2, i64 %6
%8 = load i32, i32* %7
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 0
%11 = getelementptr inbounds i32, i32* %0, i64 -2
%12 = load i32, i32* %11
br i1 %10, label %19, label %13
13: ; preds = %1
%14 = ptrtoint i32* %0 to i64
%15 = trunc i64 %14 to i32
%16 = ptrtoint i32* %11 to i64
%17 = trunc i64 %16 to i32
%18 = tail call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %3, i32 %15, i32 %17)
br label %26
19: ; preds = %1
%20 = load i32, i32* %0
%21 = getelementptr inbounds i32, i32* %0, i64 1
%22 = load i32, i32* %21
%23 = ptrtoint i32* %11 to i64
%24 = trunc i64 %23 to i32
%25 = tail call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %3, i32 %20, i32 %22, i32 %24)
br label %26
26: ; preds = %19, %13
ret void
}