#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__ gang_4(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 * 2)];
  if (vector_1(ary, (32 * 32 * 32 * 2)))
    return 1;
  if (vector_2(ary, (32 * 32 * 32 * 2)))
    return 1;
  if (worker_1(ary, (32 * 32 * 32 * 2)))
    return 1;
  if (gang_1(ary, (32 * 32 * 32 * 2)))
    return 1;
  if (gang_2(ary, (32 * 32 * 32 * 2)))
    return 1;
  if (gang_3(ary, (32 * 32 * 32 * 2)))
    return 1;
  if (gang_4(ary, (32 * 32 * 32 * 2)))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40010,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
call   1040 <acc_on_device@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11c0 <main+0x40>
movl   $0x0,-0x4(%rbp)
jmp    12d8 <main+0x158>
lea    -0x40010(%rbp),%rdi
mov    $0x10000,%esi
call   10a0 <vector_1@plt>
cmp    $0x0,%rax
je     11e7 <main+0x67>
movl   $0x1,-0x4(%rbp)
jmp    12d8 <main+0x158>
lea    -0x40010(%rbp),%rdi
mov    $0x10000,%esi
call   1070 <vector_2@plt>
cmp    $0x0,%rax
je     120e <main+0x8e>
movl   $0x1,-0x4(%rbp)
jmp    12d8 <main+0x158>
lea    -0x40010(%rbp),%rdi
mov    $0x10000,%esi
call   1090 <worker_1@plt>
cmp    $0x0,%rax
je     1235 <main+0xb5>
movl   $0x1,-0x4(%rbp)
jmp    12d8 <main+0x158>
lea    -0x40010(%rbp),%rdi
mov    $0x10000,%esi
call   1030 <gang_1@plt>
cmp    $0x0,%rax
je     125c <main+0xdc>
movl   $0x1,-0x4(%rbp)
jmp    12d8 <main+0x158>
lea    -0x40010(%rbp),%rdi
mov    $0x10000,%esi
call   1080 <gang_2@plt>
cmp    $0x0,%rax
je     1283 <main+0x103>
movl   $0x1,-0x4(%rbp)
jmp    12d8 <main+0x158>
lea    -0x40010(%rbp),%rdi
mov    $0x10000,%esi
call   1050 <gang_3@plt>
cmp    $0x0,%rax
je     12aa <main+0x12a>
movl   $0x1,-0x4(%rbp)
jmp    12d8 <main+0x158>
lea    -0x40010(%rbp),%rdi
mov    $0x10000,%esi
call   1060 <gang_4@plt>
cmp    $0x0,%rax
je     12d1 <main+0x151>
movl   $0x1,-0x4(%rbp)
jmp    12d8 <main+0x158>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40000,%rsp
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1040 <acc_on_device@plt>
test   %eax,%eax
je     1226 <main+0xa6>
mov    %rsp,%rdi
mov    $0x10000,%esi
call   10a0 <vector_1@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    1228 <main+0xa8>
mov    %rsp,%rdi
mov    $0x10000,%esi
call   1070 <vector_2@plt>
test   %rax,%rax
jne    1228 <main+0xa8>
mov    %rsp,%rdi
mov    $0x10000,%esi
call   1090 <worker_1@plt>
test   %rax,%rax
jne    1228 <main+0xa8>
mov    %rsp,%rdi
mov    $0x10000,%esi
call   1030 <gang_1@plt>
test   %rax,%rax
jne    1228 <main+0xa8>
mov    %rsp,%rdi
mov    $0x10000,%esi
call   1080 <gang_2@plt>
test   %rax,%rax
jne    1228 <main+0xa8>
mov    %rsp,%rdi
mov    $0x10000,%esi
call   1050 <gang_3@plt>
test   %rax,%rax
jne    1228 <main+0xa8>
mov    %rsp,%rdi
mov    $0x10000,%esi
call   1060 <gang_4@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
jmp    1228 <main+0xa8>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x40000,%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 [65536 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 %45
9: ; preds = %0
%10 = getelementptr inbounds [65536 x i32], [65536 x i32]* %3, i64 0, i64 0
%11 = call i64 @vector_1(i32* %10, i32 65536)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 1, i32* %1
br label %45
14: ; preds = %9
%15 = getelementptr inbounds [65536 x i32], [65536 x i32]* %3, i64 0, i64 0
%16 = call i64 @vector_2(i32* %15, i32 65536)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %14
store i32 1, i32* %1
br label %45
19: ; preds = %14
%20 = getelementptr inbounds [65536 x i32], [65536 x i32]* %3, i64 0, i64 0
%21 = call i64 @worker_1(i32* %20, i32 65536)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 1, i32* %1
br label %45
24: ; preds = %19
%25 = getelementptr inbounds [65536 x i32], [65536 x i32]* %3, i64 0, i64 0
%26 = call i64 @gang_1(i32* %25, i32 65536)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i32 1, i32* %1
br label %45
29: ; preds = %24
%30 = getelementptr inbounds [65536 x i32], [65536 x i32]* %3, i64 0, i64 0
%31 = call i64 @gang_2(i32* %30, i32 65536)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 1, i32* %1
br label %45
34: ; preds = %29
%35 = getelementptr inbounds [65536 x i32], [65536 x i32]* %3, i64 0, i64 0
%36 = call i64 @gang_3(i32* %35, i32 65536)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 1, i32* %1
br label %45
39: ; preds = %34
%40 = getelementptr inbounds [65536 x i32], [65536 x i32]* %3, i64 0, i64 0
%41 = call i64 @gang_4(i32* %40, i32 65536)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %39
store i32 1, i32* %1
br label %45
44: ; preds = %39
store i32 0, i32* %1
br label %45
45: ; preds = %44, %43, %38, %33, %28, %23, %18, %13, %8
%46 = load i32, i32* %1
ret i32 %46
}

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