#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 *, ...);
main() {
  int i, n = 7;
  int a[n];
  for (i = 0; i < n; i++)
    a[i] = i + 1;
#pragma omp parallel for shared(a) default(none) firstprivate(n)
  for (i = 0; i < n; i++) {
    a[i] += i;
    printf("Iteracion %d, Hebra %d, Valor de a[%d] = %d.\n", i,
           omp_get_thread_num(), i, a[i]);
  }
  printf("Después de parallel for:\n");
  for (i = 0; i < n; i++)
    printf("a[%d] = %d\n", i, a[i]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x7,-0xc(%rbp)
mov    -0xc(%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,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118f <main+0x6f>
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%edx
add    $0x1,%edx
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1164 <main+0x44>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f0 <main+0xd0>
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%edx
movslq -0x8(%rbp),%rcx
add    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%ecx
movslq -0x8(%rbp),%rdi
mov    (%rax,%rdi,4),%r8d
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1196 <main+0x76>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123b <main+0x11b>
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%esi
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1205 <main+0xe5>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    0xec1(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %eax,%edx
xor    %ecx,%ecx
mov    $0x1,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
mov    $0x1,%ecx
mov    $0x3,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    %eax,%edx
mov    $0x2,%ecx
mov    $0x5,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    %eax,%edx
mov    $0x3,%ecx
mov    $0x7,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %eax,%edx
mov    $0x4,%ecx
mov    $0x9,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    %eax,%edx
mov    $0x5,%ecx
mov    $0xb,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %eax,%edx
mov    $0x6,%ecx
mov    $0xd,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0c(%rip),%rdi
call   1030 <puts@plt>
lea    0xdf4(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x7,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x9,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
mov    $0xb,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
mov    $0xd,%edx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [46 x i8] c"Iteracion %d, Hebra %d, Valor de a[%d] = %d.\0A\00"
@.str.2 = [12 x i8] c"a[%d] = %d\0A\00"
@str = [26 x i8] c"Despu\C3\A9s de parallel for:\00"
define i32 @main() {
%1 = tail call i32 (...) @omp_get_thread_num()
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 0, i32 %1, i32 0, i32 1)
%3 = tail call i32 (...) @omp_get_thread_num()
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 1, i32 %3, i32 1, i32 3)
%5 = tail call i32 (...) @omp_get_thread_num()
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 2, i32 %5, i32 2, i32 5)
%7 = tail call i32 (...) @omp_get_thread_num()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 3, i32 %7, i32 3, i32 7)
%9 = tail call i32 (...) @omp_get_thread_num()
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 4, i32 %9, i32 4, i32 9)
%11 = tail call i32 (...) @omp_get_thread_num()
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 5, i32 %11, i32 5, i32 11)
%13 = tail call i32 (...) @omp_get_thread_num()
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 6, i32 %13, i32 6, i32 13)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 1)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 1, i32 3)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 2, i32 5)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 7)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 4, i32 9)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 11)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 6, i32 13)
ret i32 0
}