#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 */
double fmin(double, double);
double tmax(double ***, int, int, int);
void calculate_dt(double Re, double tau, double *dt, double dx, double dy,
                  double dz, int imax, int jmax, int kmax, double ***U,
                  double ***V, double ***W) {
  double maxi1, maxi2, maxi3;
  if (tau >= 0) {
    *dt = 0.5 * Re *
          (1.0 / (1.0 / (dx * dx) + 1.0 / (dy * dy) + 1.0 / (dz * dz)));
    maxi1 = tmax(U, imax, jmax, kmax);
    maxi2 = tmax(V, imax, jmax, kmax);
    maxi3 = tmax(W, imax, jmax, kmax);
    if (maxi1 > 0) {
      *dt = fmin(*dt, dx / maxi1);
    }
    if (maxi2 > 0) {
      *dt = fmin(*dt, dy / maxi2);
    }
    if (maxi3 > 0) {
      *dt = fmin(*dt, dz / maxi3);
    }
    *dt = tau * (*dt);
  }
}


x86 assembly (clang, -O0):
<calculate_dt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
mov    %esi,-0x34(%rbp)
mov    %edx,-0x38(%rbp)
mov    %ecx,-0x3c(%rbp)
mov    %r8,-0x48(%rbp)
mov    %r9,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1303 <calculate_dt+0x1f3>
movsd  0xea4(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  0xe85(%rip),%xmm2
divsd  %xmm1,%xmm2
movsd  -0x28(%rbp),%xmm3
mulsd  -0x28(%rbp),%xmm3
movsd  0xe6f(%rip),%xmm1
divsd  %xmm3,%xmm1
addsd  %xmm1,%xmm2
movsd  -0x30(%rbp),%xmm3
mulsd  -0x30(%rbp),%xmm3
movsd  0xe55(%rip),%xmm1
divsd  %xmm3,%xmm1
addsd  %xmm1,%xmm2
movsd  0xe45(%rip),%xmm1
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
call   1030 <tmax@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
call   1030 <tmax@plt>
movsd  %xmm0,-0x60(%rbp)
mov    0x10(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
mov    -0x3c(%rbp),%ecx
call   1030 <tmax@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    125a <calculate_dt+0x14a>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm3
movsd  -0x20(%rbp),%xmm2
divsd  -0x58(%rbp),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordsd %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
minsd  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12a4 <calculate_dt+0x194>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm3
movsd  -0x28(%rbp),%xmm2
divsd  -0x60(%rbp),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordsd %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
minsd  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x68(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12ee <calculate_dt+0x1de>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm3
movsd  -0x30(%rbp),%xmm2
divsd  -0x68(%rbp),%xmm2
movaps %xmm2,%xmm4
movaps %xmm3,%xmm0
cmpunordsd %xmm0,%xmm0
movaps %xmm0,%xmm1
pand   %xmm4,%xmm1
minsd  %xmm3,%xmm2
pandn  %xmm2,%xmm0
por    %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_dt>:
xorpd  %xmm5,%xmm5
ucomisd %xmm5,%xmm1
jb     12b0 <calculate_dt+0x1a0>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,%r12
mov    %ecx,%r15d
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
movsd  %xmm1,0x18(%rsp)
mov    0x90(%rsp),%r13
mulsd  0xeb1(%rip),%xmm0
movapd %xmm2,0x20(%rsp)
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movsd  0xea3(%rip),%xmm2
movapd %xmm2,%xmm6
divsd  %xmm1,%xmm6
movapd %xmm3,0x30(%rsp)
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm2,%xmm5
divsd  %xmm1,%xmm5
addsd  %xmm6,%xmm5
movapd %xmm4,0x40(%rsp)
movapd %xmm4,%xmm1
mulsd  %xmm4,%xmm1
movapd %xmm2,%xmm3
divsd  %xmm1,%xmm3
addsd  %xmm5,%xmm3
divsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,(%rdi)
mov    %r8,%rdi
call   1030 <tmax@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
call   1030 <tmax@plt>
movsd  %xmm0,0x10(%rsp)
mov    %r13,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
call   1030 <tmax@plt>
movsd  0x8(%rsp),%xmm2
ucomisd 0xe23(%rip),%xmm2
jbe    1220 <calculate_dt+0x110>
movsd  (%r14),%xmm1
movapd 0x20(%rsp),%xmm4
divsd  %xmm2,%xmm4
movapd %xmm1,%xmm2
cmpunordsd %xmm1,%xmm2
movapd %xmm2,%xmm3
andpd  %xmm4,%xmm3
minsd  %xmm1,%xmm4
andnpd %xmm4,%xmm2
orpd   %xmm3,%xmm2
movlpd %xmm2,(%r14)
xorpd  %xmm1,%xmm1
movsd  0x10(%rsp),%xmm3
ucomisd %xmm1,%xmm3
jbe    1261 <calculate_dt+0x151>
movsd  (%r14),%xmm2
movapd 0x30(%rsp),%xmm5
divsd  %xmm3,%xmm5
movapd %xmm2,%xmm3
cmpunordsd %xmm2,%xmm3
movapd %xmm3,%xmm4
andpd  %xmm5,%xmm4
minsd  %xmm2,%xmm5
andnpd %xmm5,%xmm3
orpd   %xmm4,%xmm3
movlpd %xmm3,(%r14)
ucomisd %xmm1,%xmm0
movsd  (%r14),%xmm1
movapd 0x40(%rsp),%xmm3
jbe    1297 <calculate_dt+0x187>
divsd  %xmm0,%xmm3
movapd %xmm1,%xmm0
cmpunordsd %xmm1,%xmm0
movapd %xmm0,%xmm2
andpd  %xmm3,%xmm2
minsd  %xmm1,%xmm3
andnpd %xmm3,%xmm0
orpd   %xmm2,%xmm0
movapd %xmm0,%xmm1
mulsd  0x18(%rsp),%xmm1
movsd  %xmm1,(%r14)
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @calculate_dt(double %0, double %1, double* %2, double %3, double %4, double %5, i32 %6, i32 %7, i32 %8, double*** %9, double*** %10, double*** %11) {
%13 = alloca double
%14 = alloca double
%15 = alloca double*
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca double***
%23 = alloca double***
%24 = alloca double***
%25 = alloca double
%26 = alloca double
%27 = alloca double
store double %0, double* %13
store double %1, double* %14
store double* %2, double** %15
store double %3, double* %16
store double %4, double* %17
store double %5, double* %18
store i32 %6, i32* %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store double*** %9, double**** %22
store double*** %10, double**** %23
store double*** %11, double**** %24
%28 = load double, double* %14
%29 = fcmp oge double %28, 0.000000e+00
br i1 %29, label %30, label %103
30: ; preds = %12
%31 = load double, double* %13
%32 = fmul double 5.000000e-01, %31
%33 = load double, double* %16
%34 = load double, double* %16
%35 = fmul double %33, %34
%36 = fdiv double 1.000000e+00, %35
%37 = load double, double* %17
%38 = load double, double* %17
%39 = fmul double %37, %38
%40 = fdiv double 1.000000e+00, %39
%41 = fadd double %36, %40
%42 = load double, double* %18
%43 = load double, double* %18
%44 = fmul double %42, %43
%45 = fdiv double 1.000000e+00, %44
%46 = fadd double %41, %45
%47 = fdiv double 1.000000e+00, %46
%48 = fmul double %32, %47
%49 = load double*, double** %15
store double %48, double* %49
%50 = load double***, double**** %22
%51 = load i32, i32* %19
%52 = load i32, i32* %20
%53 = load i32, i32* %21
%54 = call double @tmax(double*** %50, i32 %51, i32 %52, i32 %53)
store double %54, double* %25
%55 = load double***, double**** %23
%56 = load i32, i32* %19
%57 = load i32, i32* %20
%58 = load i32, i32* %21
%59 = call double @tmax(double*** %55, i32 %56, i32 %57, i32 %58)
store double %59, double* %26
%60 = load double***, double**** %24
%61 = load i32, i32* %19
%62 = load i32, i32* %20
%63 = load i32, i32* %21
%64 = call double @tmax(double*** %60, i32 %61, i32 %62, i32 %63)
store double %64, double* %27
%65 = load double, double* %25
%66 = fcmp ogt double %65, 0.000000e+00
br i1 %66, label %67, label %75
67: ; preds = %30
%68 = load double*, double** %15
%69 = load double, double* %68
%70 = load double, double* %16
%71 = load double, double* %25
%72 = fdiv double %70, %71
%73 = call double @llvm.minnum.f64(double %69, double %72)
%74 = load double*, double** %15
store double %73, double* %74
br label %75
75: ; preds = %67, %30
%76 = load double, double* %26
%77 = fcmp ogt double %76, 0.000000e+00
br i1 %77, label %78, label %86
78: ; preds = %75
%79 = load double*, double** %15
%80 = load double, double* %79
%81 = load double, double* %17
%82 = load double, double* %26
%83 = fdiv double %81, %82
%84 = call double @llvm.minnum.f64(double %80, double %83)
%85 = load double*, double** %15
store double %84, double* %85
br label %86
86: ; preds = %78, %75
%87 = load double, double* %27
%88 = fcmp ogt double %87, 0.000000e+00
br i1 %88, label %89, label %97
89: ; preds = %86
%90 = load double*, double** %15
%91 = load double, double* %90
%92 = load double, double* %18
%93 = load double, double* %27
%94 = fdiv double %92, %93
%95 = call double @llvm.minnum.f64(double %91, double %94)
%96 = load double*, double** %15
store double %95, double* %96
br label %97
97: ; preds = %89, %86
%98 = load double, double* %14
%99 = load double*, double** %15
%100 = load double, double* %99
%101 = fmul double %98, %100
%102 = load double*, double** %15
store double %101, double* %102
br label %103
103: ; preds = %97, %12
ret void
}

LLVM IR (-O2):
define void @calculate_dt(double %0, double %1, double* nocapture %2, double %3, double %4, double %5, i32 %6, i32 %7, i32 %8, double*** %9, double*** %10, double*** %11) {
%13 = fcmp ult double %1, 0.000000e+00
br i1 %13, label %49, label %14
14: ; preds = %12
%15 = fmul double %0, 5.000000e-01
%16 = fmul double %3, %3
%17 = fdiv double 1.000000e+00, %16
%18 = fmul double %4, %4
%19 = fdiv double 1.000000e+00, %18
%20 = fadd double %17, %19
%21 = fmul double %5, %5
%22 = fdiv double 1.000000e+00, %21
%23 = fadd double %20, %22
%24 = fdiv double 1.000000e+00, %23
%25 = fmul double %15, %24
store double %25, double* %2
%26 = tail call double @tmax(double*** %9, i32 %6, i32 %7, i32 %8)
%27 = tail call double @tmax(double*** %10, i32 %6, i32 %7, i32 %8)
%28 = tail call double @tmax(double*** %11, i32 %6, i32 %7, i32 %8)
%29 = fcmp ogt double %26, 0.000000e+00
br i1 %29, label %30, label %34
30: ; preds = %14
%31 = load double, double* %2
%32 = fdiv double %3, %26
%33 = tail call double @llvm.minnum.f64(double %31, double %32)
store double %33, double* %2
br label %34
34: ; preds = %30, %14
%35 = fcmp ogt double %27, 0.000000e+00
br i1 %35, label %36, label %40
36: ; preds = %34
%37 = load double, double* %2
%38 = fdiv double %4, %27
%39 = tail call double @llvm.minnum.f64(double %37, double %38)
store double %39, double* %2
br label %40
40: ; preds = %36, %34
%41 = fcmp ogt double %28, 0.000000e+00
%42 = load double, double* %2
br i1 %41, label %43, label %46
43: ; preds = %40
%44 = fdiv double %5, %28
%45 = tail call double @llvm.minnum.f64(double %42, double %44)
br label %46
46: ; preds = %40, %43
%47 = phi double [ %45, %43 ], [ %42, %40 ]
%48 = fmul double %47, %1
store double %48, double* %2
br label %49
49: ; preds = %46, %12
ret void
}