#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 */
void place(void *bp, size_t size) {
  size_t block_size = ((*(unsigned int *)(((char *)(bp)-4))) & ~0x7);
  size_t reserve_size = block_size - size;
  int prev_alloc = ((*(unsigned int *)(((char *)(bp)-4))) & 0x2);
  char *next_block;
  size_t next_block_size;
  int next_alloc;
  if (reserve_size < 8) {
    (*(unsigned int *)(((char *)(bp)-4)) = (((block_size) | (prev_alloc | 1))));
    next_block =
        ((char *)(bp) + ((*(unsigned int *)(((char *)(bp)-4))) & ~0x7));
    next_block_size = ((*(unsigned int *)(((char *)(next_block)-4))) & ~0x7);
    next_alloc = ((*(unsigned int *)(((char *)(next_block)-4))) & 0x1);
    (*(unsigned int *)(((char *)(next_block)-4)) =
         (((next_block_size) | (next_alloc | 0x2))));
  } else if (8 <= reserve_size && reserve_size < block_size) {
    (*(unsigned int *)(((char *)(bp)-4)) = (((size) | (prev_alloc | 1))));
    next_block =
        ((char *)(bp) + ((*(unsigned int *)(((char *)(bp)-4))) & ~0x7));
    next_alloc = ((*(unsigned int *)(((char *)(next_block)-4))) & 0x1);
    (*(unsigned int *)(((char *)(next_block)-4)) =
         (((reserve_size) | (next_alloc | 0x2))));
    (*(unsigned int *)(((char *)(next_block) +
                        ((*(unsigned int *)(((char *)(next_block)-4))) & ~0x7) -
                        8)) = (((reserve_size) | (next_alloc | 0x2))));
  }
}


