#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*/ foo(int *, int *);
int main() {
  int x = 1, y[8] = {2, 3, 4, 5, 6, 7, 8, 9}, i;
#pragma omp target data map(to : y [0:8]) map(to : x)
  ;
#pragma omp target data map(to : y [0:8]) map(to : x)
  {
#pragma omp target update from(y [0:8]) from(x)
  }
#pragma omp target data map(to : y [0:8]) map(to : x)
  foo(&x, &y[0]);
  if (x != 8)
    abort();
  for (i = 0; i < 8; i++)
    if (y[i] != 9 + i)
      abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    0xec3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x30(%rbp),%rsi
lea    -0x8(%rbp),%rdi
call   1040 <foo@plt>
cmpl   $0x8,-0x8(%rbp)
je     1180 <main+0x60>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    11c1 <main+0xa1>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    -0x34(%rbp),%ecx
add    $0x9,%ecx
cmp    %ecx,%eax
je     11ae <main+0x8e>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11b3 <main+0x93>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1187 <main+0x67>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movl   $0x1,0xc(%rsp)
movaps 0xefd(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movdqa 0xee0(%rip),%xmm0
movdqa %xmm0,0x10(%rsp)
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <foo@plt>
cmpl   $0x8,0xc(%rsp)
jne    1197 <main+0x77>
movdqa 0x10(%rsp),%xmm0
movdqa 0x20(%rsp),%xmm1
pcmpeqd 0xe90(%rip),%xmm1
pcmpeqd %xmm2,%xmm2
pxor   %xmm2,%xmm1
pcmpeqd 0xe90(%rip),%xmm0
pxor   %xmm2,%xmm0
packssdw %xmm1,%xmm0
pmovmskb %xmm0,%eax
test   %eax,%eax
jne    1197 <main+0x77>
xor    %eax,%eax
add    $0x38,%rsp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@__const.main.y = [8 x i32] [i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [8 x i32]
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%5 = bitcast [8 x i32]* %3 to i8*
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%7 = call i32 @foo(i32* %2, i32* %6)
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 8
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (...) @abort()
unreachable
12: ; preds = %0
store i32 0, i32* %4
br label %13
13: ; preds = %27, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 8
br i1 %15, label %16, label %30
16: ; preds = %13
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %4
%22 = add nsw i32 9, %21
%23 = icmp ne i32 %20, %22
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = call i32 (...) @abort()
unreachable
26: ; preds = %16
br label %27
27: ; preds = %26
%28 = load i32, i32* %4
%29 = add nsw i32 %28, 1
store i32 %29, i32* %4
br label %13
30: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@__const.main.y = [8 x i32] [i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9]
define i32 @main() {
%1 = alloca i32
%2 = alloca <8 x i32>
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast <8 x i32>* %2 to i8*
%5 = getelementptr inbounds <8 x i32>, <8 x i32>* %2, i64 0, i64 0
%6 = call i32 @foo(i32* %1, i32* %5)
%7 = load i32, i32* %1
%8 = icmp eq i32 %7, 8
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = load <8 x i32>, <8 x i32>* %2
%11 = freeze <8 x i32> %10
%12 = icmp ne <8 x i32> %11, <i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16>
%13 = bitcast <8 x i1> %12 to i8
%14 = icmp eq i8 %13, 0
br i1 %14, label %17, label %18
15: ; preds = %0
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %9
ret i32 0
18: ; preds = %9
%19 = call i32 (...) @abort()
unreachable
}