#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;
  int i;
  unsigned char *h[N];
  void *d[N];
  for (i = 0; i < N; i++) {
    h[i] = (unsigned char *)malloc(N);
    d[i] = acc_malloc(N);
    acc_map_data(h[i], d[i], N);
  }
  for (i = 0; i < N; i++) {
    if (acc_is_present(h[i], N) != 1)
      abort();
  }
  for (i = 0; i < N; i++) {
    acc_unmap_data(h[i]);
    if (acc_is_present(h[i], N) != 0)
      abort();
    acc_free(d[i]);
    free(h[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x100,-0x14(%rbp)
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x100,-0x18(%rbp)
jge    121d <main+0x9d>
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
mov    %rcx,-0x820(%rbp,%rax,8)
ff
mov    $0x100,%edi
call   1050 <acc_malloc@plt>
mov    %rax,%rcx
movslq -0x18(%rbp),%rax
mov    %rcx,-0x1020(%rbp,%rax,8)
ff
movslq -0x18(%rbp),%rax
mov    -0x820(%rbp,%rax,8),%rdi
ff
movslq -0x18(%rbp),%rax
mov    -0x1020(%rbp,%rax,8),%rsi
ff
mov    $0x100,%edx
call   1070 <acc_map_data@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ae <main+0x2e>
movl   $0x0,-0x18(%rbp)
cmpl   $0x100,-0x18(%rbp)
jge    126a <main+0xea>
movslq -0x18(%rbp),%rax
mov    -0x820(%rbp,%rax,8),%rdi
ff
mov    $0x100,%esi
call   1080 <acc_is_present@plt>
cmp    $0x1,%eax
je     1257 <main+0xd7>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    125c <main+0xdc>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1224 <main+0xa4>
movl   $0x0,-0x18(%rbp)
cmpl   $0x100,-0x18(%rbp)
jge    12e5 <main+0x165>
movslq -0x18(%rbp),%rax
mov    -0x820(%rbp,%rax,8),%rdi
ff
call   1060 <acc_unmap_data@plt>
movslq -0x18(%rbp),%rax
mov    -0x820(%rbp,%rax,8),%rdi
ff
mov    $0x100,%esi
call   1080 <acc_is_present@plt>
cmp    $0x0,%eax
je     12b5 <main+0x135>
mov    $0x0,%al
call   1040 <abort@plt>
movslq -0x18(%rbp),%rax
mov    -0x1020(%rbp,%rax,8),%rdi
ff
call   10a0 <acc_free@plt>
movslq -0x18(%rbp),%rax
mov    -0x820(%rbp,%rax,8),%rdi
ff
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1271 <main+0xf1>
movl   $0x0,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1008,%rsp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    %rax,(%rsp,%rbx,8)
mov    $0x100,%edi
call   1050 <acc_malloc@plt>
mov    %rax,0x800(%rsp,%rbx,8)
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x100,%edx
call   1070 <acc_map_data@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1190 <main+0x10>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp,%rbx,8),%rdi
mov    $0x100,%esi
call   1080 <acc_is_present@plt>
cmp    $0x1,%eax
jne    125c <main+0xdc>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    11e0 <main+0x60>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rsp,%rbx,8),%r14
mov    %r14,%rdi
call   1060 <acc_unmap_data@plt>
mov    %r14,%rdi
mov    $0x100,%esi
call   1080 <acc_is_present@plt>
test   %eax,%eax
jne    125c <main+0xdc>
mov    0x800(%rsp,%rbx,8),%rdi
call   10a0 <acc_free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1210 <main+0x90>
xor    %eax,%eax
add    $0x1008,%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 i32
%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 i8* @llvm.stacksave()
store i8* %9, i8** %8
%10 = alloca i8*, i64 256
%11 = alloca i8*, i64 256
store i32 0, i32* %7
br label %12
12: ; preds = %34, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 256
br i1 %14, label %15, label %37
15: ; preds = %12
%16 = call i64 @malloc(i32 256)
%17 = inttoptr i64 %16 to i8*
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %10, i64 %19
store i8* %17, i8** %20
%21 = call i8* @acc_malloc(i32 256)
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %11, i64 %23
store i8* %21, i8** %24
%25 = load i32, i32* %7
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %10, i64 %26
%28 = load i8*, i8** %27
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %11, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @acc_map_data(i8* %28, i8* %32, i32 256)
br label %34
34: ; preds = %15
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %12
37: ; preds = %12
store i32 0, i32* %7
br label %38
38: ; preds = %51, %37
%39 = load i32, i32* %7
%40 = icmp slt i32 %39, 256
br i1 %40, label %41, label %54
41: ; preds = %38
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8*, i8** %10, i64 %43
%45 = load i8*, i8** %44
%46 = call i32 @acc_is_present(i8* %45, i32 256)
%47 = icmp ne i32 %46, 1
br i1 %47, label %48, label %50
48: ; preds = %41
%49 = call i32 (...) @abort()
unreachable
50: ; preds = %41
br label %51
51: ; preds = %50
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
br label %38
54: ; preds = %38
store i32 0, i32* %7
br label %55
55: ; preds = %83, %54
%56 = load i32, i32* %7
%57 = icmp slt i32 %56, 256
br i1 %57, label %58, label %86
58: ; preds = %55
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %10, i64 %60
%62 = load i8*, i8** %61
%63 = call i32 @acc_unmap_data(i8* %62)
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %10, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 @acc_is_present(i8* %67, i32 256)
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %58
%71 = call i32 (...) @abort()
unreachable
72: ; preds = %58
%73 = load i32, i32* %7
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %11, i64 %74
%76 = load i8*, i8** %75
%77 = call i32 @acc_free(i8* %76)
%78 = load i32, i32* %7
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %10, i64 %79
%81 = load i8*, i8** %80
%82 = call i32 @free(i8* %81)
br label %83
83: ; preds = %72
%84 = load i32, i32* %7
%85 = add nsw i32 %84, 1
store i32 %85, i32* %7
br label %55
86: ; preds = %55
store i32 0, i32* %3
%87 = load i8*, i8** %8
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i8*]
%4 = alloca [256 x i8*]
br label %5
5: ; preds = %2, %5
%6 = phi i64 [ 0, %2 ], [ %13, %5 ]
%7 = tail call i64 @malloc(i32 256)
%8 = inttoptr i64 %7 to i8*
%9 = getelementptr inbounds [256 x i8*], [256 x i8*]* %3, i64 0, i64 %6
store i8* %8, i8** %9
%10 = tail call i8* @acc_malloc(i32 256)
%11 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 %6
store i8* %10, i8** %11
%12 = tail call i32 @acc_map_data(i8* %8, i8* %10, i32 256)
%13 = add nuw nsw i64 %6, 1
%14 = icmp eq i64 %13, 256
br i1 %14, label %18, label %5
15: ; preds = %18
%16 = add nuw nsw i64 %19, 1
%17 = icmp eq i64 %16, 256
br i1 %17, label %26, label %18
18: ; preds = %5, %15
%19 = phi i64 [ %16, %15 ], [ 0, %5 ]
%20 = getelementptr inbounds [256 x i8*], [256 x i8*]* %3, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = tail call i32 @acc_is_present(i8* %21, i32 256)
%23 = icmp eq i32 %22, 1
br i1 %23, label %15, label %24
24: ; preds = %18
%25 = tail call i32 (...) @abort()
unreachable
26: ; preds = %15, %35
%27 = phi i64 [ %40, %35 ], [ 0, %15 ]
%28 = getelementptr inbounds [256 x i8*], [256 x i8*]* %3, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = tail call i32 @acc_unmap_data(i8* %29)
%31 = tail call i32 @acc_is_present(i8* %29, i32 256)
%32 = icmp eq i32 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %26
%34 = tail call i32 (...) @abort()
unreachable
35: ; preds = %26
%36 = getelementptr inbounds [256 x i8*], [256 x i8*]* %4, i64 0, i64 %27
%37 = load i8*, i8** %36
%38 = tail call i32 @acc_free(i8* %37)
%39 = tail call i32 @free(i8* %29)
%40 = add nuw nsw i64 %27, 1
%41 = icmp eq i64 %40, 256
br i1 %41, label %42, label %26
42: ; preds = %35
ret i32 0
}