#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_4(int *ary, int size) {
  clear(ary, size);
#pragma acc parallel vector_length(32) copy(ary [0:size]) firstprivate(size)
  {
#pragma acc loop auto
    for (int jx = 0; jx < size; jx++)
      ary[jx] = place();
  }
  return check(ary, size, 1, 0, 1);
}


x86 assembly (clang, -O0):
<gang_4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <clear@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1180 <gang_4+0x50>
mov    $0x0,%al
call   1030 <place@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1152 <gang_4+0x22>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1,%r8d
xor    %ecx,%ecx
mov    %r8d,%edx
call   1040 <check@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gang_4>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
call   1050 <clear@plt>
test   %r14d,%r14d
jle    1164 <gang_4+0x34>
mov    %r14d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <place@plt>
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <gang_4+0x20>
mov    %r15,%rdi
mov    %r14d,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <check@plt>

LLVM IR (-O0):
define i32 @gang_4(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = load i32, i32* %4
%8 = call i32 @clear(i32* %6, i32 %7)
store i32 0, i32* %5
br label %9
9: ; preds = %19, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = call i32 (...) @place()
%15 = load i32*, i32** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
store i32 %14, i32* %18
br label %19
19: ; preds = %13
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %9
22: ; preds = %9
%23 = load i32*, i32** %3
%24 = load i32, i32* %4
%25 = call i32 @check(i32* %23, i32 %24, i32 1, i32 0, i32 1)
ret i32 %25
}

LLVM IR (-O2):
define i32 @gang_4(i32* %0, i32 %1) {
%3 = tail call i32 @clear(i32* %0, i32 %1)
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = zext i32 %1 to i64
br label %9
7: ; preds = %9, %2
%8 = tail call i32 @check(i32* %0, i32 %1, i32 1, i32 0, i32 1)
ret i32 %8
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %13, %9 ]
%11 = tail call i32 (...) @place()
%12 = getelementptr inbounds i32, i32* %0, i64 %10
store i32 %11, i32* %12
%13 = add nuw nsw i64 %10, 1
%14 = icmp eq i64 %13, %6
br i1 %14, label %7, label %9
}