#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*/ abort();
int /*<<< orphan*/ acc_delete(unsigned char *, int const);
void *acc_present_or_create(unsigned char *, int const);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ malloc(int const);
int main(int argc, char **argv) {
  const int N = 256;
  unsigned char *h;
  void *d1, *d2;
  h = (unsigned char *)malloc(N);
  d1 = acc_present_or_create(h, N);
  if (!d1)
    abort();
  d2 = acc_present_or_create(h, N - 2);
  if (!d2)
    abort();
  if (d1 != d2)
    abort();
  acc_delete(h, N);
  free(h);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x100,-0x14(%rbp)
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x100,%esi
call   1050 <acc_present_or_create@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    119f <main+0x4f>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x20(%rbp),%rdi
mov    $0xfe,%esi
call   1050 <acc_present_or_create@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11c3 <main+0x73>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
je     11d8 <main+0x88>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x20(%rbp),%rdi
mov    $0x100,%esi
call   1070 <acc_delete@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x100,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x100,%esi
call   1050 <acc_present_or_create@plt>
test   %rax,%rax
je     11ac <main+0x5c>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0xfe,%esi
call   1050 <acc_present_or_create@plt>
test   %rax,%rax
je     11ac <main+0x5c>
cmp    %rax,%r14
jne    11ac <main+0x5c>
mov    %rbx,%rdi
mov    $0x100,%esi
call   1070 <acc_delete@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 256, i32* %6
%10 = call i64 @malloc(i32 256)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = call i8* @acc_present_or_create(i8* %12, i32 256)
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = icmp ne i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %2
%19 = load i8*, i8** %7
%20 = call i8* @acc_present_or_create(i8* %19, i32 254)
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = icmp ne i8* %21, null
br i1 %22, label %25, label %23
23: ; preds = %18
%24 = call i32 (...) @abort()
unreachable
25: ; preds = %18
%26 = load i8*, i8** %8
%27 = load i8*, i8** %9
%28 = icmp ne i8* %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %25
%32 = load i8*, i8** %7
%33 = call i32 @acc_delete(i8* %32, i32 256)
%34 = load i8*, i8** %7
%35 = call i32 @free(i8* %34)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 256)
%4 = inttoptr i64 %3 to i8*
%5 = tail call i8* @acc_present_or_create(i8* %4, i32 256)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 (...) @abort()
unreachable
9: ; preds = %2
%10 = tail call i8* @acc_present_or_create(i8* %4, i32 254)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 (...) @abort()
unreachable
14: ; preds = %9
%15 = icmp eq i8* %5, %10
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = tail call i32 (...) @abort()
unreachable
18: ; preds = %14
%19 = tail call i32 @acc_delete(i8* %4, i32 256)
%20 = tail call i32 @free(i8* %4)
ret i32 0
}