#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() {
  int a, b, c, i, n;
  int a_check, c_check;
  b = 50;
  n = 1858;
  a_check = b + n - 1;
  c_check = a_check + b;
  printf("Before parallel loop: b = %d n = %d\n", b, n);
#pragma omp parallel for private(i), firstprivate(b), lastprivate(a)
  for (i = 0; i < n; i++) {
    a = b + i;
  }
  c = a + b;
  printf("Values of a and c after parallel for:\n");
  printf("\ta = %d\t(correct value is %d)\n", a, a_check);
  printf("\tc = %d\t(correct value is %d)\n", c, c_check);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x32,-0xc(%rbp)
movl   $0x742,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1180 <main+0x70>
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <main+0x4d>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xeb3(%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    0xed8(%rip),%rdi
mov    $0x32,%esi
mov    $0x742,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf23(%rip),%rdi
call   1030 <puts@plt>
lea    0xed9(%rip),%rdi
mov    $0x773,%esi
mov    $0x773,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x7a5,%esi
mov    $0x7a5,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Before parallel loop: b = %d n = %d\0A\00"
@.str.1 = [39 x i8] c"Values of a and c after parallel for:\0A\00"
@.str.2 = [31 x i8] c"\09a = %d\09(correct value is %d)\0A\00"
@.str.3 = [31 x i8] c"\09c = %d\09(correct value is %d)\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
%8 = alloca i32
store i32 0, i32* %1
store i32 50, i32* %3
store i32 1858, i32* %6
%9 = load i32, i32* %3
%10 = load i32, i32* %6
%11 = add nsw i32 %9, %10
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = load i32, i32* %3
%15 = add nsw i32 %13, %14
store i32 %15, i32* %8
%16 = load i32, i32* %3
%17 = load i32, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
store i32 0, i32* %5
br label %19
19: ; preds = %27, %0
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load i32, i32* %3
%25 = load i32, i32* %5
%26 = add nsw i32 %24, %25
store i32 %26, i32* %2
br label %27
27: ; preds = %23
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %19
30: ; preds = %19
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = add nsw i32 %31, %32
store i32 %33, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* %2
%36 = load i32, i32* %7
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32 %36)
%38 = load i32, i32* %4
%39 = load i32, i32* %8
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Before parallel loop: b = %d n = %d\0A\00"
@.str.2 = [31 x i8] c"\09a = %d\09(correct value is %d)\0A\00"
@.str.3 = [31 x i8] c"\09c = %d\09(correct value is %d)\0A\00"
@str = [38 x i8] c"Values of a and c after parallel for:\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 50, i32 1858)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 1907, i32 1907)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 1957, i32 1957)
ret i32 0
}