#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_free(void *);
int acc_is_present(unsigned char *, int const);
void *acc_malloc(int const);
int /*<<< orphan*/ acc_map_data(unsigned char *, void *, int const);
int /*<<< orphan*/ acc_unmap_data(unsigned char *);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ malloc(int const);
int main(int argc, char **argv) {
  const int N = 256;
  unsigned char *h;
  void *d;
  h = (unsigned char *)malloc(N);
  d = acc_malloc(N);
  acc_map_data(h, d, N);
  if (acc_is_present(h, N) != 1)
    abort();
  acc_unmap_data(h);
  acc_free(d);
  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   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0x100,%edi
call   1050 <acc_malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x100,%edx
call   1070 <acc_map_data@plt>
mov    -0x20(%rbp),%rdi
mov    $0x100,%esi
call   1080 <acc_is_present@plt>
cmp    $0x1,%eax
je     11e9 <main+0x69>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x20(%rbp),%rdi
call   1060 <acc_unmap_data@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <acc_free@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   1090 <malloc@plt>
mov    %rax,%rbx
mov    $0x100,%edi
call   1050 <acc_malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x100,%edx
call   1070 <acc_map_data@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
call   1080 <acc_is_present@plt>
cmp    $0x1,%eax
jne    11e2 <main+0x62>
mov    %rbx,%rdi
call   1060 <acc_unmap_data@plt>
mov    %r14,%rdi
call   10a0 <acc_free@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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 256, i32* %6
%9 = call i64 @malloc(i32 256)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %7
%11 = call i8* @acc_malloc(i32 256)
store i8* %11, i8** %8
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = call i32 @acc_map_data(i8* %12, i8* %13, i32 256)
%15 = load i8*, i8** %7
%16 = call i32 @acc_is_present(i8* %15, i32 256)
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (...) @abort()
unreachable
20: ; preds = %2
%21 = load i8*, i8** %7
%22 = call i32 @acc_unmap_data(i8* %21)
%23 = load i8*, i8** %8
%24 = call i32 @acc_free(i8* %23)
%25 = load i8*, i8** %7
%26 = call i32 @free(i8* %25)
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_malloc(i32 256)
%6 = tail call i32 @acc_map_data(i8* %4, i8* %5, i32 256)
%7 = tail call i32 @acc_is_present(i8* %4, i32 256)
%8 = icmp eq i32 %7, 1
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i32 (...) @abort()
unreachable
11: ; preds = %2
%12 = tail call i32 @acc_unmap_data(i8* %4)
%13 = tail call i32 @acc_free(i8* %5)
%14 = tail call i32 @free(i8* %4)
ret i32 0
}