#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*/ acc_copyin(int *, int);
int /*<<< orphan*/ acc_copyout(int *, int);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int main() {
  int *p = (int *)malloc(sizeof(int));
#pragma acc enter data copyin(p [0:1])
#pragma acc parallel present(p [0:1]) num_gangs(1)
  { p[0] = 1; }
  acc_copyout(p, sizeof(int));
  assert(p[0] == 1);
  acc_copyin(p, sizeof(int));
#pragma acc parallel present(p [0:1]) num_gangs(1)
  { p[0] = 2; }
#pragma acc exit data copyout(p [0:1])
  assert(p[0] == 2);
  acc_copyin(p, sizeof(int));
#pragma acc parallel present(p [0:1]) num_gangs(1)
  { p[0] = 3; }
  acc_copyout(p, sizeof(int));
  assert(p[0] == 3);
#pragma acc enter data copyin(p [0:1])
#pragma acc parallel present(p [0:1]) num_gangs(1)
  { p[0] = 3; }
#pragma acc exit data copyout(p [0:1])
  assert(p[0] == 3);
  free(p);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1070 <acc_copyout@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <acc_copyin@plt>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x2,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <acc_copyin@plt>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1070 <acc_copyout@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x3,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x3,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movl   $0x1,(%rax)
mov    %rax,%rdi
mov    $0x4,%esi
call   1070 <acc_copyout@plt>
xor    %edi,%edi
cmpl   $0x1,(%rbx)
sete   %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <acc_copyin@plt>
movl   $0x2,(%rbx)
mov    $0x1,%edi
call   1050 <assert@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <acc_copyin@plt>
movl   $0x3,(%rbx)
mov    %rbx,%rdi
mov    $0x4,%esi
call   1070 <acc_copyout@plt>
xor    %edi,%edi
cmpl   $0x3,(%rbx)
sete   %dil
call   1050 <assert@plt>
movl   $0x3,(%rbx)
mov    $0x1,%edi
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i64 @malloc(i32 4)
%4 = inttoptr i64 %3 to i32*
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = getelementptr inbounds i32, i32* %5, i64 0
store i32 1, i32* %6
%7 = load i32*, i32** %2
%8 = call i32 @acc_copyout(i32* %7, i32 4)
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i64 0
%11 = load i32, i32* %10
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32*, i32** %2
%16 = call i32 @acc_copyin(i32* %15, i32 4)
%17 = load i32*, i32** %2
%18 = getelementptr inbounds i32, i32* %17, i64 0
store i32 2, i32* %18
%19 = load i32*, i32** %2
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 2
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32*, i32** %2
%26 = call i32 @acc_copyin(i32* %25, i32 4)
%27 = load i32*, i32** %2
%28 = getelementptr inbounds i32, i32* %27, i64 0
store i32 3, i32* %28
%29 = load i32*, i32** %2
%30 = call i32 @acc_copyout(i32* %29, i32 4)
%31 = load i32*, i32** %2
%32 = getelementptr inbounds i32, i32* %31, i64 0
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 3
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i32*, i32** %2
%38 = getelementptr inbounds i32, i32* %37, i64 0
store i32 3, i32* %38
%39 = load i32*, i32** %2
%40 = getelementptr inbounds i32, i32* %39, i64 0
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, 3
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i32*, i32** %2
%46 = call i32 @free(i32* %45)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @malloc(i32 4)
%2 = inttoptr i64 %1 to i32*
store i32 1, i32* %2
%3 = tail call i32 @acc_copyout(i32* %2, i32 4)
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 1
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @acc_copyin(i32* %2, i32 4)
store i32 2, i32* %2
%9 = tail call i32 @assert(i32 1)
%10 = tail call i32 @acc_copyin(i32* %2, i32 4)
store i32 3, i32* %2
%11 = tail call i32 @acc_copyout(i32* %2, i32 4)
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 3
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
store i32 3, i32* %2
%16 = tail call i32 @assert(i32 1)
%17 = tail call i32 @free(i32* %2)
ret i32 0
}