#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*/ acc_device_not_host;
int acc_on_device(int /*<<< orphan*/);
scalar_t__ gang_1(int *, int);
scalar_t__ gang_2(int *, int);
scalar_t__ gang_3(int *, int);
scalar_t__ vector_1(int *, int);
scalar_t__ vector_2(int *, int);
scalar_t__ worker_1(int *, int);
int main() {
  int ondev = 0;
#pragma acc parallel copy(ondev)
  { ondev = acc_on_device(acc_device_not_host); }
  if (!ondev)
    return 0;
  int ary[(32 * 32 * 32)];
  if (vector_1(ary, (32 * 32 * 32)))
    return 1;
  if (vector_2(ary, (32 * 32 * 32)))
    return 1;
  if (worker_1(ary, (32 * 32 * 32)))
    return 1;
  if (gang_1(ary, (32 * 32 * 32)))
    return 1;
  if (gang_2(ary, (32 * 32 * 32)))
    return 1;
  if (gang_3(ary, (32 * 32 * 32)))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20010,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1040 <acc_on_device@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11b0 <main+0x40>
movl   $0x0,-0x4(%rbp)
jmp    12a1 <main+0x131>
lea    -0x20010(%rbp),%rdi
mov    $0x8000,%esi
call   1090 <vector_1@plt>
cmp    $0x0,%rax
je     11d7 <main+0x67>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <main+0x131>
lea    -0x20010(%rbp),%rdi
mov    $0x8000,%esi
call   1060 <vector_2@plt>
cmp    $0x0,%rax
je     11fe <main+0x8e>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <main+0x131>
lea    -0x20010(%rbp),%rdi
mov    $0x8000,%esi
call   1080 <worker_1@plt>
cmp    $0x0,%rax
je     1225 <main+0xb5>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <main+0x131>
lea    -0x20010(%rbp),%rdi
mov    $0x8000,%esi
call   1030 <gang_1@plt>
cmp    $0x0,%rax
je     124c <main+0xdc>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <main+0x131>
lea    -0x20010(%rbp),%rdi
mov    $0x8000,%esi
call   1070 <gang_2@plt>
cmp    $0x0,%rax
je     1273 <main+0x103>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <main+0x131>
lea    -0x20010(%rbp),%rdi
mov    $0x8000,%esi
call   1050 <gang_3@plt>
cmp    $0x0,%rax
je     129a <main+0x12a>
movl   $0x1,-0x4(%rbp)
jmp    12a1 <main+0x131>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20000,%rsp
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1040 <acc_on_device@plt>
test   %eax,%eax
je     1200 <main+0x90>
mov    %rsp,%rdi
mov    $0x8000,%esi
call   1090 <vector_1@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    1202 <main+0x92>
mov    %rsp,%rdi
mov    $0x8000,%esi
call   1060 <vector_2@plt>
test   %rax,%rax
jne    1202 <main+0x92>
mov    %rsp,%rdi
mov    $0x8000,%esi
call   1080 <worker_1@plt>
test   %rax,%rax
jne    1202 <main+0x92>
mov    %rsp,%rdi
mov    $0x8000,%esi
call   1030 <gang_1@plt>
test   %rax,%rax
jne    1202 <main+0x92>
mov    %rsp,%rdi
mov    $0x8000,%esi
call   1070 <gang_2@plt>
test   %rax,%rax
jne    1202 <main+0x92>
mov    %rsp,%rdi
mov    $0x8000,%esi
call   1050 <gang_3@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
jmp    1202 <main+0x92>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x20000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@acc_device_not_host = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [32768 x i32]
store i32 0, i32* %1
store i32 0, i32* %2
%4 = load i32, i32* @acc_device_not_host
%5 = call i32 @acc_on_device(i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %0
store i32 0, i32* %1
br label %40
9: ; preds = %0
%10 = getelementptr inbounds [32768 x i32], [32768 x i32]* %3, i64 0, i64 0
%11 = call i64 @vector_1(i32* %10, i32 32768)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 1, i32* %1
br label %40
14: ; preds = %9
%15 = getelementptr inbounds [32768 x i32], [32768 x i32]* %3, i64 0, i64 0
%16 = call i64 @vector_2(i32* %15, i32 32768)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* %1
br label %40
19: ; preds = %14
%20 = getelementptr inbounds [32768 x i32], [32768 x i32]* %3, i64 0, i64 0
%21 = call i64 @worker_1(i32* %20, i32 32768)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %1
br label %40
24: ; preds = %19
%25 = getelementptr inbounds [32768 x i32], [32768 x i32]* %3, i64 0, i64 0
%26 = call i64 @gang_1(i32* %25, i32 32768)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 1, i32* %1
br label %40
29: ; preds = %24
%30 = getelementptr inbounds [32768 x i32], [32768 x i32]* %3, i64 0, i64 0
%31 = call i64 @gang_2(i32* %30, i32 32768)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 1, i32* %1
br label %40
34: ; preds = %29
%35 = getelementptr inbounds [32768 x i32], [32768 x i32]* %3, i64 0, i64 0
%36 = call i64 @gang_3(i32* %35, i32 32768)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 1, i32* %1
br label %40
39: ; preds = %34
store i32 0, i32* %1
br label %40
40: ; preds = %39, %38, %33, %28, %23, %18, %13, %8
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@acc_device_not_host = global i32 0
define i32 @main() {
%1 = alloca [32768 x i32]
%2 = load i32, i32* @acc_device_not_host
%3 = tail call i32 @acc_on_device(i32 %2)
%4 = icmp eq i32 %3, 0
br i1 %4, label %28, label %5
5: ; preds = %0
%6 = bitcast [32768 x i32]* %1 to i8*
%7 = getelementptr inbounds [32768 x i32], [32768 x i32]* %1, i64 0, i64 0
%8 = call i64 @vector_1(i32* %7, i32 32768)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %5
%11 = call i64 @vector_2(i32* %7, i32 32768)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = call i64 @worker_1(i32* %7, i32 32768)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = call i64 @gang_1(i32* %7, i32 32768)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = call i64 @gang_2(i32* %7, i32 32768)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = call i64 @gang_3(i32* %7, i32 32768)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %22, %19, %16, %13, %10, %5
%27 = phi i32 [ 1, %5 ], [ 1, %10 ], [ 1, %13 ], [ 1, %16 ], [ 1, %19 ], [ %25, %22 ]
br label %28
28: ; preds = %0, %26
%29 = phi i32 [ %27, %26 ], [ 0, %0 ]
ret i32 %29
}