#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*/ usleep(int);
int main() {
  int a = 0, b = 0, c = 0, d[7];
#pragma omp parallel
#pragma omp single
  {
#pragma omp task depend(out : d[0])
    a = 2;
#pragma omp target enter data nowait map(to                                    \
                                         : a, b, c) depend(in                  \
                                                           : d[0])             \
    depend(out                                                                 \
           : d[1])
#pragma omp target nowait map(alloc : a) depend(in : d[1]) depend(out : d[2])
    a++;
#pragma omp target nowait map(alloc : b) depend(in : d[2]) depend(out : d[3])
    {
      usleep(1000);
#pragma omp atomic update
      b |= 4;
    }
#pragma omp target nowait map(alloc : b) depend(in : d[2]) depend(out : d[4])
    {
      usleep(5000);
#pragma omp atomic update
      b |= 1;
    }
#pragma omp target nowait map(alloc                                            \
                              : c) depend(in                                   \
                                          : d[3], d[4]) depend(out             \
                                                               : d[5])
    {
      usleep(5000);
#pragma omp atomic update
      c |= 8;
    }
#pragma omp target nowait map(alloc                                            \
                              : c) depend(in                                   \
                                          : d[3], d[4]) depend(out             \
                                                               : d[6])
    {
      usleep(1000);
#pragma omp atomic update
      c |= 2;
    }
#pragma omp target exit data map(always, from : a, b, c) depend(in : d[5], d[6])
  }
  if (a != 3 || b != 5 || c != 10)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x3e8,%edi
call   1040 <usleep@plt>
mov    -0xc(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0xc(%rbp)
mov    $0x1388,%edi
call   1040 <usleep@plt>
mov    -0xc(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    $0x1388,%edi
call   1040 <usleep@plt>
mov    -0x10(%rbp),%eax
or     $0x8,%eax
mov    %eax,-0x10(%rbp)
mov    $0x3e8,%edi
call   1040 <usleep@plt>
mov    -0x10(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11be <main+0x9e>
cmpl   $0x5,-0xc(%rbp)
jne    11be <main+0x9e>
cmpl   $0xa,-0x10(%rbp)
je     11c5 <main+0xa5>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x3e8,%edi
call   1030 <usleep@plt>
mov    $0x1388,%edi
call   1030 <usleep@plt>
mov    $0x1388,%edi
call   1030 <usleep@plt>
mov    $0x3e8,%edi
call   1030 <usleep@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @usleep(i32 1000)
%2 = tail call i32 @usleep(i32 5000)
%3 = tail call i32 @usleep(i32 5000)
%4 = tail call i32 @usleep(i32 1000)
ret i32 0
}