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


x86 assembly (clang, -O0):
<calculate_dt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %esi,-0x2c(%rbp)
mov    %edx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1228 <calculate_dt+0x118>
movsd  0xea8(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm2
mulsd  -0x28(%rbp),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
call   1030 <mmax@plt>
movsd  %xmm0,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
call   1030 <mmax@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm4
movsd  -0x20(%rbp),%xmm5
divsd  -0x50(%rbp),%xmm5
movsd  -0x28(%rbp),%xmm2
divsd  -0x58(%rbp),%xmm2
movaps %xmm2,%xmm6
movaps %xmm5,%xmm3
cmpunordsd %xmm3,%xmm3
movaps %xmm3,%xmm1
pand   %xmm6,%xmm1
minsd  %xmm5,%xmm2
pandn  %xmm2,%xmm3
por    %xmm1,%xmm3
movaps %xmm3,%xmm5
movaps %xmm4,%xmm1
cmpunordsd %xmm1,%xmm1
movaps %xmm1,%xmm2
pand   %xmm5,%xmm2
minsd  %xmm4,%xmm3
pandn  %xmm3,%xmm1
por    %xmm2,%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_dt>:
xorpd  %xmm4,%xmm4
ucomisd %xmm4,%xmm1
jb     11ff <calculate_dt+0xef>
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %r8,%r15
mov    %edx,%ebp
mov    %esi,%ebx
mov    %rdi,%r14
mulsd  0xec6(%rip),%xmm0
movapd %xmm2,%xmm4
movsd  %xmm2,0x10(%rsp)
mulsd  %xmm2,%xmm4
movsd  %xmm1,0x18(%rsp)
movapd %xmm3,%xmm2
mulsd  %xmm3,%xmm2
addsd  %xmm4,%xmm2
mulsd  %xmm3,%xmm4
mulsd  %xmm3,%xmm4
mulsd  %xmm0,%xmm4
divsd  %xmm2,%xmm4
movapd %xmm4,0x30(%rsp)
mov    %rcx,%rdi
movapd %xmm3,0x20(%rsp)
call   1030 <mmax@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <mmax@plt>
movsd  0x10(%rsp),%xmm1
divsd  0x8(%rsp),%xmm1
movapd 0x20(%rsp),%xmm3
divsd  %xmm0,%xmm3
movapd %xmm1,%xmm0
movapd %xmm1,%xmm2
cmpunordsd %xmm1,%xmm0
movapd %xmm0,%xmm1
andpd  %xmm3,%xmm1
minsd  %xmm2,%xmm3
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
movapd %xmm0,%xmm1
movapd 0x30(%rsp),%xmm3
minsd  %xmm3,%xmm1
cmpunordsd %xmm3,%xmm3
movapd %xmm3,%xmm2
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm3
orpd   %xmm2,%xmm3
mulsd  0x18(%rsp),%xmm3
movsd  %xmm3,(%r14)
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @calculate_dt(double %0, double %1, double* %2, double %3, double %4, i32 %5, i32 %6, double** %7, double** %8) {
%10 = alloca double
%11 = alloca double
%12 = alloca double*
%13 = alloca double
%14 = alloca double
%15 = alloca i32
%16 = alloca i32
%17 = alloca double**
%18 = alloca double**
%19 = alloca double
%20 = alloca double
%21 = alloca double
store double %0, double* %10
store double %1, double* %11
store double* %2, double** %12
store double %3, double* %13
store double %4, double* %14
store i32 %5, i32* %15
store i32 %6, i32* %16
store double** %7, double*** %17
store double** %8, double*** %18
%22 = load double, double* %11
%23 = fcmp oge double %22, 0.000000e+00
br i1 %23, label %24, label %62
24: ; preds = %9
%25 = load double, double* %10
%26 = fmul double 5.000000e-01, %25
%27 = load double, double* %13
%28 = load double, double* %13
%29 = fmul double %27, %28
%30 = load double, double* %14
%31 = fmul double %29, %30
%32 = load double, double* %14
%33 = fmul double %31, %32
%34 = fmul double %26, %33
%35 = load double, double* %13
%36 = load double, double* %13
%37 = load double, double* %14
%38 = load double, double* %14
%39 = fmul double %37, %38
%40 = call double @llvm.fmuladd.f64(double %35, double %36, double %39)
%41 = fdiv double %34, %40
store double %41, double* %19
%42 = load double**, double*** %17
%43 = load i32, i32* %15
%44 = load i32, i32* %16
%45 = call double @mmax(double** %42, i32 %43, i32 %44)
store double %45, double* %20
%46 = load double**, double*** %18
%47 = load i32, i32* %15
%48 = load i32, i32* %16
%49 = call double @mmax(double** %46, i32 %47, i32 %48)
store double %49, double* %21
%50 = load double, double* %11
%51 = load double, double* %19
%52 = load double, double* %13
%53 = load double, double* %20
%54 = fdiv double %52, %53
%55 = load double, double* %14
%56 = load double, double* %21
%57 = fdiv double %55, %56
%58 = call double @llvm.minnum.f64(double %54, double %57)
%59 = call double @llvm.minnum.f64(double %51, double %58)
%60 = fmul double %50, %59
%61 = load double*, double** %12
store double %60, double* %61
br label %62
62: ; preds = %24, %9
ret void
}

LLVM IR (-O2):
define void @calculate_dt(double %0, double %1, double* nocapture writeonly %2, double %3, double %4, i32 %5, i32 %6, double** %7, double** %8) {
%10 = fcmp ult double %1, 0.000000e+00
br i1 %10, label %27, label %11
11: ; preds = %9
%12 = fmul double %0, 5.000000e-01
%13 = fmul double %3, %3
%14 = fmul double %13, %4
%15 = fmul double %14, %4
%16 = fmul double %12, %15
%17 = fmul double %4, %4
%18 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %17)
%19 = fdiv double %16, %18
%20 = tail call double @mmax(double** %7, i32 %5, i32 %6)
%21 = tail call double @mmax(double** %8, i32 %5, i32 %6)
%22 = fdiv double %3, %20
%23 = fdiv double %4, %21
%24 = tail call double @llvm.minnum.f64(double %22, double %23)
%25 = tail call double @llvm.minnum.f64(double %19, double %24)
%26 = fmul double %25, %1
store double %26, double* %2
br label %27
27: ; preds = %11, %9
ret void
}