#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, a, b[n];
  for (i = 0; i < n; i++)
    b[i] = -1;
#pragma omp parallel
  {
#pragma omp single
    {
      printf("Introduce valor de inicializació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;
  }
  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    $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    0xe75(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1201 <main+0xd1>
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    11d9 <main+0xa9>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
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    0xe19(%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   %rbx
sub    $0x10,%rsp
mov    %rsp,%r15
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
lea    0xea1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%ebx
lea    0xebc(%rip),%rdi
call   1040 <puts@plt>
lea    0xea4(%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>
mov    %r15,%rsp
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Introduce valor de inicializaci\C3\B3n a: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"Single ejecutada por el thread %d\0A\00"
@.str.3 = [33 x i8] c"Depu\C3\A9s de la regi\C3\B3n parallel:\0A\00"
@.str.4 = [12 x i8] c"b[%d] = %d\09\00"
@.str.5 = [2 x i8] c"\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 ([39 x i8], [39 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* %4)
%25 = call i32 (...) @omp_get_thread_num()
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %25)
store i32 0, i32* %3
br label %27
27: ; preds = %36, %22
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %39
31: ; preds = %27
%32 = load i32, i32* %4
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %10, i64 %34
store i32 %32, i32* %35
br label %36
36: ; preds = %31
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %27
39: ; preds = %27
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %41
41: ; preds = %52, %39
%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 = load i8*, i8** %5
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str = [39 x i8] c"Introduce valor de inicializaci\C3\B3n a: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [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"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 i8* @llvm.stacksave()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = call i32 (...) @omp_get_thread_num()
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %1
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%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 %8)
%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 %8)
%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 %8)
%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 %8)
%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 %8)
%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 %8)
%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 %8)
%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 %8)
%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 %8)
%19 = call i32 @putchar(i32 10)
ret i32 0
}