#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);
void t8() {
  int arr[1024];
  int gangs;
  for (gangs = 1; gangs <= 1024; gangs <<= 1) {
    int i;
    for (i = 0; i < 1024; i++)
      arr[i] = 0;
#pragma acc parallel copy(arr) num_gangs(gangs) num_workers(1) vector_length(32)
    {
      int j;
#pragma acc loop gang
      for (j = 0; j < 1024; j++)
        arr[j]++;
    }
    for (i = 0; i < 1024; i++)
      assert(arr[i] == 1);
  }
}


x86 assembly (clang, -O0):
<t8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
movl   $0x1,-0x1004(%rbp)
cmpl   $0x400,-0x1004(%rbp)
jg     121e <t8+0x10e>
movl   $0x0,-0x1008(%rbp)
cmpl   $0x400,-0x1008(%rbp)
jge    1175 <t8+0x65>
movslq -0x1008(%rbp),%rax
movl   $0x0,-0x1000(%rbp,%rax,4)
mov    -0x1008(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1008(%rbp)
jmp    113f <t8+0x2f>
movl   $0x0,-0x100c(%rbp)
cmpl   $0x400,-0x100c(%rbp)
jge    11bb <t8+0xab>
movslq -0x100c(%rbp),%rax
mov    -0x1000(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x1000(%rbp,%rax,4)
mov    -0x100c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x100c(%rbp)
jmp    117f <t8+0x6f>
movl   $0x0,-0x1008(%rbp)
cmpl   $0x400,-0x1008(%rbp)
jge    1205 <t8+0xf5>
movslq -0x1008(%rbp),%rax
cmpl   $0x1,-0x1000(%rbp,%rax,4)
01
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x1008(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1008(%rbp)
jmp    11c5 <t8+0xb5>
jmp    120a <t8+0xfa>
mov    -0x1004(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x1004(%rbp)
jmp    1125 <t8+0x15>
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t8>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1000,%rsp
mov    $0x1,%ebp
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x1000,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
xor    %eax,%eax
pcmpeqd %xmm4,%xmm4
cs nopw 0x0(%rax,%rax,1)
nop
movdqa (%rsp,%rax,4),%xmm0
movdqa 0x10(%rsp,%rax,4),%xmm1
movdqa 0x20(%rsp,%rax,4),%xmm2
movdqa 0x30(%rsp,%rax,4),%xmm3
psubd  %xmm4,%xmm0
psubd  %xmm4,%xmm1
movdqa %xmm0,(%rsp,%rax,4)
movdqa %xmm1,0x10(%rsp,%rax,4)
psubd  %xmm4,%xmm2
psubd  %xmm4,%xmm3
movdqa %xmm2,0x20(%rsp,%rax,4)
movdqa %xmm3,0x30(%rsp,%rax,4)
add    $0x10,%rax
cmp    $0x400,%rax
jne    1160 <t8+0x40>
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %edi,%edi
cmpl   $0x1,(%rsp,%rbx,4)
sete   %dil
call   1040 <assert@plt>
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    11b0 <t8+0x90>
add    %ebp,%ebp
cmp    $0x401,%ebp
jl     1140 <t8+0x20>
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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