#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, int);
int /*<<< orphan*/ sleep(int);
int main() {
  int i, np;
#pragma omp parallel private(np, i)
  {
    np = omp_get_thread_num();
#pragma omp for ordered
    for (i = 0; i < 5; i++) {
      printf("\t\tSoy el thread %d, antes del ordered en la iteracion %d\n", np,
             i);
#pragma omp ordered
      {
        printf("Soy el thread %d, actuando en la iteracion %d\n", np, i);
        sleep(1);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1196 <main+0x66>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1150 <main+0x20>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
lea    0xebb(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1040 <printf@plt>
lea    0xee2(%rip),%r15
mov    %r15,%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x1,%edx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x2,%edx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x3,%edx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [58 x i8] c"\09\09Soy el thread %d, antes del ordered en la iteracion %d\0A\00"
@.str.1 = [47 x i8] c"Soy el thread %d, actuando en la iteracion %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @omp_get_thread_num()
store i32 %4, i32* %3
store i32 0, i32* %2
br label %5
5: ; preds = %16, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13)
%15 = call i32 @sleep(i32 1)
br label %16
16: ; preds = %8
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %5
19: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [58 x i8] c"\09\09Soy el thread %d, antes del ordered en la iteracion %d\0A\00"
@.str.1 = [47 x i8] c"Soy el thread %d, actuando en la iteracion %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @omp_get_thread_num()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %1, i32 0)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 0)
%4 = tail call i32 @sleep(i32 1)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %1, i32 1)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 1)
%7 = tail call i32 @sleep(i32 1)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %1, i32 2)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 2)
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %1, i32 3)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 3)
%13 = tail call i32 @sleep(i32 1)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %1, i32 4)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 4)
%16 = tail call i32 @sleep(i32 1)
ret i32 0
}