#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 /*<<< orphan*/ printf(char *, int, double, double, double);
void shear_stress_calc(double *x_loc, double dx, double dy, int imax,
                       double **U, double **V) {
  int i;
  double dv_dx, du_dy, stress, stress_ahead;
  du_dy = (U[imax][2] - U[imax][0]) / (2 * dy);
  dv_dx = (V[imax + 1][1] - V[imax - 1][1]) / (2 * dx);
  stress_ahead = du_dy + dv_dx;
  for (i = imax - 1; i > 1; i--) {
    du_dy = (U[i][2] - U[i][0]) / (2 * dy);
    dv_dx = (V[i + 1][1] - V[i - 1][1]) / (2 * dx);
    stress = du_dy + dv_dx;
    if (stress_ahead > 0 && stress < 0) {
      *x_loc = i * dx;
      break;
    }
    stress_ahead = stress;
    printf("%f \t %f \t %f \t %f \n ", (i * dx), stress, du_dy, dv_dx);
  }
}


x86 assembly (clang, -O0):
<shear_stress_calc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  0x10(%rax),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
subsd  (%rax),%xmm0
movsd  0xea6(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsd  0x8(%rax),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
subsd  0x8(%rax),%xmm0
movsd  0xe64(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x1,-0x34(%rbp)
jle    12cc <shear_stress_calc+0x1bc>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsd  0x10(%rax),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
subsd  (%rax),%xmm0
movsd  0xe0b(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
movsd  0x8(%rax),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
subsd  0x8(%rax),%xmm0
movsd  0xdc9(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    128b <shear_stress_calc+0x17b>
xorps  %xmm0,%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    128b <shear_stress_calc+0x17b>
cvtsi2sdl -0x34(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12cc <shear_stress_calc+0x1bc>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
cvtsi2sdl -0x34(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%esi
movsd  -0x50(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
lea    0xd4f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    11c2 <shear_stress_calc+0xb2>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shear_stress_calc>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
movapd %xmm0,(%rsp)
cmp    $0x3,%esi
jl     1224 <shear_stress_calc+0x114>
mov    %rcx,%r13
mov    %rdx,%r14
mov    %rdi,%r15
movslq %esi,%rax
mov    (%rdx,%rax,8),%rcx
add    $0xffffffff,%eax
movapd %xmm1,%xmm2
unpcklpd (%rsp),%xmm2
addpd  %xmm2,%xmm2
mov    %esi,%edx
mov    0x8(%r13,%rdx,8),%rdx
mov    %eax,%ebx
mov    0x0(%r13,%rbx,8),%rax
movsd  (%rcx),%xmm0
movsd  0x10(%rcx),%xmm1
movhpd 0x8(%rdx),%xmm1
movhpd 0x8(%rax),%xmm0
subpd  %xmm0,%xmm1
movapd %xmm2,0x10(%rsp)
divpd  %xmm2,%xmm1
movapd %xmm1,%xmm3
unpckhpd %xmm1,%xmm3
addsd  %xmm1,%xmm3
xorpd  %xmm5,%xmm5
lea    0xe6f(%rip),%r12
jmp    11c6 <shear_stress_calc+0xb6>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cvttsd2si %xmm4,%esi
mov    %r12,%rdi
movapd %xmm0,0x20(%rsp)
call   1030 <printf@plt>
xorpd  %xmm5,%xmm5
movapd 0x20(%rsp),%xmm3
lea    0x1(%rbx),%rax
cmp    $0x2,%rax
jbe    1224 <shear_stress_calc+0x114>
mov    (%r14,%rbx,8),%rax
mov    0x8(%r13,%rbx,8),%rcx
xorps  %xmm4,%xmm4
cvtsi2sd %ebx,%xmm4
add    $0xffffffffffffffff,%rbx
mov    %ebx,%edx
mov    0x0(%r13,%rdx,8),%rdx
movsd  (%rax),%xmm2
movsd  0x10(%rax),%xmm1
movhpd 0x8(%rcx),%xmm1
movhpd 0x8(%rdx),%xmm2
subpd  %xmm2,%xmm1
divpd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
ucomisd %xmm5,%xmm3
movapd %xmm1,%xmm0
addsd  %xmm2,%xmm0
mulsd  (%rsp),%xmm4
jbe    11a0 <shear_stress_calc+0x90>
ucomisd %xmm0,%xmm5
jbe    11a0 <shear_stress_calc+0x90>
movsd  %xmm4,(%r15)
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"%f \09 %f \09 %f \09 %f \0A \00"
define void @shear_stress_calc(double* %0, double %1, double %2, i32 %3, double** %4, double** %5) {
%7 = alloca double*
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca double**
%12 = alloca double**
%13 = alloca i32
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
store double* %0, double** %7
store double %1, double* %8
store double %2, double* %9
store i32 %3, i32* %10
store double** %4, double*** %11
store double** %5, double*** %12
%18 = load double**, double*** %11
%19 = load i32, i32* %10
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double*, double** %18, i64 %20
%22 = load double*, double** %21
%23 = getelementptr inbounds double, double* %22, i64 2
%24 = load double, double* %23
%25 = load double**, double*** %11
%26 = load i32, i32* %10
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double*, double** %25, i64 %27
%29 = load double*, double** %28
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = fsub double %24, %31
%33 = load double, double* %9
%34 = fmul double 2.000000e+00, %33
%35 = fdiv double %32, %34
store double %35, double* %15
%36 = load double**, double*** %12
%37 = load i32, i32* %10
%38 = add nsw i32 %37, 1
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double*, double** %36, i64 %39
%41 = load double*, double** %40
%42 = getelementptr inbounds double, double* %41, i64 1
%43 = load double, double* %42
%44 = load double**, double*** %12
%45 = load i32, i32* %10
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double*, double** %44, i64 %47
%49 = load double*, double** %48
%50 = getelementptr inbounds double, double* %49, i64 1
%51 = load double, double* %50
%52 = fsub double %43, %51
%53 = load double, double* %8
%54 = fmul double 2.000000e+00, %53
%55 = fdiv double %52, %54
store double %55, double* %14
%56 = load double, double* %15
%57 = load double, double* %14
%58 = fadd double %56, %57
store double %58, double* %17
%59 = load i32, i32* %10
%60 = sub nsw i32 %59, 1
store i32 %60, i32* %13
br label %61
61: ; preds = %128, %6
%62 = load i32, i32* %13
%63 = icmp sgt i32 %62, 1
br i1 %63, label %64, label %131
64: ; preds = %61
%65 = load double**, double*** %11
%66 = load i32, i32* %13
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds double*, double** %65, i64 %67
%69 = load double*, double** %68
%70 = getelementptr inbounds double, double* %69, i64 2
%71 = load double, double* %70
%72 = load double**, double*** %11
%73 = load i32, i32* %13
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double*, double** %72, i64 %74
%76 = load double*, double** %75
%77 = getelementptr inbounds double, double* %76, i64 0
%78 = load double, double* %77
%79 = fsub double %71, %78
%80 = load double, double* %9
%81 = fmul double 2.000000e+00, %80
%82 = fdiv double %79, %81
store double %82, double* %15
%83 = load double**, double*** %12
%84 = load i32, i32* %13
%85 = add nsw i32 %84, 1
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds double*, double** %83, i64 %86
%88 = load double*, double** %87
%89 = getelementptr inbounds double, double* %88, i64 1
%90 = load double, double* %89
%91 = load double**, double*** %12
%92 = load i32, i32* %13
%93 = sub nsw i32 %92, 1
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds double*, double** %91, i64 %94
%96 = load double*, double** %95
%97 = getelementptr inbounds double, double* %96, i64 1
%98 = load double, double* %97
%99 = fsub double %90, %98
%100 = load double, double* %8
%101 = fmul double 2.000000e+00, %100
%102 = fdiv double %99, %101
store double %102, double* %14
%103 = load double, double* %15
%104 = load double, double* %14
%105 = fadd double %103, %104
store double %105, double* %16
%106 = load double, double* %17
%107 = fcmp ogt double %106, 0.000000e+00
br i1 %107, label %108, label %117
108: ; preds = %64
%109 = load double, double* %16
%110 = fcmp olt double %109, 0.000000e+00
br i1 %110, label %111, label %117
111: ; preds = %108
%112 = load i32, i32* %13
%113 = sitofp i32 %112 to double
%114 = load double, double* %8
%115 = fmul double %113, %114
%116 = load double*, double** %7
store double %115, double* %116
br label %131
117: ; preds = %108, %64
%118 = load double, double* %16
store double %118, double* %17
%119 = load i32, i32* %13
%120 = sitofp i32 %119 to double
%121 = load double, double* %8
%122 = fmul double %120, %121
%123 = fptosi double %122 to i32
%124 = load double, double* %16
%125 = load double, double* %15
%126 = load double, double* %14
%127 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %123, double %124, double %125, double %126)
br label %128
128: ; preds = %117
%129 = load i32, i32* %13
%130 = add nsw i32 %129, -1
store i32 %130, i32* %13
br label %61
131: ; preds = %111, %61
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"%f \09 %f \09 %f \09 %f \0A \00"
define void @shear_stress_calc(double* nocapture writeonly %0, double %1, double %2, i32 %3, double** nocapture %4, double** nocapture %5) {
%7 = sext i32 %3 to i64
%8 = getelementptr inbounds double*, double** %4, i64 %7
%9 = load double*, double** %8
%10 = add nsw i32 %3, -1
%11 = insertelement <2 x double> poison, double %2, i64 0
%12 = insertelement <2 x double> %11, double %1, i64 1
%13 = fmul <2 x double> %12, <double 2.000000e+00, double 2.000000e+00>
%14 = icmp sgt i32 %3, 2
br i1 %14, label %15, label %79
15: ; preds = %6
%16 = getelementptr inbounds double, double* %9, i64 2
%17 = load double, double* %16
%18 = load double, double* %9
%19 = add nuw nsw i32 %3, 1
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds double*, double** %5, i64 %20
%22 = load double*, double** %21
%23 = getelementptr inbounds double, double* %22, i64 1
%24 = load double, double* %23
%25 = zext i32 %10 to i64
%26 = getelementptr inbounds double*, double** %5, i64 %25
%27 = load double*, double** %26
%28 = getelementptr inbounds double, double* %27, i64 1
%29 = load double, double* %28
%30 = insertelement <2 x double> poison, double %17, i64 0
%31 = insertelement <2 x double> %30, double %24, i64 1
%32 = insertelement <2 x double> poison, double %18, i64 0
%33 = insertelement <2 x double> %32, double %29, i64 1
%34 = fsub <2 x double> %31, %33
%35 = fdiv <2 x double> %34, %13
%36 = shufflevector <2 x double> %35, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%37 = fadd <2 x double> %35, %36
%38 = extractelement <2 x double> %37, i64 0
%39 = zext i32 %10 to i64
br label %40
40: ; preds = %15, %75
%41 = phi i64 [ %39, %15 ], [ %53, %75 ]
%42 = phi double [ %38, %15 ], [ %67, %75 ]
%43 = getelementptr inbounds double*, double** %4, i64 %41
%44 = load double*, double** %43
%45 = getelementptr inbounds double, double* %44, i64 2
%46 = load double, double* %45
%47 = load double, double* %44
%48 = add nuw nsw i64 %41, 1
%49 = getelementptr inbounds double*, double** %5, i64 %48
%50 = load double*, double** %49
%51 = getelementptr inbounds double, double* %50, i64 1
%52 = load double, double* %51
%53 = add nsw i64 %41, -1
%54 = and i64 %53, 4294967295
%55 = getelementptr inbounds double*, double** %5, i64 %54
%56 = load double*, double** %55
%57 = getelementptr inbounds double, double* %56, i64 1
%58 = load double, double* %57
%59 = insertelement <2 x double> poison, double %46, i64 0
%60 = insertelement <2 x double> %59, double %52, i64 1
%61 = insertelement <2 x double> poison, double %47, i64 0
%62 = insertelement <2 x double> %61, double %58, i64 1
%63 = fsub <2 x double> %60, %62
%64 = fdiv <2 x double> %63, %13
%65 = extractelement <2 x double> %64, i64 0
%66 = extractelement <2 x double> %64, i64 1
%67 = fadd double %65, %66
%68 = fcmp ogt double %42, 0.000000e+00
%69 = fcmp olt double %67, 0.000000e+00
%70 = select i1 %68, i1 %69, i1 false
%71 = trunc i64 %41 to i32
%72 = sitofp i32 %71 to double
%73 = fmul double %72, %1
br i1 %70, label %74, label %75
74: ; preds = %40
store double %73, double* %0
br label %79
75: ; preds = %40
%76 = fptosi double %73 to i32
%77 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %76, double %67, double %65, double %66)
%78 = icmp ugt i64 %41, 2
br i1 %78, label %40, label %79
79: ; preds = %75, %6, %74
ret void
}