#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();
scalar_t__ acc_device_nvidia;
scalar_t__ acc_get_device_type();
int main() {
  int s1 = 0, s2 = 0;
  int i;
  int dummy = 0;
#pragma acc data copy(dummy)
  {
#pragma acc parallel num_gangs(N) reduction(+ : s1) copy(s1)
    { s1++; }
  }
  if (acc_get_device_type() != acc_device_nvidia) {
    if (s1 != 1)
      abort();
  } else {
    if (s1 != 10)
      abort();
  }
  s1 = 0;
  s2 = 0;
#pragma acc parallel num_gangs(10) reduction(+ : s1, s2) copy(s1, s2)
  {
    s1++;
    s2 += 10;
  }
  if (acc_get_device_type() != acc_device_nvidia) {
    if (s1 != 1)
      abort();
    if (s2 != 10)
      abort();
  } else {
    if (s1 != 10)
      abort();
    if (s2 != 10 * 10)
      abort();
  }
  s1 = 0;
#pragma acc parallel num_gangs(10) reduction(+ : s1) copy(s1)
  {
#pragma acc loop gang reduction(+ : s1)
    for (i = 0; i < 10; i++)
      s1++;
  }
  if (s1 != 10)
    abort();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <acc_get_device_type@plt>
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%rax
je     117a <main+0x5a>
cmpl   $0x1,-0x8(%rbp)
je     1175 <main+0x55>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1190 <main+0x70>
cmpl   $0xa,-0x8(%rbp)
je     118b <main+0x6b>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1190 <main+0x70>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1040 <acc_get_device_type@plt>
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%rax
je     11ee <main+0xce>
cmpl   $0x1,-0x8(%rbp)
je     11d8 <main+0xb8>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0xa,-0xc(%rbp)
je     11e9 <main+0xc9>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1215 <main+0xf5>
cmpl   $0xa,-0x8(%rbp)
je     11ff <main+0xdf>
mov    $0x0,%al
call   1030 <abort@plt>
cmpl   $0x64,-0xc(%rbp)
je     1210 <main+0xf0>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1215 <main+0xf5>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    1244 <main+0x124>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1223 <main+0x103>
cmpl   $0xa,-0x8(%rbp)
je     1255 <main+0x135>
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 <acc_get_device_type@plt>
mov    0x2eb1(%rip),%rbx
cmp    (%rbx),%rax
je     1144 <main+0x24>
xor    %eax,%eax
call   1040 <acc_get_device_type@plt>
cmp    (%rbx),%rax
je     1144 <main+0x24>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@acc_device_nvidia = global i64 0
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 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %5
%6 = load i32, i32* %2
%7 = add nsw i32 %6, 1
store i32 %7, i32* %2
%8 = call i64 (...) @acc_get_device_type()
%9 = load i64, i64* @acc_device_nvidia
%10 = icmp ne i64 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %0
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (...) @abort()
unreachable
16: ; preds = %11
br label %23
17: ; preds = %0
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 10
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %17
br label %23
23: ; preds = %22, %16
store i32 0, i32* %2
store i32 0, i32* %3
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 10
store i32 %27, i32* %3
%28 = call i64 (...) @acc_get_device_type()
%29 = load i64, i64* @acc_device_nvidia
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %42
31: ; preds = %23
%32 = load i32, i32* %2
%33 = icmp ne i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (...) @abort()
unreachable
36: ; preds = %31
%37 = load i32, i32* %3
%38 = icmp ne i32 %37, 10
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (...) @abort()
unreachable
41: ; preds = %36
br label %53
42: ; preds = %23
%43 = load i32, i32* %2
%44 = icmp ne i32 %43, 10
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 (...) @abort()
unreachable
47: ; preds = %42
%48 = load i32, i32* %3
%49 = icmp ne i32 %48, 100
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 (...) @abort()
unreachable
52: ; preds = %47
br label %53
53: ; preds = %52, %41
store i32 0, i32* %2
store i32 0, i32* %4
br label %54
54: ; preds = %60, %53
%55 = load i32, i32* %4
%56 = icmp slt i32 %55, 10
br i1 %56, label %57, label %63
57: ; preds = %54
%58 = load i32, i32* %2
%59 = add nsw i32 %58, 1
store i32 %59, i32* %2
br label %60
60: ; preds = %57
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %54
63: ; preds = %54
%64 = load i32, i32* %2
%65 = icmp ne i32 %64, 10
br i1 %65, label %66, label %68
66: ; preds = %63
%67 = call i32 (...) @abort()
unreachable
68: ; preds = %63
ret i32 0
}

LLVM IR (-O2):
@acc_device_nvidia = global i64 0
define i32 @main() {
%1 = tail call i64 (...) @acc_get_device_type()
%2 = load i64, i64* @acc_device_nvidia
%3 = icmp eq i64 %1, %2
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 (...) @abort()
unreachable
6: ; preds = %0
%7 = tail call i64 (...) @acc_get_device_type()
%8 = load i64, i64* @acc_device_nvidia
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 (...) @abort()
unreachable
12: ; preds = %6
ret i32 0
}