#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 omp_get_thread_num();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ usleep(int);
void f(int n, int a[n]) {
  int i, t;
  int ok = 1;
#pragma omp parallel firstprivate(a) private(i, t)
  {
    t = omp_get_thread_num();
    for (i = 0; i < n; ++i) {
      a[i] += t;
      usleep(10);
    }
#pragma omp barrier
    for (i = 0; i < n; ++i) {
      usleep(10);
      if (a[i] != t + 10) {
        ok = 0;
      }
    }
  }
  if (ok) {
    printf("vla 004 : SUCCESS\n");
  } else {
    printf("vla 004 : FAILED\n");
  }
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118c <f+0x5c>
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    $0xa,%edi
call   1050 <usleep@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1157 <f+0x27>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11dc <f+0xac>
mov    $0xa,%edi
call   1050 <usleep@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x18(%rbp),%ecx
add    $0xa,%ecx
cmp    %ecx,%eax
je     11c9 <f+0x99>
movl   $0x0,-0x1c(%rbp)
jmp    11ce <f+0x9e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <f+0x63>
cmpl   $0x0,-0x1c(%rbp)
je     11f7 <f+0xc7>
lea    0xe13(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <f+0xd3>
lea    0xe15(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    0xec3(%rip),%r14
test   %ebx,%ebx
jle    11bf <f+0x8f>
mov    %eax,%r13d
mov    %ebx,%r15d
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
add    %r13d,(%r12,%rbp,4)
mov    $0xa,%edi
call   1050 <usleep@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1160 <f+0x30>
test   %ebx,%ebx
jle    11bf <f+0x8f>
add    $0xa,%r13d
mov    $0x1,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    $0xa,%edi
call   1050 <usleep@plt>
cmp    %r13d,(%r12,%rbx,4)
cmovne %r14d,%ebp
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1190 <f+0x60>
test   %ebp,%ebp
lea    0xe4c(%rip),%rax
lea    0xe56(%rip),%r14
cmove  %rax,%r14
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"vla 004 : SUCCESS\0A\00"
@.str.1 = [18 x i8] c"vla 004 : FAILED\0A\00"
define void @f(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%8 = load i32, i32* %3
%9 = zext i32 %8 to i64
store i32 1, i32* %7
%10 = call i32 (...) @omp_get_thread_num()
store i32 %10, i32* %6
store i32 0, i32* %5
br label %11
11: ; preds = %24, %2
%12 = load i32, i32* %5
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i32, i32* %6
%17 = load i32*, i32** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %21, %16
store i32 %22, i32* %20
%23 = call i32 @usleep(i32 10)
br label %24
24: ; preds = %15
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %11
27: ; preds = %11
store i32 0, i32* %5
br label %28
28: ; preds = %44, %27
%29 = load i32, i32* %5
%30 = load i32, i32* %3
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %47
32: ; preds = %28
%33 = call i32 @usleep(i32 10)
%34 = load i32*, i32** %4
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 10
%41 = icmp ne i32 %38, %40
br i1 %41, label %42, label %43
42: ; preds = %32
store i32 0, i32* %7
br label %43
43: ; preds = %42, %32
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %28
47: ; preds = %28
%48 = load i32, i32* %7
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %54
52: ; preds = %47
%53 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
ret void
}

LLVM IR (-O2):
@str = [17 x i8] c"vla 004 : FAILED\00"
@str.2 = [18 x i8] c"vla 004 : SUCCESS\00"
define void @f(i32 %0, i32* nocapture %1) {
%3 = tail call i32 (...) @omp_get_thread_num()
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %32
5: ; preds = %2
%6 = zext i32 %0 to i64
br label %11
7: ; preds = %11
br i1 %4, label %8, label %32
8: ; preds = %7
%9 = add nsw i32 %3, 10
%10 = zext i32 %0 to i64
br label %19
11: ; preds = %5, %11
%12 = phi i64 [ 0, %5 ], [ %17, %11 ]
%13 = getelementptr inbounds i32, i32* %1, i64 %12
%14 = load i32, i32* %13
%15 = add nsw i32 %14, %3
store i32 %15, i32* %13
%16 = tail call i32 @usleep(i32 10)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, %6
br i1 %18, label %7, label %11
19: ; preds = %8, %19
%20 = phi i64 [ 0, %8 ], [ %27, %19 ]
%21 = phi i32 [ 1, %8 ], [ %26, %19 ]
%22 = tail call i32 @usleep(i32 10)
%23 = getelementptr inbounds i32, i32* %1, i64 %20
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, %9
%26 = select i1 %25, i32 %21, i32 0
%27 = add nuw nsw i64 %20, 1
%28 = icmp eq i64 %27, %10
br i1 %28, label %29, label %19
29: ; preds = %19
%30 = icmp eq i32 %26, 0
%31 = select i1 %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.2, i64 0, i64 0)
br label %32
32: ; preds = %29, %7, %2
%33 = phi i8* [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.2, i64 0, i64 0), %7 ], [ %31, %29 ]
%34 = tail call i32 @puts(i8* dereferenceable(1) %33)
ret void
}