x86 assembly (clang, -O0):
<place>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0xfffffff8,%eax
mov    %eax,%eax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
sub    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0x2,%eax
mov    %eax,-0x24(%rbp)
cmpq   $0x8,-0x20(%rbp)
jae    11ab <place+0xab>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
or     $0x1,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,-0x4(%rax)
mov    -0x8(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x4(%rcx),%ecx
and    $0xfffffff8,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0xfffffff8,%eax
mov    %eax,%eax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x3c(%rbp),%ecx
or     $0x2,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,-0x4(%rax)
jmp    1249 <place+0x149>
mov    $0x8,%eax
cmp    -0x20(%rbp),%rax
ja     1244 <place+0x144>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1244 <place+0x144>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
or     $0x1,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,-0x4(%rax)
mov    -0x8(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x4(%rcx),%ecx
and    $0xfffffff8,%ecx
mov    %ecx,%ecx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x4(%rax),%eax
and    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x3c(%rbp),%ecx
or     $0x2,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,-0x4(%rax)
mov    -0x20(%rbp),%rax
mov    -0x3c(%rbp),%ecx
or     $0x2,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %eax,%edx
mov    -0x30(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    -0x4(%rcx),%ecx
and    $0xfffffff8,%ecx
mov    %ecx,%ecx
mov    %edx,-0x8(%rax,%rcx,1)
jmp    1249 <place+0x149>
pop    %rbp
ret

x86 assembly (clang, -O2):
<place>:
mov    -0x4(%rdi),%ecx
mov    %ecx,%edx
and    $0xfffffff8,%edx
mov    %rdx,%rax
sub    %rsi,%rax
cmp    $0x7,%rax
ja     112c <place+0x2c>
and    $0xfffffffa,%ecx
or     $0x1,%ecx
mov    %ecx,-0x4(%rdi)
mov    -0x4(%rdi,%rdx,1),%eax
and    $0xfffffff9,%eax
or     $0x2,%eax
mov    %eax,-0x4(%rdi,%rdx,1)
ret
cmp    %rdx,%rax
jae    115a <place+0x5a>
and    $0x2,%ecx
or     %esi,%ecx
or     $0x1,%ecx
mov    %ecx,-0x4(%rdi)
and    $0xfffffff8,%esi
lea    (%rdi,%rsi,1),%rcx
mov    -0x4(%rdi,%rsi,1),%edx
and    $0x1,%edx
or     %eax,%edx
or     $0x2,%edx
mov    %edx,-0x4(%rdi,%rsi,1)
and    $0xfffffff8,%eax
mov    %edx,-0x8(%rax,%rcx,1)
ret

LLVM IR (-O0):
define void @place(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 -4
%13 = bitcast i8* %12 to i32*
%14 = load i32, i32* %13
%15 = and i32 %14, -8
%16 = zext i32 %15 to i64
store i64 %16, i64* %5
%17 = load i64, i64* %5
%18 = load i64, i64* %4
%19 = sub i64 %17, %18
store i64 %19, i64* %6
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 -4
%22 = bitcast i8* %21 to i32*
%23 = load i32, i32* %22
%24 = and i32 %23, 2
store i32 %24, i32* %7
%25 = load i64, i64* %6
%26 = icmp ult i64 %25, 8
br i1 %26, label %27, label %65
27: ; preds = %2
%28 = load i64, i64* %5
%29 = load i32, i32* %7
%30 = or i32 %29, 1
%31 = sext i32 %30 to i64
%32 = or i64 %28, %31
%33 = trunc i64 %32 to i32
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i64 -4
%36 = bitcast i8* %35 to i32*
store i32 %33, i32* %36
%37 = load i8*, i8** %3
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 -4
%40 = bitcast i8* %39 to i32*
%41 = load i32, i32* %40
%42 = and i32 %41, -8
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %37, i64 %43
store i8* %44, i8** %8
%45 = load i8*, i8** %8
%46 = getelementptr inbounds i8, i8* %45, i64 -4
%47 = bitcast i8* %46 to i32*
%48 = load i32, i32* %47
%49 = and i32 %48, -8
%50 = zext i32 %49 to i64
store i64 %50, i64* %9
%51 = load i8*, i8** %8
%52 = getelementptr inbounds i8, i8* %51, i64 -4
%53 = bitcast i8* %52 to i32*
%54 = load i32, i32* %53
%55 = and i32 %54, 1
store i32 %55, i32* %10
%56 = load i64, i64* %9
%57 = load i32, i32* %10
%58 = or i32 %57, 2
%59 = sext i32 %58 to i64
%60 = or i64 %56, %59
%61 = trunc i64 %60 to i32
%62 = load i8*, i8** %8
%63 = getelementptr inbounds i8, i8* %62, i64 -4
%64 = bitcast i8* %63 to i32*
store i32 %61, i32* %64
br label %121
65: ; preds = %2
%66 = load i64, i64* %6
%67 = icmp ule i64 8, %66
br i1 %67, label %68, label %120
68: ; preds = %65
%69 = load i64, i64* %6
%70 = load i64, i64* %5
%71 = icmp ult i64 %69, %70
br i1 %71, label %72, label %120
72: ; preds = %68
%73 = load i64, i64* %4
%74 = load i32, i32* %7
%75 = or i32 %74, 1
%76 = sext i32 %75 to i64
%77 = or i64 %73, %76
%78 = trunc i64 %77 to i32
%79 = load i8*, i8** %3
%80 = getelementptr inbounds i8, i8* %79, i64 -4
%81 = bitcast i8* %80 to i32*
store i32 %78, i32* %81
%82 = load i8*, i8** %3
%83 = load i8*, i8** %3
%84 = getelementptr inbounds i8, i8* %83, i64 -4
%85 = bitcast i8* %84 to i32*
%86 = load i32, i32* %85
%87 = and i32 %86, -8
%88 = zext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %82, i64 %88
store i8* %89, i8** %8
%90 = load i8*, i8** %8
%91 = getelementptr inbounds i8, i8* %90, i64 -4
%92 = bitcast i8* %91 to i32*
%93 = load i32, i32* %92
%94 = and i32 %93, 1
store i32 %94, i32* %10
%95 = load i64, i64* %6
%96 = load i32, i32* %10
%97 = or i32 %96, 2
%98 = sext i32 %97 to i64
%99 = or i64 %95, %98
%100 = trunc i64 %99 to i32
%101 = load i8*, i8** %8
%102 = getelementptr inbounds i8, i8* %101, i64 -4
%103 = bitcast i8* %102 to i32*
store i32 %100, i32* %103
%104 = load i64, i64* %6
%105 = load i32, i32* %10
%106 = or i32 %105, 2
%107 = sext i32 %106 to i64
%108 = or i64 %104, %107
%109 = trunc i64 %108 to i32
%110 = load i8*, i8** %8
%111 = load i8*, i8** %8
%112 = getelementptr inbounds i8, i8* %111, i64 -4
%113 = bitcast i8* %112 to i32*
%114 = load i32, i32* %113
%115 = and i32 %114, -8
%116 = zext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %110, i64 %116
%118 = getelementptr inbounds i8, i8* %117, i64 -8
%119 = bitcast i8* %118 to i32*
store i32 %109, i32* %119
br label %120
120: ; preds = %72, %68, %65
br label %121
121: ; preds = %120, %27
ret void
}

LLVM IR (-O2):
define void @place(i8* nocapture %0, i64 %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 -4
%4 = bitcast i8* %3 to i32*
%5 = load i32, i32* %4
%6 = and i32 %5, -8
%7 = zext i32 %6 to i64
%8 = sub i64 %7, %1
%9 = and i32 %5, 2
%10 = icmp ult i64 %8, 8
br i1 %10, label %11, label %20
11: ; preds = %2
%12 = and i32 %5, -6
%13 = or i32 %12, 1
store i32 %13, i32* %4
%14 = getelementptr inbounds i8, i8* %0, i64 %7
%15 = getelementptr inbounds i8, i8* %14, i64 -4
%16 = bitcast i8* %15 to i32*
%17 = load i32, i32* %16
%18 = and i32 %17, -7
%19 = or i32 %18, 2
store i32 %19, i32* %16
br label %39
20: ; preds = %2
%21 = icmp ult i64 %8, %7
br i1 %21, label %22, label %39
22: ; preds = %20
%23 = trunc i64 %1 to i32
%24 = or i32 %9, %23
%25 = or i32 %24, 1
store i32 %25, i32* %4
%26 = and i64 %1, 4294967288
%27 = getelementptr inbounds i8, i8* %0, i64 %26
%28 = getelementptr inbounds i8, i8* %27, i64 -4
%29 = bitcast i8* %28 to i32*
%30 = load i32, i32* %29
%31 = and i32 %30, 1
%32 = trunc i64 %8 to i32
%33 = or i32 %31, %32
%34 = or i32 %33, 2
store i32 %34, i32* %29
%35 = and i64 %8, 4294967288
%36 = getelementptr inbounds i8, i8* %27, i64 %35
%37 = getelementptr inbounds i8, i8* %36, i64 -8
%38 = bitcast i8* %37 to i32*
store i32 %34, i32* %38
br label %39
39: ; preds = %20, %22, %11
ret void
}