#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*/ assert(int);
int main(int argc, char *argv[]) {
  int n, arr[32], i;
  for (i = 0; i < 32; i++)
    arr[i] = 0;
  n = 0;
#pragma acc parallel copy(n, arr) num_gangs(ACTUAL_GANGS) num_workers(8)       \
    vector_length(32)
  {
    int j;
#pragma acc atomic
    n++;
#pragma acc loop vector
    for (j = 0; j < 32; j++) {
#pragma acc atomic
      arr[j] += 1;
    }
#pragma acc atomic
    n++;
  }
  assert(n == 8 * 2);
  for (i = 0; i < 32; i++)
    assert(arr[i] == 8);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xa4(%rbp)
cmpl   $0x20,-0xa4(%rbp)
jge    1166 <main+0x56>
movslq -0xa4(%rbp),%rax
movl   $0x0,-0xa0(%rbp,%rax,4)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1133 <main+0x23>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xa8(%rbp)
cmpl   $0x20,-0xa8(%rbp)
jge    11b9 <main+0xa9>
movslq -0xa8(%rbp),%rax
mov    -0xa0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0xa0(%rbp,%rax,4)
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    1180 <main+0x70>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0xa4(%rbp)
cmpl   $0x20,-0xa4(%rbp)
jge    121a <main+0x10a>
movslq -0xa4(%rbp),%rax
cmpl   $0x8,-0xa0(%rbp,%rax,4)
08
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    11dd <main+0xcd>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movdqa (%rsp),%xmm0
pcmpeqd %xmm1,%xmm1
psubd  %xmm1,%xmm0
movdqa %xmm0,(%rsp)
movdqa 0x10(%rsp),%xmm0
psubd  %xmm1,%xmm0
movdqa %xmm0,0x10(%rsp)
movdqa 0x20(%rsp),%xmm0
psubd  %xmm1,%xmm0
movdqa %xmm0,0x20(%rsp)
movdqa 0x30(%rsp),%xmm0
psubd  %xmm1,%xmm0
movdqa %xmm0,0x30(%rsp)
movdqa 0x40(%rsp),%xmm0
psubd  %xmm1,%xmm0
movdqa %xmm0,0x40(%rsp)
movdqa 0x50(%rsp),%xmm0
psubd  %xmm1,%xmm0
movdqa %xmm0,0x50(%rsp)
movdqa 0x60(%rsp),%xmm0
psubd  %xmm1,%xmm0
movdqa %xmm0,0x60(%rsp)
movdqa 0x70(%rsp),%xmm0
psubd  %xmm1,%xmm0
movdqa %xmm0,0x70(%rsp)
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <assert@plt>
nopl   (%rax)
xor    %edi,%edi
cmpl   $0x8,(%rsp,%rbx,4)
sete   %dil
call   1030 <assert@plt>
add    $0x1,%rbx
cmp    $0x20,%rbx
jne    11d0 <main+0xc0>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

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

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