#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*/ printf(char *, ...);
int main(void) {
  int SUM1 = 0, SUM2 = 0;
  int N1 = 32, N2 = 64;
#pragma omp target map(tofrom : SUM1)
#pragma omp teams distribute parallel for reduction(+ : SUM1)
  for (int i = 1; i <= N1; i++)
    SUM1 += i;
#pragma omp target map(tofrom : SUM2)
#pragma omp teams distribute parallel for reduction(+ : SUM2)
  for (int i = 1; i <= N2; i++)
    SUM2 += i;
  printf("N1:%d  Sum1:%d  CheckVal:%d\n", N1, SUM1, (N1 * (N1 + 1)) / 2);
  printf("N2:%d  Sum2:%d  CheckVal:%d\n", N2, SUM2, (N2 * (N2 + 1)) / 2);
  if ((SUM1 != (N1 * (N1 + 1)) / 2) || (SUM2 != (N2 * (N2 + 1)) / 2)) {
    printf("INVALID RESULTS\n");
    return 1;
  } else {
    printf("Success\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x20,-0x10(%rbp)
movl   $0x40,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1165 <main+0x55>
mov    -0x18(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1142 <main+0x32>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     118f <main+0x7f>
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116c <main+0x5c>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%edx
mov    %eax,%ecx
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x24(%rbp),%edx
mov    %eax,%ecx
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jne    123d <main+0x12d>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
je     1257 <main+0x147>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    126c <main+0x15c>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0x20,%esi
mov    $0x210,%edx
mov    $0x210,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
mov    $0x40,%esi
mov    $0x820,%edx
mov    $0x820,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"N1:%d Sum1:%d CheckVal:%d\0A\00"
@.str.1 = [29 x i8] c"N2:%d Sum2:%d CheckVal:%d\0A\00"
@.str.2 = [17 x i8] c"INVALID RESULTS\0A\00"
@.str.3 = [9 x i8] c"Success\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 32, i32* %4
store i32 64, i32* %5
store i32 1, i32* %6
br label %8
8: ; preds = %16, %0
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load i32, i32* %6
%14 = load i32, i32* %2
%15 = add nsw i32 %14, %13
store i32 %15, i32* %2
br label %16
16: ; preds = %12
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %8
19: ; preds = %8
store i32 1, i32* %7
br label %20
20: ; preds = %28, %19
%21 = load i32, i32* %7
%22 = load i32, i32* %5
%23 = icmp sle i32 %21, %22
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i32, i32* %7
%26 = load i32, i32* %3
%27 = add nsw i32 %26, %25
store i32 %27, i32* %3
br label %28
28: ; preds = %24
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %20
31: ; preds = %20
%32 = load i32, i32* %4
%33 = load i32, i32* %2
%34 = load i32, i32* %4
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
%37 = mul nsw i32 %34, %36
%38 = sdiv i32 %37, 2
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %33, i32 %38)
%40 = load i32, i32* %5
%41 = load i32, i32* %3
%42 = load i32, i32* %5
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
%45 = mul nsw i32 %42, %44
%46 = sdiv i32 %45, 2
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41, i32 %46)
%48 = load i32, i32* %2
%49 = load i32, i32* %4
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
%52 = mul nsw i32 %49, %51
%53 = sdiv i32 %52, 2
%54 = icmp ne i32 %48, %53
br i1 %54, label %63, label %55
55: ; preds = %31
%56 = load i32, i32* %3
%57 = load i32, i32* %5
%58 = load i32, i32* %5
%59 = add nsw i32 %58, 1
%60 = mul nsw i32 %57, %59
%61 = sdiv i32 %60, 2
%62 = icmp ne i32 %56, %61
br i1 %62, label %63, label %65
63: ; preds = %55, %31
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %67
65: ; preds = %55
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %67
67: ; preds = %65, %63
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
@.str = [29 x i8] c"N1:%d Sum1:%d CheckVal:%d\0A\00"
@.str.1 = [29 x i8] c"N2:%d Sum2:%d CheckVal:%d\0A\00"
@str = [8 x i8] c"Success\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 32, i32 528, i32 528)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 64, i32 2080, i32 2080)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
ret i32 0
}