#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;
#pragma omp single
    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>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123e <main+0x10e>
mov    -0x28(%rbp),%rax
mov    -0xc(%rbp),%esi
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1208 <main+0xd8>
lea    0xe06(%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    0xead(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%ebx
lea    0xec0(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <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 = [12 x i8] c"b[%d] = %d\09\00"
@.str.4 = [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
store i32 0, i32* %3
br label %40
40: ; preds = %51, %39
%41 = load i32, i32* %3
%42 = load i32, i32* %2
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %54
44: ; preds = %40
%45 = load i32, i32* %3
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %10, i64 %47
%49 = load i32, i32* %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %45, i32 %49)
br label %51
51: ; preds = %44
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %40
54: ; preds = %40
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%56 = load i8*, i8** %5
%57 = load i32, i32* %1
ret i32 %57
}

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.3 = [12 x i8] c"b[%d] = %d\09\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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %8)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 1, i32 %8)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 2, i32 %8)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 3, i32 %8)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 4, i32 %8)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 5, i32 %8)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 6, i32 %8)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 7, i32 %8)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 8, i32 %8)
%18 = call i32 @putchar(i32 10)
ret i32 0
}