#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*/ free(float *);
scalar_t__ malloc(int);
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));
#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   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <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>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1245 <main+0xd5>
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    11f7 <main+0x87>
mov    -0x30(%rbp),%rdi
call   1080 <acc_deviceptr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <acc_unmap_data@plt>
mov    -0x38(%rbp),%rdi
call   1090 <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   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x20,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    $0x20,%edi
call   1070 <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>
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   1080 <acc_deviceptr@plt>
mov    %rax,%r12
mov    %rbx,%rdi
call   1050 <acc_unmap_data@plt>
mov    %r12,%rdi
call   1090 <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):
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)
store i32 0, i32* %12
br label %44
44: ; preds = %67, %2
%45 = load i32, i32* %12
%46 = load i32, i32* %6
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %70
48: ; preds = %44
%49 = load float*, float** %7
%50 = load i32, i32* %12
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds float, float* %49, i64 %51
%53 = load float, float* %52
%54 = load float*, float** %9
%55 = load i32, i32* %12
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds float, float* %54, i64 %56
store float %53, float* %57
%58 = load float*, float** %9
%59 = load i32, i32* %12
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds float, float* %58, i64 %60
%62 = load float, float* %61
%63 = load float*, float** %8
%64 = load i32, i32* %12
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds float, float* %63, i64 %65
store float %62, float* %66
br label %67
67: ; preds = %48
%68 = load i32, i32* %12
%69 = add nsw i32 %68, 1
store i32 %69, i32* %12
br label %44
70: ; preds = %44
%71 = load float*, float** %9
%72 = call i64 @acc_deviceptr(float* %71)
%73 = inttoptr i64 %72 to float*
store float* %73, float** %10
%74 = load float*, float** %9
%75 = call i32 @acc_unmap_data(float* %74)
%76 = load float*, float** %10
%77 = call i32 @acc_free(float* %76)
%78 = load float*, float** %7
%79 = call i32 @free(float* %78)
%80 = load float*, float** %8
%81 = call i32 @free(float* %80)
%82 = load float*, float** %9
%83 = call i32 @free(float* %82)
ret i32 0
}

LLVM IR (-O2):
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 float, float* %4
store float %12, float* %8
store float %12, float* %6
%13 = getelementptr inbounds float, float* %4, i64 1
%14 = load float, float* %13
%15 = getelementptr inbounds float, float* %8, i64 1
store float %14, float* %15
%16 = getelementptr inbounds float, float* %6, i64 1
store float %14, float* %16
%17 = getelementptr inbounds float, float* %4, i64 2
%18 = load float, float* %17
%19 = getelementptr inbounds float, float* %8, i64 2
store float %18, float* %19
%20 = getelementptr inbounds float, float* %6, i64 2
store float %18, float* %20
%21 = getelementptr inbounds float, float* %4, i64 3
%22 = load float, float* %21
%23 = getelementptr inbounds float, float* %8, i64 3
store float %22, float* %23
%24 = getelementptr inbounds float, float* %6, i64 3
store float %22, float* %24
%25 = getelementptr inbounds float, float* %4, i64 4
%26 = load float, float* %25
%27 = getelementptr inbounds float, float* %8, i64 4
store float %26, float* %27
%28 = getelementptr inbounds float, float* %6, i64 4
store float %26, float* %28
%29 = getelementptr inbounds float, float* %4, i64 5
%30 = load float, float* %29
%31 = getelementptr inbounds float, float* %8, i64 5
store float %30, float* %31
%32 = getelementptr inbounds float, float* %6, i64 5
store float %30, float* %32
%33 = getelementptr inbounds float, float* %4, i64 6
%34 = load float, float* %33
%35 = getelementptr inbounds float, float* %8, i64 6
store float %34, float* %35
%36 = getelementptr inbounds float, float* %6, i64 6
store float %34, float* %36
%37 = getelementptr inbounds float, float* %4, i64 7
%38 = load float, float* %37
%39 = getelementptr inbounds float, float* %8, i64 7
store float %38, float* %39
%40 = getelementptr inbounds float, float* %6, i64 7
store float %38, float* %40
%41 = tail call i64 @acc_deviceptr(float* %8)
%42 = inttoptr i64 %41 to float*
%43 = tail call i32 @acc_unmap_data(float* %8)
%44 = tail call i32 @acc_free(float* %42)
%45 = tail call i32 @free(float* %4)
%46 = tail call i32 @free(float* %6)
%47 = tail call i32 @free(float* %8)
ret i32 0
}