#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 */
struct timeval {
  int tv_sec;
  unsigned long tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ fac_task(int, int, int, int, double *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ upd_task(int, int, int, int, int, double *, double *);
unsigned long chol_prl(int m, int mt, int b, int t, double **Ah) {
  struct timeval start, stop;
  gettimeofday(&start, NULL);
  int skipa = 0;
  int k;
  for (k = 0; k < mt; k++) {
    fac_task(skipa, m, b, t, Ah[k]);
    int skipb = skipa;
    int j;
    for (j = k + 1; j < mt; j++) {
      skipb += b;
      upd_task(skipa, skipb, m, b, t, Ah[k], Ah[j]);
    }
    skipa += b;
  }
#pragma omp taskwait
  gettimeofday(&start, NULL);
  return (stop.tv_sec - start.tv_sec) * 1000000 + stop.tv_usec - start.tv_usec;
}


x86 assembly (clang, -O0):
<chol_prl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1206 <chol_prl+0xd6>
mov    -0x3c(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq -0x40(%rbp),%r8
mov    (%rax,%r8,8),%r8
call   1050 <fac_task@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ef <chol_prl+0xbf>
mov    -0xc(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x44(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x18(%rbp),%rax
movslq -0x40(%rbp),%r9
mov    (%rax,%r9,8),%r9
mov    -0x18(%rbp),%rax
movslq -0x48(%rbp),%r10
mov    (%rax,%r10,8),%rax
mov    %rax,(%rsp)
call   1040 <upd_task@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    119b <chol_prl+0x6b>
mov    -0xc(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1163 <chol_prl+0x33>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x38(%rbp),%eax
sub    -0x28(%rbp),%eax
imul   $0xf4240,%eax,%eax
cltq
add    -0x30(%rbp),%rax
sub    -0x20(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chol_prl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,%rbx
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%ebp
lea    0x48(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
xor    %eax,%eax
test   %r14d,%r14d
jle    124e <chol_prl+0x11e>
mov    %r14d,%r13d
mov    %r15d,0x14(%rsp)
mov    %r13,%rdx
mov    %rbx,%rsi
xor    %edi,%edi
mov    %r13,0x38(%rsp)
jmp    11b8 <chol_prl+0x88>
nopw   0x0(%rax,%rax,1)
mov    0x20(%rsp),%rax
add    %r15d,%eax
mov    0x28(%rsp),%rsi
add    $0x8,%rsi
mov    0x30(%rsp),%rdx
add    $0xffffffffffffffff,%rdx
add    %r15d,0x14(%rsp)
mov    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    0x38(%rsp),%r13
cmp    %r13,%rbp
mov    %r14d,%ebp
je     124e <chol_prl+0x11e>
mov    %rdi,0x18(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdx,0x30(%rsp)
mov    0x18(%rsp),%rdx
mov    (%rbx,%rdx,8),%r8
mov    %rax,%rdi
mov    %rax,0x20(%rsp)
mov    %ebp,%esi
mov    %r15d,%edx
mov    %r12d,%ecx
call   1050 <fac_task@plt>
mov    0x18(%rsp),%rcx
lea    0x1(%rcx),%rax
mov    %rax,0x40(%rsp)
cmp    %r13,%rax
mov    %ebp,%r14d
jae    1180 <chol_prl+0x50>
mov    $0x1,%r13d
mov    0x14(%rsp),%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%rbx,%rcx,8),%r9
mov    0x28(%rsp),%rax
mov    (%rax,%r13,8),%rax
mov    %rax,(%rsp)
mov    0x20(%rsp),%rdi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
mov    %r12d,%r8d
call   1040 <upd_task@plt>
mov    0x18(%rsp),%rcx
add    $0x1,%r13
add    %r15d,%ebp
cmp    %r13,0x30(%rsp)
jne    1210 <chol_prl+0xe0>
jmp    1180 <chol_prl+0x50>
lea    0x48(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
define i64 @chol_prl(i32 %0, i32 %1, i32 %2, i32 %3, double** %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double**
%11 = alloca %struct.timeval
%12 = alloca %struct.timeval
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store double** %4, double*** %10
%17 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
store i32 0, i32* %13
store i32 0, i32* %14
br label %18
18: ; preds = %67, %5
%19 = load i32, i32* %14
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %70
22: ; preds = %18
%23 = load i32, i32* %13
%24 = load i32, i32* %6
%25 = load i32, i32* %8
%26 = load i32, i32* %9
%27 = load double**, double*** %10
%28 = load i32, i32* %14
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double*, double** %27, i64 %29
%31 = load double*, double** %30
%32 = call i32 @fac_task(i32 %23, i32 %24, i32 %25, i32 %26, double* %31)
%33 = load i32, i32* %13
store i32 %33, i32* %15
%34 = load i32, i32* %14
%35 = add nsw i32 %34, 1
store i32 %35, i32* %16
br label %36
36: ; preds = %60, %22
%37 = load i32, i32* %16
%38 = load i32, i32* %7
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %63
40: ; preds = %36
%41 = load i32, i32* %8
%42 = load i32, i32* %15
%43 = add nsw i32 %42, %41
store i32 %43, i32* %15
%44 = load i32, i32* %13
%45 = load i32, i32* %15
%46 = load i32, i32* %6
%47 = load i32, i32* %8
%48 = load i32, i32* %9
%49 = load double**, double*** %10
%50 = load i32, i32* %14
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double*, double** %49, i64 %51
%53 = load double*, double** %52
%54 = load double**, double*** %10
%55 = load i32, i32* %16
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds double*, double** %54, i64 %56
%58 = load double*, double** %57
%59 = call i32 @upd_task(i32 %44, i32 %45, i32 %46, i32 %47, i32 %48, double* %53, double* %58)
br label %60
60: ; preds = %40
%61 = load i32, i32* %16
%62 = add nsw i32 %61, 1
store i32 %62, i32* %16
br label %36
63: ; preds = %36
%64 = load i32, i32* %8
%65 = load i32, i32* %13
%66 = add nsw i32 %65, %64
store i32 %66, i32* %13
br label %67
67: ; preds = %63
%68 = load i32, i32* %14
%69 = add nsw i32 %68, 1
store i32 %69, i32* %14
br label %18
70: ; preds = %18
%71 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%72 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 0
%73 = load i32, i32* %72
%74 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 0
%75 = load i32, i32* %74
%76 = sub nsw i32 %73, %75
%77 = mul nsw i32 %76, 1000000
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds %struct.timeval, %struct.timeval* %12, i32 0, i32 1
%80 = load i64, i64* %79
%81 = add i64 %78, %80
%82 = getelementptr inbounds %struct.timeval, %struct.timeval* %11, i32 0, i32 1
%83 = load i64, i64* %82
%84 = sub i64 %81, %83
ret i64 %84
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
define i64 @chol_prl(i32 %0, i32 %1, i32 %2, i32 %3, double** nocapture %4) {
%6 = alloca %struct.timeval
%7 = bitcast %struct.timeval* %6 to i8*
%8 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %36
10: ; preds = %5
%11 = zext i32 %1 to i64
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %10, %32
%14 = phi i64 [ 0, %10 ], [ %20, %32 ]
%15 = phi i64 [ 1, %10 ], [ %34, %32 ]
%16 = phi i32 [ 0, %10 ], [ %33, %32 ]
%17 = getelementptr inbounds double*, double** %4, i64 %14
%18 = load double*, double** %17
%19 = tail call i32 @fac_task(i32 %16, i32 %0, i32 %2, i32 %3, double* %18)
%20 = add nuw nsw i64 %14, 1
%21 = icmp ult i64 %20, %11
br i1 %21, label %22, label %32
22: ; preds = %13, %22
%23 = phi i64 [ %30, %22 ], [ %15, %13 ]
%24 = phi i32 [ %25, %22 ], [ %16, %13 ]
%25 = add nsw i32 %24, %2
%26 = load double*, double** %17
%27 = getelementptr inbounds double*, double** %4, i64 %23
%28 = load double*, double** %27
%29 = tail call i32 @upd_task(i32 %16, i32 %25, i32 %0, i32 %2, i32 %3, double* %26, double* %28)
%30 = add nuw nsw i64 %23, 1
%31 = icmp eq i64 %30, %12
br i1 %31, label %32, label %22
32: ; preds = %22, %13
%33 = add nsw i32 %16, %2
%34 = add nuw nsw i64 %15, 1
%35 = icmp eq i64 %20, %12
br i1 %35, label %36, label %13
36: ; preds = %32, %5
%37 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
ret i64 undef
}