#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_max_threads();
int omp_get_num_procs();
int omp_get_num_threads();
int omp_get_thread_num();
double omp_get_wtime();
int omp_in_parallel();
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  double tiempo_inicio;
  omp_set_num_threads(2);
  tiempo_inicio = omp_get_wtime();
  printf("Tiempo inicio: %f\n", tiempo_inicio);
  printf("\nProcesadores disponibles: %d\n", omp_get_num_procs());
  printf("\nNumero de hilos (num_threads): %d\nNumero de hilos (max_threads): "
         "%d\n\n",
         omp_get_num_threads(), omp_get_max_threads());
  printf("\nEs paralelo? %s\n\n", (omp_in_parallel() == 1) ? "true" : "false");
#pragma omp parallel
  { printf("Hilo %d: Hola mundo\n", omp_get_thread_num()); }
  printf("\nTiempo fin: %f\n", omp_get_wtime());
  printf("\nTiempo total: %f\n", omp_get_wtime() - tiempo_inicio);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2,%edi
call   1090 <omp_set_num_threads@plt>
mov    $0x0,%al
call   1050 <omp_get_wtime@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe48(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1080 <omp_get_num_procs@plt>
mov    %eax,%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <omp_get_num_threads@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   10a0 <omp_get_max_threads@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <omp_in_parallel@plt>
mov    %eax,%ecx
lea    0xe87(%rip),%rsi
lea    0xe7b(%rip),%rax
cmp    $0x1,%ecx
cmove  %rax,%rsi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <omp_get_thread_num@plt>
mov    %eax,%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <omp_get_wtime@plt>
lea    0xe61(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <omp_get_wtime@plt>
subsd  -0x18(%rbp),%xmm0
lea    0xe58(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x2,%edi
call   1090 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1050 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe5d(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1080 <omp_get_num_procs@plt>
lea    0xe5b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <omp_get_num_threads@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   10a0 <omp_get_max_threads@plt>
lea    0xe5a(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1030 <omp_in_parallel@plt>
cmp    $0x1,%eax
lea    0xe98(%rip),%rax
lea    0xe96(%rip),%rsi
cmove  %rax,%rsi
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
lea    0xe7c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_wtime@plt>
lea    0xe7a(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_wtime@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe70(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Tiempo inicio: %f\0A\00"
@.str.1 = [31 x i8] c"\0AProcesadores disponibles: %d\0A\00"
@.str.2 = [71 x i8] c"\0ANumero de hilos (num_threads): %d\0ANumero de hilos (max_threads): %d\0A\0A\00"
@.str.3 = [19 x i8] c"\0AEs paralelo? %s\0A\0A\00"
@.str.4 = [5 x i8] c"true\00"
@.str.5 = [6 x i8] c"false\00"
@.str.6 = [21 x i8] c"Hilo %d: Hola mundo\0A\00"
@.str.7 = [17 x i8] c"\0ATiempo fin: %f\0A\00"
@.str.8 = [19 x i8] c"\0ATiempo total: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @omp_set_num_threads(i32 2)
%8 = call double (...) @omp_get_wtime()
store double %8, double* %6
%9 = load double, double* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %9)
%11 = call i32 (...) @omp_get_num_procs()
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @omp_get_num_threads()
%14 = call i32 (...) @omp_get_max_threads()
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14)
%16 = call i32 (...) @omp_in_parallel()
%17 = icmp eq i32 %16, 1
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = call i32 (...) @omp_get_thread_num()
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %21)
%23 = call double (...) @omp_get_wtime()
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), double %23)
%25 = call double (...) @omp_get_wtime()
%26 = load double, double* %6
%27 = fsub double %25, %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), double %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Tiempo inicio: %f\0A\00"
@.str.1 = [31 x i8] c"\0AProcesadores disponibles: %d\0A\00"
@.str.2 = [71 x i8] c"\0ANumero de hilos (num_threads): %d\0ANumero de hilos (max_threads): %d\0A\0A\00"
@.str.3 = [19 x i8] c"\0AEs paralelo? %s\0A\0A\00"
@.str.4 = [5 x i8] c"true\00"
@.str.5 = [6 x i8] c"false\00"
@.str.6 = [21 x i8] c"Hilo %d: Hola mundo\0A\00"
@.str.7 = [17 x i8] c"\0ATiempo fin: %f\0A\00"
@.str.8 = [19 x i8] c"\0ATiempo total: %f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @omp_set_num_threads(i32 2)
%4 = tail call double (...) @omp_get_wtime()
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), double %4)
%6 = tail call i32 (...) @omp_get_num_procs()
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = tail call i32 (...) @omp_get_num_threads()
%9 = tail call i32 (...) @omp_get_max_threads()
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9)
%11 = tail call i32 (...) @omp_in_parallel()
%12 = icmp eq i32 %11, 1
%13 = select i1 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = tail call i32 (...) @omp_get_thread_num()
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %15)
%17 = tail call double (...) @omp_get_wtime()
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), double %17)
%19 = tail call double (...) @omp_get_wtime()
%20 = fsub double %19, %4
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), double %20)
ret i32 0
}