#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*/ WorkVec(int *, int, int, int, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int DoWorkVec(int nw) {
  int ary[32][64];
  int err = 0;
  for (int ix = 0; ix != 32; ix++)
    for (int jx = 0; jx != 64; jx++)
      ary[ix][jx] = 0xdeadbeef;
  printf("spawning %d ...", nw);
  fflush(stdout);
#pragma acc parallel num_workers(nw) vector_length(NUM_VECTORS) copy(ary)
  { WorkVec((int *)ary, 64, 32, nw, 32); }
  for (int ix = 0; ix != 32; ix++)
    for (int jx = 0; jx != 64; jx++) {
      int exp = ((ix % nw) << 8) | (jx % 32);
      if (ary[ix][jx] != exp) {
        printf("\nary[%d][%d] = %#x expected %#x", ix, jx, ary[ix][jx], exp);
        err = 1;
      }
    }
  printf(err ? " failed\n" : " ok\n");
  return err;
}


x86 assembly (clang, -O0):
<DoWorkVec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x2014(%rbp)
movl   $0x0,-0x2018(%rbp)
cmpl   $0x20,-0x2018(%rbp)
je     11c6 <DoWorkVec+0x96>
movl   $0x0,-0x201c(%rbp)
cmpl   $0x40,-0x201c(%rbp)
je     11ad <DoWorkVec+0x7d>
movslq -0x2018(%rbp),%rcx
lea    -0x2010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x201c(%rbp),%rcx
movl   $0xdeadbeef,(%rax,%rcx,4)
mov    -0x201c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x201c(%rbp)
jmp    1169 <DoWorkVec+0x39>
jmp    11b2 <DoWorkVec+0x82>
mov    -0x2018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2018(%rbp)
jmp    1152 <DoWorkVec+0x22>
mov    -0x4(%rbp),%esi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    -0x2010(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0x40,%esi
mov    $0x20,%r8d
mov    %r8d,%edx
call   1050 <WorkVec@plt>
movl   $0x0,-0x2020(%rbp)
cmpl   $0x20,-0x2020(%rbp)
je     1306 <DoWorkVec+0x1d6>
movl   $0x0,-0x2024(%rbp)
cmpl   $0x40,-0x2024(%rbp)
je     12ed <DoWorkVec+0x1bd>
mov    -0x2020(%rbp),%eax
cltd
idivl  -0x4(%rbp)
shl    $0x8,%edx
mov    %edx,-0x202c(%rbp)
mov    -0x2024(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
mov    -0x202c(%rbp),%eax
or     %edx,%eax
mov    %eax,-0x2028(%rbp)
movslq -0x2020(%rbp),%rcx
lea    -0x2010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x2024(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x2028(%rbp),%eax
je     12d4 <DoWorkVec+0x1a4>
mov    -0x2020(%rbp),%esi
mov    -0x2024(%rbp),%edx
movslq -0x2020(%rbp),%rcx
lea    -0x2010(%rbp),%rax
shl    $0x8,%rcx
add    %rcx,%rax
movslq -0x2024(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x2028(%rbp),%r8d
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x2014(%rbp)
jmp    12d9 <DoWorkVec+0x1a9>
mov    -0x2024(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2024(%rbp)
jmp    1223 <DoWorkVec+0xf3>
jmp    12f2 <DoWorkVec+0x1c2>
mov    -0x2020(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2020(%rbp)
jmp    120c <DoWorkVec+0xdc>
mov    -0x2014(%rbp),%ecx
lea    0xd26(%rip),%rdi
lea    0xd16(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2014(%rbp),%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoWorkVec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
mov    %edi,0xc(%rsp)
xor    %eax,%eax
movaps 0xeb2(%rip),%xmm0
xchg   %ax,%ax
movaps %xmm0,0x10(%rsp,%rax,1)
movaps %xmm0,0x20(%rsp,%rax,1)
movaps %xmm0,0x30(%rsp,%rax,1)
movaps %xmm0,0x40(%rsp,%rax,1)
movaps %xmm0,0x50(%rsp,%rax,1)
movaps %xmm0,0x60(%rsp,%rax,1)
movaps %xmm0,0x70(%rsp,%rax,1)
movaps %xmm0,0x80(%rsp,%rax,1)
movaps %xmm0,0x90(%rsp,%rax,1)
movaps %xmm0,0xa0(%rsp,%rax,1)
movaps %xmm0,0xb0(%rsp,%rax,1)
movaps %xmm0,0xc0(%rsp,%rax,1)
movaps %xmm0,0xd0(%rsp,%rax,1)
movaps %xmm0,0xe0(%rsp,%rax,1)
movaps %xmm0,0xf0(%rsp,%rax,1)
movaps %xmm0,0x100(%rsp,%rax,1)
add    $0x100,%rax
cmp    $0x2000,%rax
jne    1150 <DoWorkVec+0x20>
lea    0xe40(%rip),%rdi
mov    0xc(%rsp),%ebp
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
mov    $0x20,%edx
mov    %ebp,%ecx
mov    $0x20,%r8d
call   1050 <WorkVec@plt>
lea    0xe0f(%rip),%r15
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    1231 <DoWorkVec+0x101>
nopl   0x0(%rax)
add    $0x1,%r13
add    $0x100,%rbx
cmp    $0x20,%r13
je     1285 <DoWorkVec+0x155>
mov    %r13d,%eax
cltd
idivl  0xc(%rsp)
mov    %edx,%ebp
shl    $0x8,%ebp
xor    %r14d,%r14d
jmp    125a <DoWorkVec+0x12a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
cmp    $0x40,%r14
je     1220 <DoWorkVec+0xf0>
mov    %r14d,%r8d
and    $0x1f,%r8d
or     %ebp,%r8d
mov    (%rbx,%r14,4),%ecx
cmp    %r8d,%ecx
je     1250 <DoWorkVec+0x120>
mov    %r15,%rdi
mov    %r13d,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%r12d
jmp    1250 <DoWorkVec+0x120>
test   %r12d,%r12d
lea    0xdba(%rip),%rax
lea    0xdaa(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12d,%eax
add    $0x2018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"spawning %d ...\00"
@stdout = global i32 0
@.str.1 = [32 x i8] c"\0Aary[%d][%d] = %#x expected %#x\00"
@.str.2 = [9 x i8] c" failed\0A\00"
@.str.3 = [5 x i8] c" ok\0A\00"
define i32 @DoWorkVec(i32 %0) {
%2 = alloca i32
%3 = alloca [32 x [64 x i32]]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %4
store i32 0, i32* %5
br label %10
10: ; preds = %28, %1
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 32
br i1 %12, label %13, label %31
13: ; preds = %10
store i32 0, i32* %6
br label %14
14: ; preds = %24, %13
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 64
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %3, i64 0, i64 %19
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [64 x i32], [64 x i32]* %20, i64 0, i64 %22
store i32 -559038737, i32* %23
br label %24
24: ; preds = %17
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %14
27: ; preds = %14
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %10
31: ; preds = %10
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @stdout
%35 = call i32 @fflush(i32 %34)
%36 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %3, i64 0, i64 0
%37 = bitcast [64 x i32]* %36 to i32*
%38 = load i32, i32* %2
%39 = call i32 @WorkVec(i32* %37, i32 64, i32 32, i32 %38, i32 32)
store i32 0, i32* %7
br label %40
40: ; preds = %81, %31
%41 = load i32, i32* %7
%42 = icmp ne i32 %41, 32
br i1 %42, label %43, label %84
43: ; preds = %40
store i32 0, i32* %8
br label %44
44: ; preds = %77, %43
%45 = load i32, i32* %8
%46 = icmp ne i32 %45, 64
br i1 %46, label %47, label %80
47: ; preds = %44
%48 = load i32, i32* %7
%49 = load i32, i32* %2
%50 = srem i32 %48, %49
%51 = shl i32 %50, 8
%52 = load i32, i32* %8
%53 = srem i32 %52, 32
%54 = or i32 %51, %53
store i32 %54, i32* %9
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %3, i64 0, i64 %56
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [64 x i32], [64 x i32]* %57, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = load i32, i32* %9
%63 = icmp ne i32 %61, %62
br i1 %63, label %64, label %76
64: ; preds = %47
%65 = load i32, i32* %7
%66 = load i32, i32* %8
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %3, i64 0, i64 %68
%70 = load i32, i32* %8
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [64 x i32], [64 x i32]* %69, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = load i32, i32* %9
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %65, i32 %66, i32 %73, i32 %74)
store i32 1, i32* %4
br label %76
76: ; preds = %64, %47
br label %77
77: ; preds = %76
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 1
store i32 %79, i32* %8
br label %44
80: ; preds = %44
br label %81
81: ; preds = %80
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
store i32 %83, i32* %7
br label %40
84: ; preds = %40
%85 = load i32, i32* %4
%86 = icmp ne i32 %85, 0
%87 = zext i1 %86 to i64
%88 = select i1 %86, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%89 = call i32 (i8*, ...) @printf(i8* %88)
%90 = load i32, i32* %4
ret i32 %90
}

LLVM IR (-O2):
@.str = [16 x i8] c"spawning %d ...\00"
@stdout = global i32 0
@.str.1 = [32 x i8] c"\0Aary[%d][%d] = %#x expected %#x\00"
@.str.2 = [9 x i8] c" failed\0A\00"
@.str.3 = [5 x i8] c" ok\0A\00"
define i32 @DoWorkVec(i32 %0) {
%2 = alloca [32 x [64 x i32]]
%3 = bitcast [32 x [64 x i32]]* %2 to i8*
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ 0, %1 ], [ %38, %4 ]
%6 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 0
%7 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %7
%8 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 4
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %9
%10 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 8
%11 = bitcast i32* %10 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %11
%12 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 12
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %13
%14 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 16
%15 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %15
%16 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 20
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %17
%18 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 24
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %19
%20 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 28
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %21
%22 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 32
%23 = bitcast i32* %22 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %23
%24 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 36
%25 = bitcast i32* %24 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %25
%26 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 40
%27 = bitcast i32* %26 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %27
%28 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 44
%29 = bitcast i32* %28 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %29
%30 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 48
%31 = bitcast i32* %30 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %31
%32 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 52
%33 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %33
%34 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 56
%35 = bitcast i32* %34 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %35
%36 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %5, i64 60
%37 = bitcast i32* %36 to <4 x i32>*
store <4 x i32> <i32 -559038737, i32 -559038737, i32 -559038737, i32 -559038737>, <4 x i32>* %37
%38 = add nuw nsw i64 %5, 1
%39 = icmp eq i64 %38, 32
br i1 %39, label %40, label %4
40: ; preds = %4
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %0)
%42 = load i32, i32* @stdout
%43 = tail call i32 @fflush(i32 %42)
%44 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 0, i64 0
%45 = call i32 @WorkVec(i32* %44, i32 64, i32 32, i32 %0, i32 32)
br label %46
46: ; preds = %40, %56
%47 = phi i64 [ 0, %40 ], [ %57, %56 ]
%48 = phi i32 [ 0, %40 ], [ %71, %56 ]
%49 = trunc i64 %47 to i32
%50 = srem i32 %49, %0
%51 = shl i32 %50, 8
br label %59
52: ; preds = %56
%53 = icmp eq i32 %71, 0
%54 = select i1 %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %54)
ret i32 %71
56: ; preds = %70
%57 = add nuw nsw i64 %47, 1
%58 = icmp eq i64 %57, 32
br i1 %58, label %52, label %46
59: ; preds = %46, %70
%60 = phi i64 [ 0, %46 ], [ %72, %70 ]
%61 = phi i32 [ %48, %46 ], [ %71, %70 ]
%62 = trunc i64 %60 to i32
%63 = and i32 %62, 31
%64 = or i32 %51, %63
%65 = getelementptr inbounds [32 x [64 x i32]], [32 x [64 x i32]]* %2, i64 0, i64 %47, i64 %60
%66 = load i32, i32* %65
%67 = icmp eq i32 %66, %64
br i1 %67, label %70, label %68
68: ; preds = %59
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %49, i32 %62, i32 %66, i32 %64)
br label %70
70: ; preds = %68, %59
%71 = phi i32 [ 1, %68 ], [ %61, %59 ]
%72 = add nuw nsw i64 %60, 1
%73 = icmp eq i64 %72, 64
br i1 %73, label %56, label %59
}