#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__ next_block;
typedef scalar_t__ bp;

/* Variables and functions */
int /*<<< orphan*/ coalesce(void *);
void mm_free(void *bp) {
  size_t size;
  int prev_alloc = ((*(unsigned int *)(((char *)(bp)-4))) & 0x2);
  size = ((*(unsigned int *)(((char *)(bp)-4))) & ~0x7);
  (*(unsigned int *)(((char *)(bp)-4)) = (((size) | (prev_alloc))));
  (*(unsigned int *)(((char *)(bp) +
                      ((*(unsigned int *)(((char *)(bp)-4))) & ~0x7) - 8)) =
       (((size) | (prev_alloc))));
  char *next_block =
      ((char *)(bp) + ((*(unsigned int *)(((char *)(bp)-4))) & ~0x7));
  int next_alloc = ((*(unsigned int *)(((char *)(next_block)-4))) & 0x1);
  size = ((*(unsigned int *)(((char *)(next_block)-4))) & ~0x7);
  (*(unsigned int *)(((char *)(next_block)-4)) = (((size) | (next_alloc))));
  if (!next_alloc)
    (*(unsigned int *)(((char *)(next_block) +
                        ((*(unsigned int *)(((char *)(next_block)-4))) & ~0x7) -
                        8)) = (((size) | (next_alloc))));
  coalesce(bp);
}


x86 assembly (clang, -O0):
<mm_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0xfffffff8,%eax
mov    %eax,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
or     %rcx,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,-0x4(%rax)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
or     %rcx,%rax
mov    %eax,%edx
mov    -0x8(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x4(%rcx),%ecx
and    $0xfffffff8,%ecx
mov    %ecx,%ecx
mov    %edx,-0x8(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x4(%rcx),%ecx
and    $0xfffffff8,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0xfffffff8,%eax
mov    %eax,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
or     %rcx,%rax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,-0x4(%rax)
cmpl   $0x0,-0x24(%rbp)
jne    11e1 <mm_free+0xd1>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
or     %rcx,%rax
mov    %eax,%edx
mov    -0x20(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x4(%rcx),%ecx
and    $0xfffffff8,%ecx
mov    %ecx,%ecx
mov    %edx,-0x8(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1030 <coalesce@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mm_free>:
mov    -0x4(%rdi),%eax
mov    %eax,%ecx
and    $0xfffffffa,%ecx
mov    %ecx,-0x4(%rdi)
and    $0xfffffff8,%eax
mov    %ecx,-0x8(%rdi,%rax,1)
mov    -0x4(%rdi),%eax
and    $0xfffffff8,%eax
mov    -0x4(%rdi,%rax,1),%ecx
mov    %ecx,%edx
and    $0xfffffff9,%edx
mov    %edx,-0x4(%rdi,%rax,1)
test   $0x1,%cl
jne    1144 <mm_free+0x34>
add    %rdi,%rax
and    $0xfffffff8,%ecx
mov    %edx,-0x8(%rax,%rcx,1)
jmp    1030 <coalesce@plt>

LLVM IR (-O0):
define void @mm_free(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 -4
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = and i32 %10, 2
store i32 %11, i32* %4
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 -4
%14 = bitcast i8* %13 to i32*
%15 = load i32, i32* %14
%16 = and i32 %15, -8
%17 = zext i32 %16 to i64
store i64 %17, i64* %3
%18 = load i64, i64* %3
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = or i64 %18, %20
%22 = trunc i64 %21 to i32
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i64 -4
%25 = bitcast i8* %24 to i32*
store i32 %22, i32* %25
%26 = load i64, i64* %3
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = or i64 %26, %28
%30 = trunc i64 %29 to i32
%31 = load i8*, i8** %2
%32 = load i8*, i8** %2
%33 = getelementptr inbounds i8, i8* %32, i64 -4
%34 = bitcast i8* %33 to i32*
%35 = load i32, i32* %34
%36 = and i32 %35, -8
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %31, i64 %37
%39 = getelementptr inbounds i8, i8* %38, i64 -8
%40 = bitcast i8* %39 to i32*
store i32 %30, i32* %40
%41 = load i8*, i8** %2
%42 = load i8*, i8** %2
%43 = getelementptr inbounds i8, i8* %42, i64 -4
%44 = bitcast i8* %43 to i32*
%45 = load i32, i32* %44
%46 = and i32 %45, -8
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %41, i64 %47
store i8* %48, i8** %5
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i64 -4
%51 = bitcast i8* %50 to i32*
%52 = load i32, i32* %51
%53 = and i32 %52, 1
store i32 %53, i32* %6
%54 = load i8*, i8** %5
%55 = getelementptr inbounds i8, i8* %54, i64 -4
%56 = bitcast i8* %55 to i32*
%57 = load i32, i32* %56
%58 = and i32 %57, -8
%59 = zext i32 %58 to i64
store i64 %59, i64* %3
%60 = load i64, i64* %3
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = or i64 %60, %62
%64 = trunc i64 %63 to i32
%65 = load i8*, i8** %5
%66 = getelementptr inbounds i8, i8* %65, i64 -4
%67 = bitcast i8* %66 to i32*
store i32 %64, i32* %67
%68 = load i32, i32* %6
%69 = icmp ne i32 %68, 0
br i1 %69, label %86, label %70
70: ; preds = %1
%71 = load i64, i64* %3
%72 = load i32, i32* %6
%73 = sext i32 %72 to i64
%74 = or i64 %71, %73
%75 = trunc i64 %74 to i32
%76 = load i8*, i8** %5
%77 = load i8*, i8** %5
%78 = getelementptr inbounds i8, i8* %77, i64 -4
%79 = bitcast i8* %78 to i32*
%80 = load i32, i32* %79
%81 = and i32 %80, -8
%82 = zext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %76, i64 %82
%84 = getelementptr inbounds i8, i8* %83, i64 -8
%85 = bitcast i8* %84 to i32*
store i32 %75, i32* %85
br label %86
86: ; preds = %70, %1
%87 = load i8*, i8** %2
%88 = call i32 @coalesce(i8* %87)
ret void
}

LLVM IR (-O2):
define void @mm_free(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 -4
%3 = bitcast i8* %2 to i32*
%4 = load i32, i32* %3
%5 = and i32 %4, -6
store i32 %5, i32* %3
%6 = and i32 %4, -8
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = getelementptr inbounds i8, i8* %8, i64 -8
%10 = bitcast i8* %9 to i32*
store i32 %5, i32* %10
%11 = load i32, i32* %3
%12 = and i32 %11, -8
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%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 = and i32 %17, -7
store i32 %19, i32* %16
%20 = icmp eq i32 %18, 0
br i1 %20, label %21, label %27
21: ; preds = %1
%22 = and i32 %17, -8
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %14, i64 %23
%25 = getelementptr inbounds i8, i8* %24, i64 -8
%26 = bitcast i8* %25 to i32*
store i32 %19, i32* %26
br label %27
27: ; preds = %21, %1
%28 = tail call i32 @coalesce(i8* %0)
ret void
}