#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*/ acc_wait(int);
int /*<<< orphan*/ assert(int);
int main(int argc, char *argv[]) {
  int res, res2 = 0;
#pragma acc parallel num_gangs(GANGS) copy(res2) async(1)
  {
#pragma acc atomic
    res2 += 5;
  }
  res = 256 * 5;
  acc_wait(1);
  assert(res == res2);
  res = res2 = 1;
#pragma acc parallel num_gangs(GANGS) copy(res2) async(1)
  {
#pragma acc atomic
    res2 *= 5;
  }
  for (int i = 0; i < 8; ++i)
    res *= 5;
  acc_wait(1);
  assert(res == res2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x18(%rbp)
movl   $0x500,-0x14(%rbp)
mov    $0x1,%edi
call   1040 <acc_wait@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
imul   $0x5,-0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    11a5 <main+0x85>
imul   $0x5,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1186 <main+0x66>
mov    $0x1,%edi
call   1040 <acc_wait@plt>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%edi
call   1040 <acc_wait@plt>
xor    %edi,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1040 <acc_wait@plt>
xor    %edi,%edi
call   1030 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%9 = load i32, i32* %7
%10 = add nsw i32 %9, 5
store i32 %10, i32* %7
store i32 1280, i32* %6
%11 = call i32 @acc_wait(i32 1)
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = icmp eq i32 %12, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
store i32 1, i32* %7
store i32 1, i32* %6
%17 = load i32, i32* %7
%18 = mul nsw i32 %17, 5
store i32 %18, i32* %7
store i32 0, i32* %8
br label %19
19: ; preds = %25, %2
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 8
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %6
%24 = mul nsw i32 %23, 5
store i32 %24, i32* %6
br label %25
25: ; preds = %22
%26 = load i32, i32* %8
%27 = add nsw i32 %26, 1
store i32 %27, i32* %8
br label %19
28: ; preds = %19
%29 = call i32 @acc_wait(i32 1)
%30 = load i32, i32* %6
%31 = load i32, i32* %7
%32 = icmp eq i32 %30, %31
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @acc_wait(i32 1)
%4 = tail call i32 @assert(i32 0)
%5 = tail call i32 @acc_wait(i32 1)
%6 = tail call i32 @assert(i32 0)
ret i32 0
}