; LLVM IR from OpenFAST/openfast :: modules/map/src (residual)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind
declare double @log(double noundef) #0

; Function Attrs: nounwind
declare double @sqrt(double noundef) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #0

; Function Attrs: nounwind uwtable
define dso_local double @residual_function_length_contact(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6) #2 {
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store double %0, ptr %9, align 8, !tbaa !5
  store double %1, ptr %10, align 8, !tbaa !5
  store double %2, ptr %11, align 8, !tbaa !5
  store double %3, ptr %12, align 8, !tbaa !5
  store double %4, ptr %13, align 8, !tbaa !5
  store double %5, ptr %14, align 8, !tbaa !5
  store double %6, ptr %15, align 8, !tbaa !5
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fneg double %16
  %18 = load double, ptr %9, align 8, !tbaa !5
  %19 = load double, ptr %11, align 8, !tbaa !5
  %20 = load double, ptr %12, align 8, !tbaa !5
  %21 = fneg double %19
  %22 = call double @llvm.fmuladd.f64(double %21, double %20, double %18)
  %23 = fmul double %17, %22
  %24 = load double, ptr %10, align 8, !tbaa !5
  %25 = fcmp olt double %23, %24
  br i1 %25, label %26, label %74

26:                                               ; preds = %7
  %27 = load double, ptr %9, align 8, !tbaa !5
  %28 = load double, ptr %10, align 8, !tbaa !5
  %29 = fdiv double %27, %28
  %30 = load double, ptr %9, align 8, !tbaa !5
  %31 = load double, ptr %10, align 8, !tbaa !5
  %32 = fdiv double %30, %31
  %33 = call double @pow(double noundef %32, double noundef 2.000000e+00) #3
  %34 = fadd double 1.000000e+00, %33
  %35 = call double @sqrt(double noundef %34) #3
  %36 = fadd double %29, %35
  %37 = call double @log(double noundef %36) #3
  %38 = load double, ptr %10, align 8, !tbaa !5
  %39 = load double, ptr %11, align 8, !tbaa !5
  %40 = fdiv double %38, %39
  %41 = load double, ptr %15, align 8, !tbaa !5
  %42 = load double, ptr %13, align 8, !tbaa !5
  %43 = fdiv double %41, %42
  %44 = fmul double 5.000000e-01, %43
  %45 = load double, ptr %11, align 8, !tbaa !5
  %46 = fmul double %44, %45
  %47 = load double, ptr %12, align 8, !tbaa !5
  %48 = load double, ptr %9, align 8, !tbaa !5
  %49 = load double, ptr %11, align 8, !tbaa !5
  %50 = fdiv double %48, %49
  %51 = fsub double %47, %50
  %52 = fmul double %46, %51
  %53 = load double, ptr %12, align 8, !tbaa !5
  %54 = load double, ptr %9, align 8, !tbaa !5
  %55 = load double, ptr %11, align 8, !tbaa !5
  %56 = fdiv double %54, %55
  %57 = fsub double %53, %56
  %58 = fmul double %52, %57
  %59 = fneg double %58
  %60 = call double @llvm.fmuladd.f64(double %37, double %40, double %59)
  %61 = load double, ptr %12, align 8, !tbaa !5
  %62 = load double, ptr %13, align 8, !tbaa !5
  %63 = fdiv double %61, %62
  %64 = load double, ptr %10, align 8, !tbaa !5
  %65 = call double @llvm.fmuladd.f64(double %63, double %64, double %60)
  %66 = load double, ptr %12, align 8, !tbaa !5
  %67 = load double, ptr %9, align 8, !tbaa !5
  %68 = load double, ptr %11, align 8, !tbaa !5
  %69 = fdiv double %67, %68
  %70 = fsub double %66, %69
  %71 = fadd double %65, %70
  %72 = load double, ptr %14, align 8, !tbaa !5
  %73 = fsub double %71, %72
  store double %73, ptr %8, align 8
  br label %146

