#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 check(int *, int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ clear(int *, int);
int place();
int gang_vector_2b(int *ary, int size) {
  if (size % 256)
    return 1;
  clear(ary, size);
#pragma acc parallel vector_length(32) num_gangs(32) copy(ary [0:size])        \
    firstprivate(size)
  {
#pragma acc loop tile(64, 64) gang vector
    for (int jx = 0; jx < size; jx += 256)
      for (int ix = 0; ix < 256; ix++)
        ary[jx + ix] = place();
  }
  return check(ary, size, 1, 0, 1);
}


x86 assembly (clang, -O0):
<gang_vector_2b>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     115f <gang_vector_2b+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    11e8 <gang_vector_2b+0xb8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <clear@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ce <gang_vector_2b+0x9e>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x100,-0x1c(%rbp)
jge    11b9 <gang_vector_2b+0x89>
mov    $0x0,%al
call   1030 <place@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1185 <gang_vector_2b+0x55>
jmp    11be <gang_vector_2b+0x8e>
mov    -0x18(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0x18(%rbp)
jmp    1172 <gang_vector_2b+0x42>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x1,%r8d
xor    %ecx,%ecx
mov    %r8d,%edx
call   1040 <check@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gang_vector_2b>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
test   %r15b,%r15b
je     114e <gang_vector_2b+0x1e>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdi,%r14
mov    %r15d,%esi
call   1050 <clear@plt>
test   %r15d,%r15d
jle    11aa <gang_vector_2b+0x7a>
mov    %r14,%rbx
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <place@plt>
mov    %eax,(%rbx,%rbp,4)
add    $0x1,%rbp
cmp    $0x100,%rbp
jne    1180 <gang_vector_2b+0x50>
add    $0x100,%r12
add    $0x400,%rbx
cmp    %r15d,%r12d
jl     1170 <gang_vector_2b+0x40>
mov    %r14,%rdi
mov    %r15d,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <check@plt>

LLVM IR (-O0):
define i32 @gang_vector_2b(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = srem i32 %8, 256
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %43
12: ; preds = %2
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = call i32 @clear(i32* %13, i32 %14)
store i32 0, i32* %6
br label %16
16: ; preds = %36, %12
%17 = load i32, i32* %6
%18 = load i32, i32* %5
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %39
20: ; preds = %16
store i32 0, i32* %7
br label %21
21: ; preds = %32, %20
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 256
br i1 %23, label %24, label %35
24: ; preds = %21
%25 = call i32 (...) @place()
%26 = load i32*, i32** %4
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = add nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %26, i64 %30
store i32 %25, i32* %31
br label %32
32: ; preds = %24
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %21
35: ; preds = %21
br label %36
36: ; preds = %35
%37 = load i32, i32* %6
%38 = add nsw i32 %37, 256
store i32 %38, i32* %6
br label %16
39: ; preds = %16
%40 = load i32*, i32** %4
%41 = load i32, i32* %5
%42 = call i32 @check(i32* %40, i32 %41, i32 1, i32 0, i32 1)
store i32 %42, i32* %3
br label %43
43: ; preds = %39, %11
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
define i32 @gang_vector_2b(i32* %0, i32 %1) {
%3 = and i32 %1, 255
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %23
5: ; preds = %2
%6 = tail call i32 @clear(i32* %0, i32 %1)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %10
8: ; preds = %5, %12
%9 = phi i64 [ %13, %12 ], [ 0, %5 ]
br label %16
10: ; preds = %12, %5
%11 = tail call i32 @check(i32* %0, i32 %1, i32 1, i32 0, i32 1)
br label %23
12: ; preds = %16
%13 = add nuw i64 %9, 256
%14 = trunc i64 %13 to i32
%15 = icmp slt i32 %14, %1
br i1 %15, label %8, label %10
16: ; preds = %8, %16
%17 = phi i64 [ 0, %8 ], [ %21, %16 ]
%18 = tail call i32 (...) @place()
%19 = add nuw nsw i64 %17, %9
%20 = getelementptr inbounds i32, i32* %0, i64 %19
store i32 %18, i32* %20
%21 = add nuw nsw i64 %17, 1
%22 = icmp eq i64 %21, 256
br i1 %22, label %12, label %16
23: ; preds = %2, %10
%24 = phi i32 [ %11, %10 ], [ 1, %2 ]
ret i32 %24
}