#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*/ check_offloading();
int omp_get_thread_num();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  check_offloading();
  int A[32][10];
  for (int i = 0; i < 32; ++i)
    for (int j = 0; j < 10; ++j)
      A[i][j] = 0;
#pragma omp target
  {
    printf("Serial\n");
#pragma omp parallel num_threads(32)
    {
      int tt = omp_get_thread_num();
      if (tt == 1)
        A[tt][0] = 99;
      if (tt % 4 == 0)
#pragma omp parallel for
        for (int i = 0; i < 10; i++) {
          A[tt][i] += 3;
        }
    }
  }
  for (int i = 0; i < 32; ++i)
    for (int j = 0; j < 10; ++j)
      printf("L1:%d L2:%d %d\n", i, j, A[i][j]);
  printf("Done!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x530,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <check_offloading@plt>
movl   $0x0,-0x514(%rbp)
cmpl   $0x20,-0x514(%rbp)
jge    11c7 <main+0x97>
movl   $0x0,-0x518(%rbp)
cmpl   $0xa,-0x518(%rbp)
jge    11ae <main+0x7e>
movslq -0x514(%rbp),%rcx
lea    -0x510(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x518(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x518(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x518(%rbp)
jmp    116a <main+0x3a>
jmp    11b3 <main+0x83>
mov    -0x514(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x514(%rbp)
jmp    1153 <main+0x23>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x51c(%rbp)
cmpl   $0x1,-0x51c(%rbp)
jne    120a <main+0xda>
movslq -0x51c(%rbp),%rcx
lea    -0x510(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movl   $0x63,(%rax)
mov    -0x51c(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1276 <main+0x146>
movl   $0x0,-0x520(%rbp)
cmpl   $0xa,-0x520(%rbp)
jge    1271 <main+0x141>
movslq -0x51c(%rbp),%rcx
lea    -0x510(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x520(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x3,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x520(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x520(%rbp)
jmp    122b <main+0xfb>
jmp    1276 <main+0x146>
movl   $0x0,-0x524(%rbp)
cmpl   $0x20,-0x524(%rbp)
jge    130a <main+0x1da>
movl   $0x0,-0x528(%rbp)
cmpl   $0xa,-0x528(%rbp)
jge    12f1 <main+0x1c1>
mov    -0x524(%rbp),%esi
mov    -0x528(%rbp),%edx
movslq -0x524(%rbp),%rcx
lea    -0x510(%rbp),%rax
imul   $0x28,%rcx,%rcx
add    %rcx,%rax
movslq -0x528(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xd32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x528(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x528(%rbp)
jmp    1297 <main+0x167>
jmp    12f6 <main+0x1c6>
mov    -0x524(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x524(%rbp)
jmp    1280 <main+0x150>
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x500,%rsp
xor    %eax,%eax
call   1070 <check_offloading@plt>
mov    %rsp,%rdi
mov    $0x500,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
cmp    $0x1,%eax
jne    1194 <main+0x44>
movl   $0x63,0x28(%rsp)
jmp    11ce <main+0x7e>
test   $0x3,%al
jne    11ce <main+0x7e>
cltq
lea    (%rax,%rax,4),%rax
movdqa 0xe5a(%rip),%xmm0
movdqu (%rsp,%rax,8),%xmm1
movdqu 0x10(%rsp,%rax,8),%xmm2
paddd  %xmm0,%xmm1
movdqu %xmm1,(%rsp,%rax,8)
paddd  %xmm0,%xmm2
movdqu %xmm2,0x10(%rsp,%rax,8)
addl   $0x3,0x20(%rsp,%rax,8)
addl   $0x3,0x24(%rsp,%rax,8)
lea    0x24(%rsp),%r15
lea    0xe36(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    -0x24(%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x20(%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x1c(%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x18(%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x14(%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x10(%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0xc(%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x6,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x8(%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x7,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x4(%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x8,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r15),%ecx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x9,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
add    $0x28,%r15
cmp    $0x20,%rbx
jne    11e0 <main+0x90>
lea    0xd59(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x500,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Serial\0A\00"
@.str.1 = [16 x i8] c"L1:%d L2:%d %d\0A\00"
@.str.2 = [6 x i8] c"Done!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x [10 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (...) @check_offloading()
store i32 0, i32* %3
br label %10
10: ; preds = %28, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 32
br i1 %12, label %13, label %31
13: ; preds = %10
store i32 0, i32* %4
br label %14
14: ; preds = %24, %13
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %2, i64 0, i64 %19
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %20, i64 0, i64 %22
store i32 0, i32* %23
br label %24
24: ; preds = %17
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %14
27: ; preds = %14
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %10
31: ; preds = %10
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%33 = call i32 (...) @omp_get_thread_num()
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %2, i64 0, i64 %38
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %39, i64 0, i64 0
store i32 99, i32* %40
br label %41
41: ; preds = %36, %31
%42 = load i32, i32* %5
%43 = srem i32 %42, 4
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %62
45: ; preds = %41
store i32 0, i32* %6
br label %46
46: ; preds = %58, %45
%47 = load i32, i32* %6
%48 = icmp slt i32 %47, 10
br i1 %48, label %49, label %61
49: ; preds = %46
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %2, i64 0, i64 %51
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [10 x i32], [10 x i32]* %52, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = add nsw i32 %56, 3
store i32 %57, i32* %55
br label %58
58: ; preds = %49
%59 = load i32, i32* %6
%60 = add nsw i32 %59, 1
store i32 %60, i32* %6
br label %46
61: ; preds = %46
br label %62
62: ; preds = %61, %41
store i32 0, i32* %7
br label %63
63: ; preds = %85, %62
%64 = load i32, i32* %7
%65 = icmp slt i32 %64, 32
br i1 %65, label %66, label %88
66: ; preds = %63
store i32 0, i32* %8
br label %67
67: ; preds = %81, %66
%68 = load i32, i32* %8
%69 = icmp slt i32 %68, 10
br i1 %69, label %70, label %84
70: ; preds = %67
%71 = load i32, i32* %7
%72 = load i32, i32* %8
%73 = load i32, i32* %7
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %2, i64 0, i64 %74
%76 = load i32, i32* %8
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [10 x i32], [10 x i32]* %75, i64 0, i64 %77
%79 = load i32, i32* %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %71, i32 %72, i32 %79)
br label %81
81: ; preds = %70
%82 = load i32, i32* %8
%83 = add nsw i32 %82, 1
store i32 %83, i32* %8
br label %67
84: ; preds = %67
br label %85
85: ; preds = %84
%86 = load i32, i32* %7
%87 = add nsw i32 %86, 1
store i32 %87, i32* %7
br label %63
88: ; preds = %63
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [16 x i8] c"L1:%d L2:%d %d\0A\00"
@.str.2 = [6 x i8] c"Done!\00"
@str = [7 x i8] c"Serial\00"
define i32 @main() {
%1 = alloca [32 x [10 x i32]]
%2 = bitcast [32 x [10 x i32]]* %1 to i8*
%3 = tail call i32 (...) @check_offloading()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (...) @omp_get_thread_num()
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 1, i64 0
store i32 99, i32* %8
br label %30
9: ; preds = %0
%10 = and i32 %5, 3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = sext i32 %5 to i64
%14 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %13, i64 0
%15 = bitcast i32* %14 to <4 x i32>*
%16 = load <4 x i32>, <4 x i32>* %15
%17 = add nsw <4 x i32> %16, <i32 3, i32 3, i32 3, i32 3>
%18 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %18
%19 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %13, i64 4
%20 = bitcast i32* %19 to <4 x i32>*
%21 = load <4 x i32>, <4 x i32>* %20
%22 = add nsw <4 x i32> %21, <i32 3, i32 3, i32 3, i32 3>
%23 = bitcast i32* %19 to <4 x i32>*
store <4 x i32> %22, <4 x i32>* %23
%24 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %13, i64 8
%25 = load i32, i32* %24
%26 = add nsw i32 %25, 3
store i32 %26, i32* %24
%27 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %13, i64 9
%28 = load i32, i32* %27
%29 = add nsw i32 %28, 3
store i32 %29, i32* %27
br label %30
30: ; preds = %12, %7, %9
br label %31
31: ; preds = %30, %31
%32 = phi i64 [ %64, %31 ], [ 0, %30 ]
%33 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 0
%34 = load i32, i32* %33
%35 = trunc i64 %32 to i32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 0, i32 %34)
%37 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 1
%38 = load i32, i32* %37
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 1, i32 %38)
%40 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 2
%41 = load i32, i32* %40
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 2, i32 %41)
%43 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 3
%44 = load i32, i32* %43
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 3, i32 %44)
%46 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 4
%47 = load i32, i32* %46
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 4, i32 %47)
%49 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 5
%50 = load i32, i32* %49
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 5, i32 %50)
%52 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 6
%53 = load i32, i32* %52
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 6, i32 %53)
%55 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 7
%56 = load i32, i32* %55
%57 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 7, i32 %56)
%58 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 8
%59 = load i32, i32* %58
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 8, i32 %59)
%61 = getelementptr inbounds [32 x [10 x i32]], [32 x [10 x i32]]* %1, i64 0, i64 %32, i64 9
%62 = load i32, i32* %61
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 9, i32 %62)
%64 = add nuw nsw i64 %32, 1
%65 = icmp eq i64 %64, 32
br i1 %65, label %66, label %31
66: ; preds = %31
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}