#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 */
scalar_t__ acc_deviceptr(float *);
int /*<<< orphan*/ acc_free(float *);
scalar_t__ acc_malloc(int);
int /*<<< orphan*/ acc_map_data(float *, float *, int);
int /*<<< orphan*/ acc_unmap_data(float *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(float *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int N = 8;
  float *a, *b, *c, *d;
  int i;
  a = (float *)malloc(N * sizeof(float));
  b = (float *)malloc(N * sizeof(float));
  c = (float *)malloc(N * sizeof(float));
  d = (float *)acc_malloc(N * sizeof(float));
  acc_map_data(c, d, N * sizeof(float));
  fprintf(stderr, "CheCKpOInT\n");
#pragma acc data present(a [0:N]) present(c [0:N]) present(b [0:N])
  {
#pragma acc parallel
    {
      int ii;
      for (ii = 0; ii < N; ii++) {
        c[ii] = a[ii];
        b[ii] = c[ii];
      }
    }
  }
  d = (float *)acc_deviceptr(c);
  acc_unmap_data(c);
  acc_free(d);
  free(a);
  free(b);
  free(c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x8,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <acc_malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1060 <acc_map_data@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xdf0(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    126a <main+0xea>
mov    -0x20(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x30(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    121c <main+0x9c>
mov    -0x30(%rbp),%rdi
call   1090 <acc_deviceptr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <acc_unmap_data@plt>
mov    -0x38(%rbp),%rdi
call   10a0 <acc_free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x20,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
mov    $0x20,%edi
call   1080 <malloc@plt>
mov    %rax,%r15
mov    $0x20,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    $0x20,%edi
call   1040 <acc_malloc@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x20,%edx
call   1060 <acc_map_data@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
call   1070 <fprintf@plt>
movss  (%r14),%xmm0
movss  %xmm0,(%rbx)
movss  %xmm0,(%r15)
movss  0x4(%r14),%xmm0
movss  %xmm0,0x4(%rbx)
movss  %xmm0,0x4(%r15)
movss  0x8(%r14),%xmm0
movss  %xmm0,0x8(%rbx)
movss  %xmm0,0x8(%r15)
movss  0xc(%r14),%xmm0
movss  %xmm0,0xc(%rbx)
movss  %xmm0,0xc(%r15)
movss  0x10(%r14),%xmm0
movss  %xmm0,0x10(%rbx)
movss  %xmm0,0x10(%r15)
movss  0x14(%r14),%xmm0
movss  %xmm0,0x14(%rbx)
movss  %xmm0,0x14(%r15)
movss  0x18(%r14),%xmm0
movss  %xmm0,0x18(%rbx)
movss  %xmm0,0x18(%r15)
movss  0x1c(%r14),%xmm0
movss  %xmm0,0x1c(%rbx)
movss  %xmm0,0x1c(%r15)
mov    %rbx,%rdi
call   1090 <acc_deviceptr@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1050 <acc_unmap_data@plt>
mov    %r12,%rdi
call   10a0 <acc_free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"CheCKpOInT\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 8, i32* %6
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 4
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to float*
store float* %18, float** %7
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 4
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to float*
store float* %24, float** %8
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 4
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to float*
store float* %30, float** %9
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = mul i64 %32, 4
%34 = trunc i64 %33 to i32
%35 = call i64 @acc_malloc(i32 %34)
%36 = inttoptr i64 %35 to float*
store float* %36, float** %10
%37 = load float*, float** %9
%38 = load float*, float** %10
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = mul i64 %40, 4
%42 = trunc i64 %41 to i32
%43 = call i32 @acc_map_data(float* %37, float* %38, i32 %42)
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %12
br label %46
46: ; preds = %69, %2
%47 = load i32, i32* %12
%48 = load i32, i32* %6
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %72
50: ; preds = %46
%51 = load float*, float** %7
%52 = load i32, i32* %12
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds float, float* %51, i64 %53
%55 = load float, float* %54
%56 = load float*, float** %9
%57 = load i32, i32* %12
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds float, float* %56, i64 %58
store float %55, float* %59
%60 = load float*, float** %9
%61 = load i32, i32* %12
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds float, float* %60, i64 %62
%64 = load float, float* %63
%65 = load float*, float** %8
%66 = load i32, i32* %12
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds float, float* %65, i64 %67
store float %64, float* %68
br label %69
69: ; preds = %50
%70 = load i32, i32* %12
%71 = add nsw i32 %70, 1
store i32 %71, i32* %12
br label %46
72: ; preds = %46
%73 = load float*, float** %9
%74 = call i64 @acc_deviceptr(float* %73)
%75 = inttoptr i64 %74 to float*
store float* %75, float** %10
%76 = load float*, float** %9
%77 = call i32 @acc_unmap_data(float* %76)
%78 = load float*, float** %10
%79 = call i32 @acc_free(float* %78)
%80 = load float*, float** %7
%81 = call i32 @free(float* %80)
%82 = load float*, float** %8
%83 = call i32 @free(float* %82)
%84 = load float*, float** %9
%85 = call i32 @free(float* %84)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"CheCKpOInT\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @malloc(i32 32)
%4 = inttoptr i64 %3 to float*
%5 = tail call i64 @malloc(i32 32)
%6 = inttoptr i64 %5 to float*
%7 = tail call i64 @malloc(i32 32)
%8 = inttoptr i64 %7 to float*
%9 = tail call i64 @acc_malloc(i32 32)
%10 = inttoptr i64 %9 to float*
%11 = tail call i32 @acc_map_data(float* %8, float* %10, i32 32)
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = load float, float* %4
store float %14, float* %8
store float %14, float* %6
%15 = getelementptr inbounds float, float* %4, i64 1
%16 = load float, float* %15
%17 = getelementptr inbounds float, float* %8, i64 1
store float %16, float* %17
%18 = getelementptr inbounds float, float* %6, i64 1
store float %16, float* %18
%19 = getelementptr inbounds float, float* %4, i64 2
%20 = load float, float* %19
%21 = getelementptr inbounds float, float* %8, i64 2
store float %20, float* %21
%22 = getelementptr inbounds float, float* %6, i64 2
store float %20, float* %22
%23 = getelementptr inbounds float, float* %4, i64 3
%24 = load float, float* %23
%25 = getelementptr inbounds float, float* %8, i64 3
store float %24, float* %25
%26 = getelementptr inbounds float, float* %6, i64 3
store float %24, float* %26
%27 = getelementptr inbounds float, float* %4, i64 4
%28 = load float, float* %27
%29 = getelementptr inbounds float, float* %8, i64 4
store float %28, float* %29
%30 = getelementptr inbounds float, float* %6, i64 4
store float %28, float* %30
%31 = getelementptr inbounds float, float* %4, i64 5
%32 = load float, float* %31
%33 = getelementptr inbounds float, float* %8, i64 5
store float %32, float* %33
%34 = getelementptr inbounds float, float* %6, i64 5
store float %32, float* %34
%35 = getelementptr inbounds float, float* %4, i64 6
%36 = load float, float* %35
%37 = getelementptr inbounds float, float* %8, i64 6
store float %36, float* %37
%38 = getelementptr inbounds float, float* %6, i64 6
store float %36, float* %38
%39 = getelementptr inbounds float, float* %4, i64 7
%40 = load float, float* %39
%41 = getelementptr inbounds float, float* %8, i64 7
store float %40, float* %41
%42 = getelementptr inbounds float, float* %6, i64 7
store float %40, float* %42
%43 = tail call i64 @acc_deviceptr(float* %8)
%44 = inttoptr i64 %43 to float*
%45 = tail call i32 @acc_unmap_data(float* %8)
%46 = tail call i32 @acc_free(float* %44)
%47 = tail call i32 @free(float* %4)
%48 = tail call i32 @free(float* %6)
%49 = tail call i32 @free(float* %8)
ret i32 0
}