#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 x = 0, y = 0, z = 0, s = 11, t = 12, u = 13, w = 7, err;
#pragma omp parallel
#pragma omp single
  {
#pragma omp task depend(in : x)
    {
      usleep(5000);
      x = 1;
    }
#pragma omp task depend(in : x)
    {
      usleep(6000);
      y = 2;
    }
#pragma omp task depend(out : z)
    {
      usleep(7000);
      z = 3;
    }
#pragma omp target map(tofrom                                                  \
                       : x) map(from                                           \
                                : err) firstprivate(y) depend(inout            \
                                                              : x, z)
    err = (x != 1 || y != 2 || z != 3);
    if (err)
      abort();
#pragma omp task depend(in : x)
    {
      usleep(5000);
      x = 4;
    }
#pragma omp task depend(in : x)
    {
      usleep(4000);
      y = 5;
    }
#pragma omp task depend(in : z)
    {
      usleep(3000);
      z = 6;
    }
#pragma omp target enter data nowait map(to : w)
#pragma omp target enter data depend(inout : x, z) map(to : x, y, z)
#pragma omp target map(alloc : x, y, z) map(from : err)
    {
      err = (x != 4 || y != 5 || z != 6);
      x = 7;
      y = 8;
      z = 9;
    }
    if (err)
      abort();
#pragma omp taskwait
#pragma omp target map(alloc : w) map(from : err)
    {
      err = w != 7;
      w = 17;
    }
    if (err)
      abort();
#pragma omp task depend(in : x)
    {
      usleep(2000);
      s = 14;
    }
#pragma omp task depend(in : x)
    {
      usleep(3000);
      t = 15;
    }
#pragma omp task depend(in : z)
    {
      usleep(4000);
      u = 16;
    }
#pragma omp target exit data depend(inout : x, z) map(from : x, y, z, w)
    if (x != 7 || y != 8 || z != 9 || s != 14 || t != 15 || u != 16 || w != 17)
      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   $0xb,-0x14(%rbp)
