#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 omp_is_initial_device();
int main() {
  int a = 100;
  int b = 0;
  int c, d;
#pragma omp target if (a > 200 && a < 400)
  c = omp_is_initial_device();
#pragma omp target data map(to : b) if (a > 200 && a < 400)
#pragma omp target
  {
    b = 100;
    d = omp_is_initial_device();
  }
  if (b != 100 || !c || d)
    abort();
  a += 200;
  b = 0;
#pragma omp target if (a > 200 && a < 400)
  c = omp_is_initial_device();
#pragma omp target data map(to : b) if (a > 200 && a < 400)
#pragma omp target
  {
    b = 100;
    d = omp_is_initial_device();
  }
  if (b != 0 || c || d)
    abort();
  a += 200;
  b = 0;
#pragma omp target if (a > 200 && a < 400)
  c = omp_is_initial_device();
#pragma omp target data map(to : b) if (a > 200 && a < 400)
#pragma omp target
  {
    b = 100;
    d = omp_is_initial_device();
  }
  if (b != 100 || !c || d)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x64,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <omp_is_initial_device@plt>
mov    %eax,-0x10(%rbp)
movl   $0x64,-0xc(%rbp)
mov    $0x0,%al
call   1040 <omp_is_initial_device@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x64,-0xc(%rbp)
jne    1176 <main+0x56>
cmpl   $0x0,-0x10(%rbp)
je     1176 <main+0x56>
cmpl   $0x0,-0x14(%rbp)
je     117d <main+0x5d>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%eax
add    $0xc8,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <omp_is_initial_device@plt>
mov    %eax,-0x10(%rbp)
movl   $0x64,-0xc(%rbp)
mov    $0x0,%al
call   1040 <omp_is_initial_device@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11c8 <main+0xa8>
cmpl   $0x0,-0x10(%rbp)
jne    11c8 <main+0xa8>
cmpl   $0x0,-0x14(%rbp)
je     11cf <main+0xaf>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%eax
add    $0xc8,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <omp_is_initial_device@plt>
mov    %eax,-0x10(%rbp)
movl   $0x64,-0xc(%rbp)
mov    $0x0,%al
call   1040 <omp_is_initial_device@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x64,-0xc(%rbp)
jne    121a <main+0xfa>
cmpl   $0x0,-0x10(%rbp)
je     121a <main+0xfa>
cmpl   $0x0,-0x14(%rbp)
je     1221 <main+0x101>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <omp_is_initial_device@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <omp_is_initial_device@plt>
test   %ebx,%ebx
je     1147 <main+0x27>
test   %eax,%eax
jne    1147 <main+0x27>
xor    %eax,%eax
call   1040 <omp_is_initial_device@plt>
xor    %eax,%eax
call   1040 <omp_is_initial_device@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 100, i32* %2
store i32 0, i32* %3
%6 = call i32 (...) @omp_is_initial_device()
store i32 %6, i32* %4
store i32 100, i32* %3
%7 = call i32 (...) @omp_is_initial_device()
store i32 %7, i32* %5
%8 = load i32, i32* %3
%9 = icmp ne i32 %8, 100
br i1 %9, label %16, label %10
10: ; preds = %0
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13, %10, %0
%17 = call i32 (...) @abort()
unreachable
18: ; preds = %13
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 200
store i32 %20, i32* %2
store i32 0, i32* %3
%21 = call i32 (...) @omp_is_initial_device()
store i32 %21, i32* %4
store i32 100, i32* %3
%22 = call i32 (...) @omp_is_initial_device()
store i32 %22, i32* %5
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %18
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28, %25, %18
%32 = call i32 (...) @abort()
unreachable
33: ; preds = %28
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 200
store i32 %35, i32* %2
store i32 0, i32* %3
%36 = call i32 (...) @omp_is_initial_device()
store i32 %36, i32* %4
store i32 100, i32* %3
%37 = call i32 (...) @omp_is_initial_device()
store i32 %37, i32* %5
%38 = load i32, i32* %3
%39 = icmp ne i32 %38, 100
br i1 %39, label %46, label %40
40: ; preds = %33
%41 = load i32, i32* %4
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32, i32* %5
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43, %40, %33
%47 = call i32 (...) @abort()
unreachable
48: ; preds = %43
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @omp_is_initial_device()
%2 = tail call i32 (...) @omp_is_initial_device()
%3 = icmp eq i32 %1, 0
%4 = icmp ne i32 %2, 0
%5 = select i1 %3, i1 true, i1 %4
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 (...) @abort()
unreachable
8: ; preds = %0
%9 = tail call i32 (...) @omp_is_initial_device()
%10 = tail call i32 (...) @omp_is_initial_device()
%11 = tail call i32 (...) @abort()
unreachable
}