#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 *, long long, ...);
int main(void) {
  long long a, i;
#pragma omp target parallel shared(a) private(i)
  {
#pragma omp master
    a = 0;
#pragma omp barrier
#pragma omp for reduction(+ : a)
    for (i = 0; i < 1000000ll; i++) {
      a += i;
    }
#pragma omp single
    {
      if (a != (1000000ll * (1000000ll - 1) / 2))
        printf("Incorrect result = %lld, expected = %lld!\n", a,
               (1000000ll * (1000000ll - 1) / 2));
      else
        printf("The result is correct = %lld!\n", a);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0xf4240,-0x18(%rbp)
jge    115a <main+0x4a>
mov    -0x18(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112f <main+0x1f>
movabs $0x746a4ae6e0,%rax
cmp    %rax,-0x10(%rbp)
je     118f <main+0x7f>
mov    -0x10(%rbp),%rsi
lea    0xe87(%rip),%rdi
movabs $0x746a4ae6e0,%rdx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a1 <main+0x91>
mov    -0x10(%rbp),%rsi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
movabs $0x746a4ae6e0,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Incorrect result = %lld, expected = %lld!\0A\00"
@.str.1 = [31 x i8] c"The result is correct = %lld!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
br label %4
4: ; preds = %11, %0
%5 = load i64, i64* %3
%6 = icmp slt i64 %5, 1000000
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i64, i64* %3
%9 = load i64, i64* %2
%10 = add nsw i64 %9, %8
store i64 %10, i64* %2
br label %11
11: ; preds = %7
%12 = load i64, i64* %3
%13 = add nsw i64 %12, 1
store i64 %13, i64* %3
br label %4
14: ; preds = %4
%15 = load i64, i64* %2
%16 = icmp ne i64 %15, 499999500000
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i64, i64* %2
%19 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i64 %18, i64 499999500000)
br label %23
20: ; preds = %14
%21 = load i64, i64* %2
%22 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 %21)
br label %23
23: ; preds = %20, %17
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"The result is correct = %lld!\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i64 499999500000)
ret i32 0
}