74:                                               ; preds = %7
  %75 = load double, ptr %9, align 8, !tbaa !5
  %76 = load double, ptr %10, align 8, !tbaa !5
  %77 = fdiv double %75, %76
  %78 = load double, ptr %9, align 8, !tbaa !5
  %79 = load double, ptr %10, align 8, !tbaa !5
  %80 = fdiv double %78, %79
  %81 = call double @pow(double noundef %80, double noundef 2.000000e+00) #3
  %82 = fadd double 1.000000e+00, %81
  %83 = call double @sqrt(double noundef %82) #3
  %84 = fadd double %77, %83
  %85 = call double @log(double noundef %84) #3
  %86 = load double, ptr %10, align 8, !tbaa !5
  %87 = load double, ptr %11, align 8, !tbaa !5
  %88 = fdiv double %86, %87
  %89 = load double, ptr %15, align 8, !tbaa !5
  %90 = load double, ptr %13, align 8, !tbaa !5
  %91 = fdiv double %89, %90
  %92 = fmul double 5.000000e-01, %91
  %93 = load double, ptr %11, align 8, !tbaa !5
  %94 = fmul double %92, %93
  %95 = load double, ptr %12, align 8, !tbaa !5
  %96 = load double, ptr %9, align 8, !tbaa !5
  %97 = load double, ptr %11, align 8, !tbaa !5
  %98 = fdiv double %96, %97
  %99 = fsub double %95, %98
  %100 = load double, ptr %12, align 8, !tbaa !5
  %101 = load double, ptr %9, align 8, !tbaa !5
  %102 = load double, ptr %11, align 8, !tbaa !5
  %103 = fdiv double %101, %102
  %104 = fsub double %100, %103
  %105 = load double, ptr %12, align 8, !tbaa !5
  %106 = load double, ptr %9, align 8, !tbaa !5
  %107 = load double, ptr %11, align 8, !tbaa !5
  %108 = fdiv double %106, %107
  %109 = fsub double %105, %108
  %110 = load double, ptr %10, align 8, !tbaa !5
  %111 = load double, ptr %11, align 8, !tbaa !5
  %112 = fdiv double %110, %111
  %113 = load double, ptr %15, align 8, !tbaa !5
  %114 = fdiv double %112, %113
  %115 = fsub double %109, %114
  %116 = load double, ptr %12, align 8, !tbaa !5
  %117 = load double, ptr %9, align 8, !tbaa !5
  %118 = load double, ptr %11, align 8, !tbaa !5
  %119 = fdiv double %117, %118
  %120 = fsub double %116, %119
  %121 = load double, ptr %10, align 8, !tbaa !5
  %122 = load double, ptr %11, align 8, !tbaa !5
  %123 = fdiv double %121, %122
  %124 = load double, ptr %15, align 8, !tbaa !5
  %125 = fdiv double %123, %124
  %126 = fsub double %120, %125
  %127 = fmul double %115, %126
  %128 = fneg double %127
  %129 = call double @llvm.fmuladd.f64(double %99, double %104, double %128)
  %130 = fmul double %94, %129
  %131 = fneg double %130
  %132 = call double @llvm.fmuladd.f64(double %85, double %88, double %131)
  %133 = load double, ptr %12, align 8, !tbaa !5
  %134 = load double, ptr %13, align 8, !tbaa !5
  %135 = fdiv double %133, %134
  %136 = load double, ptr %10, align 8, !tbaa !5
  %137 = call double @llvm.fmuladd.f64(double %135, double %136, double %132)
  %138 = load double, ptr %12, align 8, !tbaa !5
  %139 = load double, ptr %9, align 8, !tbaa !5
  %140 = load double, ptr %11, align 8, !tbaa !5
  %141 = fdiv double %139, %140
  %142 = fsub double %138, %141
  %143 = fadd double %137, %142
  %144 = load double, ptr %14, align 8, !tbaa !5
  %145 = fsub double %143, %144
  store double %145, ptr %8, align 8
  br label %146

146:                                              ; preds = %74, %26
  %147 = load double, ptr %8, align 8
  ret double %147
}

attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write) uwtable
define dso_local double @residual_function_length_contact(double noundef %0, double noundef %1, double noundef %2, double noundef %3, double noundef %4, double noundef %5, double noundef %6) local_unnamed_addr #2 {
  %8 = fneg double %6
  %9 = fneg double %2
  %10 = tail call double @llvm.fmuladd.f64(double %9, double %3, double %0)
  %11 = fmul double %10, %8
  %12 = fcmp olt double %11, %1
  %13 = fdiv double %0, %1
  %square63 = fmul double %13, %13
  %14 = fadd double %square63, 1.000000e+00
  %sqrt = tail call double @llvm.sqrt.f64(double %14)
  %15 = fadd double %13, %sqrt
  %16 = tail call double @log(double noundef %15) #4
  %17 = fdiv double %1, %2
  %18 = fdiv double %6, %4
  %19 = fdiv double %0, %2
  %20 = fsub double %3, %19
  br i1 %12, label %21, label %26

21:                                               ; preds = %7
  %22 = fmul double %18, -5.000000e-01
  %23 = fmul double %22, %2
  %24 = fmul double %20, %23
  %25 = fmul double %20, %24
  br label %35

26:                                               ; preds = %7
  %27 = fdiv double %17, %6
  %28 = fsub double %20, %27
  %29 = fneg double %28
  %30 = fmul double %28, %29
  %31 = tail call double @llvm.fmuladd.f64(double %20, double %20, double %30)
  %32 = fmul double %18, -5.000000e-01
  %33 = fmul double %32, %2
  %34 = fmul double %33, %31
  br label %35

35:                                               ; preds = %26, %21
  %.sink = phi double [ %34, %26 ], [ %25, %21 ]
  %36 = tail call double @llvm.fmuladd.f64(double %16, double %17, double %.sink)
  %37 = fdiv double %3, %4
  %38 = tail call double @llvm.fmuladd.f64(double %37, double %1, double %36)
  %39 = fadd double %20, %38
  %.0 = fsub double %39, %5
  ret double %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #3

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass