#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*/ print_time(int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main() {
  int TID;
  int i, n = 10;
  int a[n], b[n], ref[n];
#pragma omp parallel private(TID)
  {
    TID = 0;
    if (TID < 1 / 2)
      system("sleep 3");
    (void)print_time(TID, "before");
#pragma omp barrier
    (void)print_time(TID, "after ");
  }
  for (i = 0; i < n; i++) {
    b[i] = 2 * (i + 1);
    ref[i] = i + b[i];
  }
#pragma omp parallel private(i) shared(n, a, b)
  {
#pragma omp for schedule(dynamic, 1) nowait
    for (i = 0; i < n; i++)
      a[i] = i;
#pragma omp barrier
#pragma omp for schedule(dynamic, 1) nowait
    for (i = 0; i < n; i++)
      a[i] += b[i];
  }
  printf("After the parallel region\n");
  for (i = 0; i < n; i++)
    printf(" a[%3d] = %6d ref[%3d] = %6d\n", i, a[i], i, ref[i]);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11ca <main+0x9a>
lea    0xe3b(%rip),%rdi
call   1030 <system@plt>
mov    -0x8(%rbp),%edi
lea    0xe34(%rip),%rsi
call   1050 <print_time@plt>
mov    -0x8(%rbp),%edi
lea    0xe2c(%rip),%rsi
call   1050 <print_time@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1232 <main+0x102>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    -0xc(%rbp),%esi
add    $0x1,%esi
shl    $0x1,%esi
movslq -0xc(%rbp),%rdx
mov    %esi,(%rcx,%rdx,4)
mov    -0xc(%rbp),%edx
movslq -0xc(%rbp),%rsi
add    (%rcx,%rsi,4),%edx
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ef <main+0xbf>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1261 <main+0x131>
mov    -0x48(%rbp),%rax
mov    -0xc(%rbp),%edx
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1239 <main+0x109>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    129b <main+0x16b>
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
movslq -0xc(%rbp),%rdx
mov    (%rcx,%rdx,4),%edx
movslq -0xc(%rbp),%rcx
add    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1268 <main+0x138>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    12f5 <main+0x1c5>
mov    -0x38(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rdx
mov    (%rcx,%rdx,4),%edx
mov    -0xc(%rbp),%ecx
movslq -0xc(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12b0 <main+0x180>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rsi
xor    %edi,%edi
call   1050 <print_time@plt>
lea    0xec1(%rip),%rsi
xor    %edi,%edi
call   1050 <print_time@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeae(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    $0x2,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
mov    $0x1,%ecx
mov    $0x5,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x8,%edx
mov    $0x2,%ecx
mov    $0x8,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0xb,%edx
mov    $0x3,%ecx
mov    $0xb,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0xe,%edx
mov    $0x4,%ecx
mov    $0xe,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0x11,%edx
mov    $0x5,%ecx
mov    $0x11,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0x14,%edx
mov    $0x6,%ecx
mov    $0x14,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
mov    $0x17,%edx
mov    $0x7,%ecx
mov    $0x17,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
mov    $0x1a,%edx
mov    $0x8,%ecx
mov    $0x1a,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
mov    $0x1d,%edx
mov    $0x9,%ecx
mov    $0x1d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"sleep 3\00"
@.str.1 = [7 x i8] c"before\00"
@.str.2 = [7 x i8] c"after \00"
@.str.3 = [27 x i8] c"After the parallel region\0A\00"
@.str.4 = [30 x i8] c" a[%3d] = %6d ref[%3d] = %6d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
store i32 10, i32* %4
%9 = load i32, i32* %4
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca i32, i64 %10
store i64 %10, i64* %6
%13 = load i32, i32* %4
%14 = zext i32 %13 to i64
%15 = alloca i32, i64 %14
store i64 %14, i64* %7
%16 = load i32, i32* %4
%17 = zext i32 %16 to i64
%18 = alloca i32, i64 %17
store i64 %17, i64* %8
store i32 0, i32* %2
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %0
%22 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %0
%24 = load i32, i32* %2
%25 = call i32 @print_time(i32 %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%26 = load i32, i32* %2
%27 = call i32 @print_time(i32 %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %28
28: ; preds = %48, %23
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %51
32: ; preds = %28
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
%35 = mul nsw i32 2, %34
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %15, i64 %37
store i32 %35, i32* %38
%39 = load i32, i32* %3
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %15, i64 %41
%43 = load i32, i32* %42
%44 = add nsw i32 %39, %43
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %18, i64 %46
store i32 %44, i32* %47
br label %48
48: ; preds = %32
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %28
51: ; preds = %28
store i32 0, i32* %3
br label %52
52: ; preds = %61, %51
%53 = load i32, i32* %3
%54 = load i32, i32* %4
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %64
56: ; preds = %52
%57 = load i32, i32* %3
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i32, i32* %12, i64 %59
store i32 %57, i32* %60
br label %61
61: ; preds = %56
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 1
store i32 %63, i32* %3
br label %52
64: ; preds = %52
store i32 0, i32* %3
br label %65
65: ; preds = %79, %64
%66 = load i32, i32* %3
%67 = load i32, i32* %4
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %82
69: ; preds = %65
%70 = load i32, i32* %3
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %15, i64 %71
%73 = load i32, i32* %72
%74 = load i32, i32* %3
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %12, i64 %75
%77 = load i32, i32* %76
%78 = add nsw i32 %77, %73
store i32 %78, i32* %76
br label %79
79: ; preds = %69
%80 = load i32, i32* %3
%81 = add nsw i32 %80, 1
store i32 %81, i32* %3
br label %65
82: ; preds = %65
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %84
84: ; preds = %100, %82
%85 = load i32, i32* %3
%86 = load i32, i32* %4
%87 = icmp slt i32 %85, %86
br i1 %87, label %88, label %103
88: ; preds = %84
%89 = load i32, i32* %3
%90 = load i32, i32* %3
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i32, i32* %12, i64 %91
%93 = load i32, i32* %92
%94 = load i32, i32* %3
%95 = load i32, i32* %3
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %18, i64 %96
%98 = load i32, i32* %97
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %89, i32 %93, i32 %94, i32 %98)
br label %100
100: ; preds = %88
%101 = load i32, i32* %3
%102 = add nsw i32 %101, 1
store i32 %102, i32* %3
br label %84
103: ; preds = %84
store i32 0, i32* %1
%104 = load i8*, i8** %5
%105 = load i32, i32* %1
ret i32 %105
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"before\00"
@.str.2 = [7 x i8] c"after \00"
@.str.4 = [30 x i8] c" a[%3d] = %6d ref[%3d] = %6d\0A\00"
@str = [26 x i8] c"After the parallel region\00"
define i32 @main() {
%1 = tail call i32 @print_time(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @print_time(i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 2, i32 0, i32 2)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 5, i32 1, i32 5)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 8, i32 2, i32 8)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 3, i32 11, i32 3, i32 11)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 4, i32 14, i32 4, i32 14)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 5, i32 17, i32 5, i32 17)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 6, i32 20, i32 6, i32 20)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 7, i32 23, i32 7, i32 23)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 8, i32 26, i32 8, i32 26)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 9, i32 29, i32 9, i32 29)
ret i32 0
}