#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_nested() {
  int X = 0, Y = 0, Z = 0;
#pragma omp target data map(from : X, Y, Z)
  {
#pragma omp target data map(from : X, Y, Z)
    {
#pragma omp target map(from : X, Y, Z)
      X = Y = Z = 1337;
      assert(X == 0);
      assert(Y == 0);
      assert(Z == 0);
#pragma omp target exit data map(from : X) map(release : Y)
      assert(X == 0);
      assert(Y == 0);
#pragma omp target exit data map(release : Y) map(delete : Z)
      assert(Y == 0);
      assert(Z == 0);
    }
    assert(X == 1337);
    assert(Y == 0);
    assert(Z == 0);
#pragma omp target map(from : X)
    X = 2448;
    assert(X == 2448);
    assert(Y == 0);
    assert(Z == 0);
    X = 4896;
  }
  assert(X == 4896);
  assert(Y == 0);
  assert(Z == 0);
}


x86 assembly (clang, -O0):
<test_nested>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x539,-0xc(%rbp)
movl   $0x539,-0x8(%rbp)
movl   $0x539,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x539,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x990,-0x4(%rbp)
cmpl   $0x990,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x1320,-0x4(%rbp)
cmpl   $0x1320,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_nested>:
push   %rax
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
call   1030 <assert@plt>
xor    %edi,%edi
pop    %rax
jmp    1030 <assert@plt>

LLVM IR (-O0):
define void @test_nested() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1337, i32* %3
store i32 1337, i32* %2
store i32 1337, i32* %1
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32, i32* %3
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i32, i32* %1
%33 = icmp eq i32 %32, 1337
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = load i32, i32* %2
%37 = icmp eq i32 %36, 0
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 0
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
store i32 2448, i32* %1
%44 = load i32, i32* %1
%45 = icmp eq i32 %44, 2448
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = load i32, i32* %2
%49 = icmp eq i32 %48, 0
%50 = zext i1 %49 to i32
%51 = call i32 @assert(i32 %50)
%52 = load i32, i32* %3
%53 = icmp eq i32 %52, 0
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
store i32 4896, i32* %1
%56 = load i32, i32* %1
%57 = icmp eq i32 %56, 4896
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = load i32, i32* %2
%61 = icmp eq i32 %60, 0
%62 = zext i1 %61 to i32
%63 = call i32 @assert(i32 %62)
%64 = load i32, i32* %3
%65 = icmp eq i32 %64, 0
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
ret void
}

LLVM IR (-O2):
define void @test_nested() {
%1 = tail call i32 @assert(i32 0)
%2 = tail call i32 @assert(i32 0)
%3 = tail call i32 @assert(i32 0)
%4 = tail call i32 @assert(i32 0)
%5 = tail call i32 @assert(i32 0)
%6 = tail call i32 @assert(i32 0)
%7 = tail call i32 @assert(i32 0)
%8 = tail call i32 @assert(i32 1)
%9 = tail call i32 @assert(i32 0)
%10 = tail call i32 @assert(i32 0)
%11 = tail call i32 @assert(i32 1)
%12 = tail call i32 @assert(i32 0)
%13 = tail call i32 @assert(i32 0)
%14 = tail call i32 @assert(i32 1)
%15 = tail call i32 @assert(i32 0)
%16 = tail call i32 @assert(i32 0)
ret void
}