#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 t9() {
  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++)
        if ((j % 3) == 0)
          arr[j]++;
        else
          arr[j] += 2;
    }
    for (i = 0; i < 1024; i++)
      assert(arr[i] == ((i % 3) == 0) ? 1 : 2);
  }
}


x86 assembly (clang, -O0):
<t9>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
movl   $0x1,-0x1004(%rbp)
cmpl   $0x400,-0x1004(%rbp)
jg     1276 <t9+0x166>
movl   $0x0,-0x1008(%rbp)
cmpl   $0x400,-0x1008(%rbp)
jge    1175 <t9+0x65>
movslq -0x1008(%rbp),%rax
movl   $0x0,-0x1000(%rbp,%rax,4)
mov    -0x1008(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1008(%rbp)
jmp    113f <t9+0x2f>
movl   $0x0,-0x100c(%rbp)
cmpl   $0x400,-0x100c(%rbp)
jge    11f4 <t9+0xe4>
mov    -0x100c(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11c3 <t9+0xb3>
movslq -0x100c(%rbp),%rax
mov    -0x1000(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x1000(%rbp,%rax,4)
jmp    11db <t9+0xcb>
movslq -0x100c(%rbp),%rax
mov    -0x1000(%rbp,%rax,4),%ecx
add    $0x2,%ecx
mov    %ecx,-0x1000(%rbp,%rax,4)
jmp    11e0 <t9+0xd0>
mov    -0x100c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x100c(%rbp)
jmp    117f <t9+0x6f>
movl   $0x0,-0x1008(%rbp)
cmpl   $0x400,-0x1008(%rbp)
jge    125d <t9+0x14d>
movslq -0x1008(%rbp),%rax
mov    -0x1000(%rbp,%rax,4),%ecx
mov    -0x1008(%rbp),%eax
mov    $0x3,%esi
cltd
idiv   %esi
cmp    $0x0,%edx
sete   %al
and    $0x1,%al
movzbl %al,%edx
mov    $0x2,%edi
mov    $0x1,%eax
cmp    %edx,%ecx
cmove  %eax,%edi
call   1030 <assert@plt>
mov    -0x1008(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1008(%rbp)
jmp    11fe <t9+0xee>
jmp    1262 <t9+0x152>
mov    -0x1004(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x1004(%rbp)
jmp    1125 <t9+0x15>
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t9>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1008,%rsp
mov    $0x1,%r15d
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
mov    $0x1000,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
xor    %eax,%eax
movdqa 0xea7(%rip),%xmm0
movdqa 0xeae(%rip),%xmm8
movdqa 0xeb6(%rip),%xmm4
pxor   %xmm5,%xmm5
movdqa 0xeba(%rip),%xmm6
movdqa 0xec2(%rip),%xmm7
movdqa 0xeca(%rip),%xmm3
cs nopw 0x0(%rax,%rax,1)
movdqa %xmm0,%xmm1
pmullw %xmm8,%xmm1
movdqa %xmm1,%xmm2
psubusw %xmm4,%xmm2
pcmpeqw %xmm5,%xmm2
punpcklwd %xmm2,%xmm2
psrad  $0x10,%xmm2
paddd  (%rsp,%rax,4),%xmm2
paddw  %xmm7,%xmm1
psubusw %xmm4,%xmm1
pcmpeqw %xmm5,%xmm1
punpcklwd %xmm1,%xmm1
psrad  $0x10,%xmm1
paddd  0x10(%rsp,%rax,4),%xmm1
paddd  %xmm6,%xmm2
paddd  %xmm6,%xmm1
movdqa %xmm2,(%rsp,%rax,4)
movdqa %xmm1,0x10(%rsp,%rax,4)
add    $0x8,%rax
paddw  %xmm3,%xmm0
cmp    $0x400,%rax
jne    1190 <t9+0x70>
xor    %ebx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movzwl %bp,%eax
imul   $0xaaab,%eax,%eax
shr    $0x11,%eax
lea    (%rax,%rax,2),%eax
xor    %ecx,%ecx
add    %bx,%ax
sete   %cl
xor    %eax,%eax
cmp    %ecx,(%rsp,%rbp,4)
sete   %al
mov    $0x2,%edi
sub    %eax,%edi
call   1040 <assert@plt>
add    $0x1,%rbp
add    $0xffffffff,%ebx
cmp    $0x400,%rbp
jne    1200 <t9+0xe0>
add    %r15d,%r15d
cmp    $0x401,%r15d
jl     1140 <t9+0x20>
add    $0x1008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @t9() {
%1 = alloca [1024 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 1, i32* %2
br label %5
5: ; preds = %64, %0
%6 = load i32, i32* %2
%7 = icmp sle i32 %6, 1024
br i1 %7, label %8, label %67
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 = %40, %19
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 1024
br i1 %22, label %23, label %43
23: ; preds = %20
%24 = load i32, i32* %4
%25 = srem i32 %24, 3
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %23
%28 = load i32, i32* %4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
br label %39
33: ; preds = %23
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = add nsw i32 %37, 2
store i32 %38, i32* %36
br label %39
39: ; preds = %33, %27
br label %40
40: ; preds = %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
br label %20
43: ; preds = %20
store i32 0, i32* %3
br label %44
44: ; preds = %60, %43
%45 = load i32, i32* %3
%46 = icmp slt i32 %45, 1024
br i1 %46, label %47, label %63
47: ; preds = %44
%48 = load i32, i32* %3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [1024 x i32], [1024 x i32]* %1, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i32, i32* %3
%53 = srem i32 %52, 3
%54 = icmp eq i32 %53, 0
%55 = zext i1 %54 to i32
%56 = icmp eq i32 %51, %55
%57 = zext i1 %56 to i64
%58 = select i1 %56, i32 1, i32 2
%59 = call i32 @assert(i32 %58)
br label %60
60: ; preds = %47
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 1
store i32 %62, i32* %3
br label %44
63: ; preds = %44
br label %64
64: ; preds = %63
%65 = load i32, i32* %2
%66 = shl i32 %65, 1
store i32 %66, i32* %2
br label %5
67: ; preds = %5
ret void
}

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