#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 omp_get_thread_num();
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int x = 10;
  int np = 1, i = 0, j = 0;
  printf("\n Antes de pragma parallel x=%d \n\n", x);
#pragma omp parallel private(np, i) reduction(| : x)
  {
    np = omp_get_thread_num();
    printf("Soy el thread %d, antes de actualizar, con x=%d \n", np, x);
    x = (np + 1) * 10;
    printf("\t\tSoy el thread %d, despues de actualizar, con x=%d \n", np, x);
  }
  printf("\n Despues de pragma parallel x=%d \n\n", x);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xa,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
imul   $0xa,%eax,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
lea    0xedd(%rip),%rdi
mov    %eax,%esi
mov    $0xa,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbx,4),%eax
lea    (%rax,%rax,1),%ebp
add    $0xa,%ebp
lea    0xef1(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf15(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0A Antes de pragma parallel x=%d \0A\0A\00"
@.str.1 = [50 x i8] c"Soy el thread %d, antes de actualizar, con x=%d \0A\00"
@.str.2 = [54 x i8] c"\09\09Soy el thread %d, despues de actualizar, con x=%d \0A\00"
@.str.3 = [37 x i8] c"\0A Despues de pragma parallel x=%d \0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 10, i32* %1
store i32 1, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = load i32, i32* %1
%6 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 (...) @omp_get_thread_num()
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = load i32, i32* %1
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
%13 = mul nsw i32 %12, 10
store i32 %13, i32* %1
%14 = load i32, i32* %2
%15 = load i32, i32* %1
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %15)
%17 = load i32, i32* %1
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"\0A Antes de pragma parallel x=%d \0A\0A\00"
@.str.1 = [50 x i8] c"Soy el thread %d, antes de actualizar, con x=%d \0A\00"
@.str.2 = [54 x i8] c"\09\09Soy el thread %d, despues de actualizar, con x=%d \0A\00"
@.str.3 = [37 x i8] c"\0A Despues de pragma parallel x=%d \0A\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 10)
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 10)
%4 = mul i32 %2, 10
%5 = add i32 %4, 10
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %2, i32 %5)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %5)
ret i32 0
}