#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;
  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();
      }
    }
  }
  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    $0x20,%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,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
lea    0xe65(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1050 <tarea_uno@plt>
cvtsi2sdl -0x1c(%rbp),%xmm0
lea    0xe6a(%rip),%rdi
call   1070 <printf@plt>
mov    $0x0,%al
call   1060 <tarea_dos@plt>
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
lea    0xe5e(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x20,%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
call   1070 <printf@plt>
xor    %eax,%eax
call   1050 <tarea_uno@plt>
lea    0xe74(%rip),%rdi
movsd  0x8(%rsp),%xmm0
call   1070 <printf@plt>
xor    %eax,%eax
call   1060 <tarea_dos@plt>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
subsd  0x10(%rsp),%xmm0
lea    0xe6b(%rip),%rdi
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 = [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 i32
store i32 0, i32* %1
%5 = call i32 @omp_set_num_threads(i32 2)
%6 = call double (...) @omp_get_wtime()
store double %6, double* %2
%7 = call i32 (...) @omp_get_thread_num()
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = sitofp i32 %8 to double
%10 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), double %9)
%11 = call i32 (...) @tarea_uno()
%12 = load i32, i32* %4
%13 = sitofp i32 %12 to double
%14 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), double %13)
%15 = call i32 (...) @tarea_dos()
%16 = call double (...) @omp_get_wtime()
store double %16, double* %3
%17 = load double, double* %3
%18 = load double, double* %2
%19 = fsub double %17, %18
%20 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %19)
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 = [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 @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 @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 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), double %10)
ret i32 0
}