#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 *);
int main() {
  int n = 9, i, a, b[n];
  for (i = 0; i < n; i++)
    b[i] = -1;
#pragma omp parallel
  {
#pragma omp single
    { printf("Dentro de la región parallel:\n"); }
#pragma omp single
    {
      printf("Introduce valor de inicialización a:");
      scanf("%d", &a);
      printf("Single ejecutada por el thread %d\n", omp_get_thread_num());
    }
#pragma omp for
    for (i = 0; i < n; i++)
      b[i] = a;
  }
#pragma omp single
  {
    for (i = 0; i < n; i++)
      printf("b[%d] = %d\t", i, b[i]);
    printf("\n");
    printf("Single ejecutada por el thread %d\n", omp_get_thread_num());
  }
  printf("Después de la región parallel:\n");
  printf("Single ejecutada por el thread %d\n", omp_get_thread_num());
  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    $0x30,%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,-0x28(%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    -0x28(%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    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120f <main+0xdf>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%edx
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e7 <main+0xb7>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    124c <main+0x11c>
mov    -0x28(%rbp),%rax
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1216 <main+0xe6>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12d3 <main+0x1a3>
mov    -0x28(%rbp),%rax
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    129d <main+0x16d>
lea    0xd45(%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   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsp,%r12
lea    0xef7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xeab(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
lea    0xe96(%rip),%r15
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%ebx
lea    0xea2(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe14(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rsp
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Dentro de la regio\CC\81n parallel:\0A\00"
@.str.1 = [39 x i8] c"Introduce valor de inicializacio\CC\81n a:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [35 x i8] c"Single ejecutada por el thread %d\0A\00"
@.str.4 = [12 x i8] c"b[%d] = %d\09\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [36 x i8] c"Despue\CC\81s de la regio\CC\81n parallel:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
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** %5
%10 = alloca i32, i64 %8
store i64 %8, i64* %6
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 ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%26 = call i32 (...) @omp_get_thread_num()
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %26)
store i32 0, i32* %3
br label %28
28: ; preds = %37, %22
%29 = load i32, i32* %3
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %40
32: ; preds = %28
%33 = load i32, i32* %4
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %10, i64 %35
store i32 %33, i32* %36
br label %37
37: ; preds = %32
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %28
40: ; preds = %28
store i32 0, i32* %3
br label %41
41: ; preds = %52, %40
%42 = load i32, i32* %3
%43 = load i32, i32* %2
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %55
45: ; preds = %41
%46 = load i32, i32* %3
%47 = load i32, i32* %3
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %10, i64 %48
%50 = load i32, i32* %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %46, i32 %50)
br label %52
52: ; preds = %45
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %41
55: ; preds = %41
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%57 = call i32 (...) @omp_get_thread_num()
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%60 = call i32 (...) @omp_get_thread_num()
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %60)
store i32 0, i32* %3
br label %62
62: ; preds = %73, %55
%63 = load i32, i32* %3
%64 = load i32, i32* %2
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %76
66: ; preds = %62
%67 = load i32, i32* %3
%68 = load i32, i32* %3
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %10, i64 %69
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %67, i32 %71)
br label %73
73: ; preds = %66
%74 = load i32, i32* %3
%75 = add nsw i32 %74, 1
store i32 %75, i32* %3
br label %62
76: ; preds = %62
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%78 = load i8*, i8** %5
%79 = load i32, i32* %1
ret i32 %79
}

LLVM IR (-O2):
@.str.1 = [39 x i8] c"Introduce valor de inicializacio\CC\81n a:\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [35 x i8] c"Single ejecutada por el thread %d\0A\00"
@.str.4 = [12 x i8] c"b[%d] = %d\09\00"
@str = [32 x i8] c"Dentro de la regio\CC\81n parallel:\00"
@str.7 = [35 x i8] c"Despue\CC\81s de la regio\CC\81n parallel:\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i8* @llvm.stacksave()
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = call i32 (...) @omp_get_thread_num()
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 %9)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 %9)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 3, i32 %9)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 4, i32 %9)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 5, i32 %9)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 6, i32 %9)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 7, i32 %9)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 8, i32 %9)
%19 = call i32 @putchar(i32 10)
%20 = call i32 (...) @omp_get_thread_num()
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.7, i64 0, i64 0))
%23 = call i32 (...) @omp_get_thread_num()
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 0, i32 %9)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 1, i32 %9)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 2, i32 %9)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 3, i32 %9)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 4, i32 %9)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 5, i32 %9)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 6, i32 %9)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 7, i32 %9)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 8, i32 %9)
%34 = call i32 @putchar(i32 10)
ret i32 0
}