#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 /*<<< orphan*/ scanf(char *, int *);
main() {
  int n = 9, i, b[n];
  for (i = 0; i < n; i++)
    b[i] = -1;
#pragma omp parallel
  {
    int a;
#pragma omp single copyprivate(a)
    {
      printf("\nIntroduce valor de inicialización a: ");
      scanf("%d", &a);
      printf("\nSingle ejecutada por el thread %d\n", omp_get_thread_num());
    }
#pragma omp for
    for (i = 0; i < n; i++) {
      b[i] = a;
      printf("Iteracion %d, Hebra %d, Valor de b[%d] = %d.\n", i,
             omp_get_thread_num(), i, b[i]);
    }
  }
  printf("Depués de la región parallel:\n");
  for (i = 0; i < n; i++)
    printf("b[%d] = %d\t", i, b[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x9,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119d <main+0x6d>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1174 <main+0x44>
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1230 <main+0x100>
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%edx
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    -0x34(%rbp),%esi
mov    %eax,%edx
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
movslq -0xc(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d9 <main+0xa9>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    127b <main+0x14b>
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1245 <main+0x115>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
lea    0xea0(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%ebx
mov    %ebx,0x14(%rsp)
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
lea    0xea5(%rip),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%ebx
mov    %ebx,0x10(%rsp)
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    $0x1,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%ebx
mov    %ebx,0xc(%rsp)
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %rbp,%rdi
mov    $0x2,%esi
mov    %eax,%edx
mov    $0x2,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%ebx
mov    %ebx,0x8(%rsp)
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %rbp,%rdi
mov    $0x3,%esi
mov    %eax,%edx
mov    $0x3,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%ebx
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %eax,%edx
mov    $0x4,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%r14d
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %rbp,%rdi
mov    $0x5,%esi
mov    %eax,%edx
mov    $0x5,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%r15d
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %rbp,%rdi
mov    $0x6,%esi
mov    %eax,%edx
mov    $0x6,%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%r12d
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %rbp,%rdi
mov    $0x7,%esi
mov    %eax,%edx
mov    $0x7,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%r13d
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %rbp,%rdi
mov    $0x8,%esi
mov    %eax,%edx
mov    $0x8,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd95(%rip),%rdi
call   1040 <puts@plt>
lea    0xd7d(%rip),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    0x14(%rsp),%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    0x10(%rsp),%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x2,%esi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x3,%esi
mov    0x8(%rsp),%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x5,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x6,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x7,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    $0x8,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"\0AIntroduce valor de inicializaci\C3\B3n a: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\0ASingle ejecutada por el thread %d\0A\00"
@.str.3 = [46 x i8] c"Iteracion %d, Hebra %d, Valor de b[%d] = %d.\0A\00"
@.str.4 = [33 x i8] c"Depu\C3\A9s de la regi\C3\B3n parallel:\0A\00"
@.str.5 = [12 x i8] c"b[%d] = %d\09\00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i32 0, i32* %1
store i32 9, i32* %2
%7 = load i32, i32* %2
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
store i8* %9, i8** %4
%10 = alloca i32, i64 %8
store i64 %8, i64* %5
store i32 0, i32* %3
br label %11
11: ; preds = %19, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %10, i64 %17
store i32 -1, i32* %18
br label %19
19: ; preds = %15
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %11
22: ; preds = %11
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%25 = call i32 (...) @omp_get_thread_num()
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %25)
store i32 0, i32* %3
br label %27
27: ; preds = %44, %22
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %47
31: ; preds = %27
%32 = load i32, i32* %6
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %10, i64 %34
store i32 %32, i32* %35
%36 = load i32, i32* %3
%37 = call i32 (...) @omp_get_thread_num()
%38 = load i32, i32* %3
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %10, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 %36, i32 %37, i32 %38, i32 %42)
br label %44
44: ; preds = %31
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %27
47: ; preds = %27
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %49
49: ; preds = %60, %47
%50 = load i32, i32* %3
%51 = load i32, i32* %2
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %63
53: ; preds = %49
%54 = load i32, i32* %3
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %10, i64 %56
%58 = load i32, i32* %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %54, i32 %58)
br label %60
60: ; preds = %53
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 1
store i32 %62, i32* %3
br label %49
63: ; preds = %49
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%65 = load i8*, i8** %4
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@.str = [40 x i8] c"\0AIntroduce valor de inicializaci\C3\B3n a: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [36 x i8] c"\0ASingle ejecutada por el thread %d\0A\00"
@.str.3 = [46 x i8] c"Iteracion %d, Hebra %d, Valor de b[%d] = %d.\0A\00"
@.str.5 = [12 x i8] c"b[%d] = %d\09\00"
@str = [32 x i8] c"Depu\C3\A9s de la regi\C3\B3n parallel:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 (...) @omp_get_thread_num()
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %1
%8 = call i32 (...) @omp_get_thread_num()
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %8, i32 0, i32 %7)
%10 = load i32, i32* %1
%11 = call i32 (...) @omp_get_thread_num()
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %11, i32 1, i32 %10)
%13 = load i32, i32* %1
%14 = call i32 (...) @omp_get_thread_num()
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %14, i32 2, i32 %13)
%16 = load i32, i32* %1
%17 = call i32 (...) @omp_get_thread_num()
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %17, i32 3, i32 %16)
%19 = load i32, i32* %1
%20 = call i32 (...) @omp_get_thread_num()
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %20, i32 4, i32 %19)
%22 = load i32, i32* %1
%23 = call i32 (...) @omp_get_thread_num()
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 %23, i32 5, i32 %22)
%25 = load i32, i32* %1
%26 = call i32 (...) @omp_get_thread_num()
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 %26, i32 6, i32 %25)
%28 = load i32, i32* %1
%29 = call i32 (...) @omp_get_thread_num()
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 %29, i32 7, i32 %28)
%31 = load i32, i32* %1
%32 = call i32 (...) @omp_get_thread_num()
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 8, i32 %32, i32 8, i32 %31)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 0, i32 %7)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 1, i32 %10)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 2, i32 %13)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 3, i32 %16)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 4, i32 %19)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 5, i32 %22)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 6, i32 %25)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 7, i32 %28)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 8, i32 %31)
%44 = call i32 @putchar(i32 10)
ret i32 0
}