#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();
double omp_get_wtime();
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *, double, ...);
int /*<<< orphan*/ tarea_dos();
int /*<<< orphan*/ tarea_uno();
int main() {
  double timeIni, timeFin, time_s1, time_s2;
  int nthread;
  omp_set_num_threads(2);
  timeIni = omp_get_wtime();
#pragma omp parallel private(nthread)
  {
    nthread = omp_get_thread_num();
#pragma omp sections
    {
#pragma omp section
      {
        printf("Hilo %i ejecutando tarea 1 \n", nthread);
        tarea_uno();
      }
#pragma omp section
      {
        printf("Hilo %i ejecutando tarea 2\n\n", nthread);
        tarea_dos();
      }
    }
    printf("Tiempo de salida hilo %i = %.4lf segundos.\n\n", nthread,
           (omp_get_wtime() - timeIni));
  }
  timeFin = omp_get_wtime();
  printf("Tiempo tardado = %.4lf segundos\n\n", (timeFin - timeIni));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x2,%edi
call   1080 <omp_set_num_threads@plt>
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
lea    0xe65(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <tarea_uno@plt>
cvtsi2sdl -0x2c(%rbp),%xmm0
lea    0xe68(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1060 <tarea_dos@plt>
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm1
lea    0xe52(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
lea    0xe5b(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    $0x2,%edi
call   1080 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xe6a(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <tarea_uno@plt>
lea    0xe72(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1060 <tarea_dos@plt>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
movapd %xmm0,%xmm1
subsd  0x10(%rsp),%xmm1
lea    0xe63(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1070 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
subsd  0x10(%rsp),%xmm0
lea    0xe6f(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Hilo %i ejecutando tarea 1 \0A\00"
@.str.1 = [29 x i8] c"Hilo %i ejecutando tarea 2\0A\0A\00"
@.str.2 = [45 x i8] c"Tiempo de salida hilo %i = %.4lf segundos.\0A\0A\00"
@.str.3 = [34 x i8] c"Tiempo tardado = %.4lf segundos\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 @omp_set_num_threads(i32 2)
%8 = call double (...) @omp_get_wtime()
store double %8, double* %2
%9 = call i32 (...) @omp_get_thread_num()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = sitofp i32 %10 to double
%12 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %11)
%13 = call i32 (...) @tarea_uno()
%14 = load i32, i32* %6
%15 = sitofp i32 %14 to double
%16 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %15)
%17 = call i32 (...) @tarea_dos()
%18 = load i32, i32* %6
%19 = sitofp i32 %18 to double
%20 = call double (...) @omp_get_wtime()
%21 = load double, double* %2
%22 = fsub double %20, %21
%23 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), double %19, double %22)
%24 = call double (...) @omp_get_wtime()
store double %24, double* %3
%25 = load double, double* %3
%26 = load double, double* %2
%27 = fsub double %25, %26
%28 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), double %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Hilo %i ejecutando tarea 1 \0A\00"
@.str.1 = [29 x i8] c"Hilo %i ejecutando tarea 2\0A\0A\00"
@.str.2 = [45 x i8] c"Tiempo de salida hilo %i = %.4lf segundos.\0A\0A\00"
@.str.3 = [34 x i8] c"Tiempo tardado = %.4lf segundos\0A\0A\00"
define i32 @main() {
%1 = tail call i32 @omp_set_num_threads(i32 2)
%2 = tail call double (...) @omp_get_wtime()
%3 = tail call i32 (...) @omp_get_thread_num()
%4 = sitofp i32 %3 to double
%5 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %4)
%6 = tail call i32 (...) @tarea_uno()
%7 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %4)
%8 = tail call i32 (...) @tarea_dos()
%9 = tail call double (...) @omp_get_wtime()
%10 = fsub double %9, %2
%11 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), double %4, double %10)
%12 = tail call double (...) @omp_get_wtime()
%13 = fsub double %12, %2
%14 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), double %13)
ret i32 0
}