#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_get_num_devices();
int omp_is_initial_device();
int main() {
  int i;
  int offload[10];
  int num = omp_get_num_devices();
#pragma omp parallel for
  for (i = 0; i < 10; i++)
#pragma omp target device(i) map(from : offload [i:1])
    offload[i] = omp_is_initial_device();
  for (i = 0; i < num; i++)
    if (offload[i])
      abort();
  for (i = num; i < 10; i++)
    if (!offload[i])
      abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <omp_get_num_devices@plt>
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1179 <main+0x49>
mov    $0x0,%al
call   1050 <omp_is_initial_device@plt>
mov    %eax,%ecx
movslq -0x8(%rbp),%rax
mov    %ecx,-0x30(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1150 <main+0x20>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    11b5 <main+0x85>
movslq -0x8(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
je     11a2 <main+0x72>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11a7 <main+0x77>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x50>
mov    -0x34(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11ee <main+0xbe>
movslq -0x8(%rbp),%rax
cmpl   $0x0,-0x30(%rbp,%rax,4)
jne    11db <main+0xab>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11e0 <main+0xb0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11bb <main+0x8b>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   1040 <omp_get_num_devices@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,%ebp
mov    %eax,(%rsp)
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,0x8(%rsp)
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,0x10(%rsp)
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,0x14(%rsp)
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,0x18(%rsp)
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,0x1c(%rsp)
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,0x20(%rsp)
xor    %eax,%eax
call   1050 <omp_is_initial_device@plt>
mov    %eax,0x24(%rsp)
test   %ebx,%ebx
jle    11db <main+0xab>
test   %ebp,%ebp
jne    11cf <main+0x9f>
mov    %ebx,%eax
mov    $0x1,%ecx
nopl   (%rax)
cmp    %rcx,%rax
je     11d6 <main+0xa6>
cmpl   $0x0,(%rsp,%rcx,4)
lea    0x1(%rcx),%rcx
je     11c0 <main+0x90>
xor    %eax,%eax
call   1030 <abort@plt>
cmp    $0x9,%ebx
jg     11fe <main+0xce>
movslq %ebx,%rax
lea    (%rsp,%rax,4),%rax
mov    $0xa,%ecx
sub    %ebx,%ecx
xor    %edx,%edx
nopl   0x0(%rax,%rax,1)
cmpl   $0x0,(%rax,%rdx,4)
je     11cf <main+0x9f>
add    $0x1,%rdx
cmp    %edx,%ecx
jne    11f0 <main+0xc0>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 (...) @omp_get_num_devices()
%4 = tail call i32 (...) @omp_is_initial_device()
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
store i32 %4, i32* %5
%6 = tail call i32 (...) @omp_is_initial_device()
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
store i32 %6, i32* %7
%8 = tail call i32 (...) @omp_is_initial_device()
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
store i32 %8, i32* %9
%10 = tail call i32 (...) @omp_is_initial_device()
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
store i32 %10, i32* %11
%12 = tail call i32 (...) @omp_is_initial_device()
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
store i32 %12, i32* %13
%14 = tail call i32 (...) @omp_is_initial_device()
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
store i32 %14, i32* %15
%16 = tail call i32 (...) @omp_is_initial_device()
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
store i32 %16, i32* %17
%18 = tail call i32 (...) @omp_is_initial_device()
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
store i32 %18, i32* %19
%20 = tail call i32 (...) @omp_is_initial_device()
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
store i32 %20, i32* %21
%22 = tail call i32 (...) @omp_is_initial_device()
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
store i32 %22, i32* %23
%24 = icmp sgt i32 %3, 0
br i1 %24, label %25, label %38
25: ; preds = %0
%26 = zext i32 %3 to i64
%27 = icmp eq i32 %4, 0
br i1 %27, label %28, label %40
28: ; preds = %25, %31
%29 = phi i64 [ %35, %31 ], [ 1, %25 ]
%30 = icmp eq i64 %29, %26
br i1 %30, label %36, label %31
31: ; preds = %28
%32 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %29
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 0
%35 = add nuw nsw i64 %29, 1
br i1 %34, label %28, label %40
36: ; preds = %28
%37 = icmp slt i32 %3, 10
br i1 %37, label %38, label %53
38: ; preds = %0, %36
%39 = sext i32 %3 to i64
br label %46
40: ; preds = %31, %25
%41 = tail call i32 (...) @abort()
unreachable
42: ; preds = %46
%43 = add nsw i64 %47, 1
%44 = trunc i64 %43 to i32
%45 = icmp eq i32 %44, 10
br i1 %45, label %53, label %46
46: ; preds = %38, %42
%47 = phi i64 [ %39, %38 ], [ %43, %42 ]
%48 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 %47
%49 = load i32, i32* %48
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %42
51: ; preds = %46
%52 = tail call i32 (...) @abort()
unreachable
53: ; preds = %42, %36
ret i32 0
}