movl   $0xc,-0x18(%rbp)
movl   $0xd,-0x1c(%rbp)
movl   $0x7,-0x20(%rbp)
mov    $0x1388,%edi
call   1040 <usleep@plt>
movl   $0x1,-0x8(%rbp)
mov    $0x1770,%edi
call   1040 <usleep@plt>
movl   $0x2,-0xc(%rbp)
mov    $0x1b58,%edi
call   1040 <usleep@plt>
movl   $0x3,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x25(%rbp)
jne    11bb <main+0x9b>
mov    $0x1,%al
cmpl   $0x2,-0xc(%rbp)
mov    %al,-0x25(%rbp)
jne    11bb <main+0x9b>
cmpl   $0x3,-0x10(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11d7 <main+0xb7>
mov    $0x0,%al
call   1030 <abort@plt>
mov    $0x1388,%edi
call   1040 <usleep@plt>
movl   $0x4,-0x8(%rbp)
mov    $0xfa0,%edi
call   1040 <usleep@plt>
movl   $0x5,-0xc(%rbp)
mov    $0xbb8,%edi
call   1040 <usleep@plt>
movl   $0x6,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x4,-0x8(%rbp)
mov    %al,-0x26(%rbp)
jne    1232 <main+0x112>
mov    $0x1,%al
cmpl   $0x5,-0xc(%rbp)
mov    %al,-0x26(%rbp)
jne    1232 <main+0x112>
cmpl   $0x6,-0x10(%rbp)
setne  %al
mov    %al,-0x26(%rbp)
mov    -0x26(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
movl   $0x7,-0x8(%rbp)
movl   $0x8,-0xc(%rbp)
movl   $0x9,-0x10(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1263 <main+0x143>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x7,-0x20(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
movl   $0x11,-0x20(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     128a <main+0x16a>
mov    $0x0,%al
call   1030 <abort@plt>
mov    $0x7d0,%edi
call   1040 <usleep@plt>
movl   $0xe,-0x14(%rbp)
mov    $0xbb8,%edi
call   1040 <usleep@plt>
movl   $0xf,-0x18(%rbp)
mov    $0xfa0,%edi
call   1040 <usleep@plt>
movl   $0x10,-0x1c(%rbp)
cmpl   $0x7,-0x8(%rbp)
jne    1303 <main+0x1e3>
cmpl   $0x8,-0xc(%rbp)
jne    1303 <main+0x1e3>
cmpl   $0x9,-0x10(%rbp)
jne    1303 <main+0x1e3>
cmpl   $0xe,-0x14(%rbp)
jne    1303 <main+0x1e3>
cmpl   $0xf,-0x18(%rbp)
jne    1303 <main+0x1e3>
cmpl   $0x10,-0x1c(%rbp)
jne    1303 <main+0x1e3>
cmpl   $0x11,-0x20(%rbp)
je     130a <main+0x1ea>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1388,%edi
call   1030 <usleep@plt>
mov    $0x1770,%edi
call   1030 <usleep@plt>
mov    $0x1b58,%edi
call   1030 <usleep@plt>
mov    $0x1388,%edi
call   1030 <usleep@plt>
mov    $0xfa0,%edi
call   1030 <usleep@plt>
mov    $0xbb8,%edi
call   1030 <usleep@plt>
mov    $0x7d0,%edi
call   1030 <usleep@plt>
mov    $0xbb8,%edi
call   1030 <usleep@plt>
mov    $0xfa0,%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 i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 11, i32* %5
store i32 12, i32* %6
store i32 13, i32* %7
store i32 7, i32* %8
%10 = call i32 @usleep(i32 5000)
store i32 1, i32* %2
%11 = call i32 @usleep(i32 6000)
store i32 2, i32* %3
%12 = call i32 @usleep(i32 7000)
store i32 3, i32* %4
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 1
br i1 %14, label %21, label %15
15: ; preds = %0
%16 = load i32, i32* %3
%17 = icmp ne i32 %16, 2
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 3
br label %21
21: ; preds = %18, %15, %0
%22 = phi i1 [ true, %15 ], [ true, %0 ], [ %20, %18 ]
%23 = zext i1 %22 to i32
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %21
%29 = call i32 @usleep(i32 5000)
store i32 4, i32* %2
%30 = call i32 @usleep(i32 4000)
store i32 5, i32* %3
%31 = call i32 @usleep(i32 3000)
store i32 6, i32* %4
%32 = load i32, i32* %2
%33 = icmp ne i32 %32, 4
br i1 %33, label %40, label %34
34: ; preds = %28
%35 = load i32, i32* %3
%36 = icmp ne i32 %35, 5
br i1 %36, label %40, label %37
37: ; preds = %34
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 6
br label %40
40: ; preds = %37, %34, %28
%41 = phi i1 [ true, %34 ], [ true, %28 ], [ %39, %37 ]
%42 = zext i1 %41 to i32
store i32 %42, i32* %9
store i32 7, i32* %2
store i32 8, i32* %3
store i32 9, i32* %4
%43 = load i32, i32* %9
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 (...) @abort()
unreachable
47: ; preds = %40
%48 = load i32, i32* %8
%49 = icmp ne i32 %48, 7
%50 = zext i1 %49 to i32
store i32 %50, i32* %9
store i32 17, i32* %8
%51 = load i32, i32* %9
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %47
%54 = call i32 (...) @abort()
unreachable
55: ; preds = %47
%56 = call i32 @usleep(i32 2000)
store i32 14, i32* %5
%57 = call i32 @usleep(i32 3000)
store i32 15, i32* %6
%58 = call i32 @usleep(i32 4000)
store i32 16, i32* %7
%59 = load i32, i32* %2
%60 = icmp ne i32 %59, 7
br i1 %60, label %79, label %61
61: ; preds = %55
%62 = load i32, i32* %3
%63 = icmp ne i32 %62, 8
br i1 %63, label %79, label %64
64: ; preds = %61
%65 = load i32, i32* %4
%66 = icmp ne i32 %65, 9
br i1 %66, label %79, label %67
67: ; preds = %64
%68 = load i32, i32* %5
%69 = icmp ne i32 %68, 14
br i1 %69, label %79, label %70
70: ; preds = %67
%71 = load i32, i32* %6
%72 = icmp ne i32 %71, 15
br i1 %72, label %79, label %73
73: ; preds = %70
%74 = load i32, i32* %7
%75 = icmp ne i32 %74, 16
br i1 %75, label %79, label %76
76: ; preds = %73
%77 = load i32, i32* %8
%78 = icmp ne i32 %77, 17
br i1 %78, label %79, label %81
79: ; preds = %76, %73, %70, %67, %64, %61, %55
%80 = call i32 (...) @abort()
unreachable
81: ; preds = %76
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @usleep(i32 5000)
%2 = tail call i32 @usleep(i32 6000)
%3 = tail call i32 @usleep(i32 7000)
%4 = tail call i32 @usleep(i32 5000)
%5 = tail call i32 @usleep(i32 4000)
%6 = tail call i32 @usleep(i32 3000)
%7 = tail call i32 @usleep(i32 2000)
%8 = tail call i32 @usleep(i32 3000)
%9 = tail call i32 @usleep(i32 4000)
ret i32 0
}