#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*/ assert(int);
void test_array_section(int *p) {
#pragma omp target data map(alloc : p [0:N])
  {
    int ok = 1;
    for (int i = 10; i < 10 + 4; i++)
      p[i] = 997 * i;
#pragma omp target map(always to : p [10:4]) map(tofrom : ok)
    for (int i = 10; i < 10 + 4; i++)
      if (p[i] != 997 * i)
        ok = 0;
    assert(ok);
#pragma omp target map(always from : p [7:9])
    for (int i = 0; i < 32; i++)
      p[i] = i;
  }
}


x86 assembly (clang, -O0):
<test_array_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0xa,-0x10(%rbp)
cmpl   $0xe,-0x10(%rbp)
jge    1154 <test_array_section+0x44>
imul   $0x3e5,-0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <test_array_section+0x1a>
movl   $0xa,-0x14(%rbp)
cmpl   $0xe,-0x14(%rbp)
jge    1199 <test_array_section+0x89>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
imul   $0x3e5,-0x14(%rbp),%ecx
cmp    %ecx,%eax
je     1186 <test_array_section+0x76>
movl   $0x0,-0xc(%rbp)
jmp    118b <test_array_section+0x7b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <test_array_section+0x4b>
mov    -0xc(%rbp),%edi
call   1030 <assert@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x20,-0x18(%rbp)
jge    11ce <test_array_section+0xbe>
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a8 <test_array_section+0x98>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_array_section>:
push   %rbx
mov    %rdi,%rbx
movaps 0xee5(%rip),%xmm0
movups %xmm0,0x28(%rdi)
mov    $0x1,%edi
call   1030 <assert@plt>
movaps 0xee0(%rip),%xmm0
movups %xmm0,(%rbx)
movaps 0xee6(%rip),%xmm0
movups %xmm0,0x10(%rbx)
movaps 0xeeb(%rip),%xmm0
movups %xmm0,0x20(%rbx)
movaps 0xef0(%rip),%xmm0
movups %xmm0,0x30(%rbx)
movaps 0xef5(%rip),%xmm0
movups %xmm0,0x40(%rbx)
movaps 0xefa(%rip),%xmm0
movups %xmm0,0x50(%rbx)
movaps 0xeff(%rip),%xmm0
movups %xmm0,0x60(%rbx)
movaps 0xf04(%rip),%xmm0
movups %xmm0,0x70(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @test_array_section(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %2
store i32 1, i32* %3
store i32 10, i32* %4
br label %7
7: ; preds = %17, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 14
br i1 %9, label %10, label %20
10: ; preds = %7
%11 = load i32, i32* %4
%12 = mul nsw i32 997, %11
%13 = load i32*, i32** %2
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
store i32 %12, i32* %16
br label %17
17: ; preds = %10
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %7
20: ; preds = %7
store i32 10, i32* %5
br label %21
21: ; preds = %35, %20
%22 = load i32, i32* %5
%23 = icmp slt i32 %22, 14
br i1 %23, label %24, label %38
24: ; preds = %21
%25 = load i32*, i32** %2
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = load i32, i32* %5
%31 = mul nsw i32 997, %30
%32 = icmp ne i32 %29, %31
br i1 %32, label %33, label %34
33: ; preds = %24
store i32 0, i32* %3
br label %34
34: ; preds = %33, %24
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %21
38: ; preds = %21
%39 = load i32, i32* %3
%40 = call i32 @assert(i32 %39)
store i32 0, i32* %6
br label %41
41: ; preds = %50, %38
%42 = load i32, i32* %6
%43 = icmp slt i32 %42, 32
br i1 %43, label %44, label %53
44: ; preds = %41
%45 = load i32, i32* %6
%46 = load i32*, i32** %2
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %46, i64 %48
store i32 %45, i32* %49
br label %50
50: ; preds = %44
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
br label %41
53: ; preds = %41
ret void
}

LLVM IR (-O2):
define void @test_array_section(i32* nocapture %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 10
%3 = getelementptr inbounds i32, i32* %0, i64 12
%4 = bitcast i32* %2 to <4 x i32>*
store <4 x i32> <i32 9970, i32 10967, i32 11964, i32 12961>, <4 x i32>* %4
%5 = tail call i32 @assert(i32 1)
%6 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %0, i64 4
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %0, i64 8
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> <i32 8, i32 9, i32 10, i32 11>, <4 x i32>* %10
%11 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> <i32 12, i32 13, i32 14, i32 15>, <4 x i32>* %11
%12 = getelementptr inbounds i32, i32* %0, i64 16
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> <i32 16, i32 17, i32 18, i32 19>, <4 x i32>* %13
%14 = getelementptr inbounds i32, i32* %0, i64 20
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, <4 x i32>* %15
%16 = getelementptr inbounds i32, i32* %0, i64 24
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 24, i32 25, i32 26, i32 27>, <4 x i32>* %17
%18 = getelementptr inbounds i32, i32* %0, i64 28
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 28, i32 29, i32 30, i32 31>, <4 x i32>* %19
ret void
}