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

; 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 uwtable
define dso_local double @enorm(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca i32, align 4
  %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 i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store double 0.000000e+00, ptr %8, align 8, !tbaa !11
  store double 0.000000e+00, ptr %9, align 8, !tbaa !11
  store double 0.000000e+00, ptr %10, align 8, !tbaa !11
  store double 0.000000e+00, ptr %12, align 8, !tbaa !11
  store double 0.000000e+00, ptr %13, align 8, !tbaa !11
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = sitofp i32 %16 to double
  store double %17, ptr %15, align 8, !tbaa !11
  %18 = load double, ptr %15, align 8, !tbaa !11
  %19 = fdiv double 0x5FECCCCCCCCCCCCC, %18
  store double %19, ptr %14, align 8, !tbaa !11
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %97, %2
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %100

24:                                               ; preds = %20
  %25 = load ptr, ptr %4, align 8, !tbaa !9
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds double, ptr %25, i64 %27
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = call double @llvm.fabs.f64(double %29)
  store double %30, ptr %11, align 8, !tbaa !11
  %31 = load double, ptr %11, align 8, !tbaa !11
  %32 = fcmp ole double %31, 0x1FFCCCCCCCCCCCCD
  br i1 %32, label %37, label %33

33:                                               ; preds = %24
  %34 = load double, ptr %11, align 8, !tbaa !11
  %35 = load double, ptr %14, align 8, !tbaa !11
  %36 = fcmp oge double %34, %35
  br i1 %36, label %37, label %91

37:                                               ; preds = %33, %24
  %38 = load double, ptr %11, align 8, !tbaa !11
  %39 = fcmp ogt double %38, 0x1FFCCCCCCCCCCCCD
  br i1 %39, label %40, label %63

40:                                               ; preds = %37
  %41 = load double, ptr %11, align 8, !tbaa !11
  %42 = load double, ptr %12, align 8, !tbaa !11
  %43 = fcmp ogt double %41, %42
  br i1 %43, label %44, label %54

44:                                               ; preds = %40
  %45 = load double, ptr %12, align 8, !tbaa !11
  %46 = load double, ptr %11, align 8, !tbaa !11
  %47 = fdiv double %45, %46
  store double %47, ptr %6, align 8, !tbaa !11
  %48 = load double, ptr %8, align 8, !tbaa !11
  %49 = load double, ptr %6, align 8, !tbaa !11
  %50 = load double, ptr %6, align 8, !tbaa !11
  %51 = fmul double %49, %50
  %52 = call double @llvm.fmuladd.f64(double %48, double %51, double 1.000000e+00)
  store double %52, ptr %8, align 8, !tbaa !11
  %53 = load double, ptr %11, align 8, !tbaa !11
  store double %53, ptr %12, align 8, !tbaa !11
  br label %62

54:                                               ; preds = %40
  %55 = load double, ptr %11, align 8, !tbaa !11
  %56 = load double, ptr %12, align 8, !tbaa !11
  %57 = fdiv double %55, %56
  store double %57, ptr %6, align 8, !tbaa !11
  %58 = load double, ptr %6, align 8, !tbaa !11
  %59 = load double, ptr %6, align 8, !tbaa !11
  %60 = load double, ptr %8, align 8, !tbaa !11
  %61 = call double @llvm.fmuladd.f64(double %58, double %59, double %60)
  store double %61, ptr %8, align 8, !tbaa !11
  br label %62

62:                                               ; preds = %54, %44
  br label %90

63:                                               ; preds = %37
  %64 = load double, ptr %11, align 8, !tbaa !11
  %65 = load double, ptr %13, align 8, !tbaa !11
  %66 = fcmp ogt double %64, %65
  br i1 %66, label %67, label %77

67:                                               ; preds = %63
  %68 = load double, ptr %13, align 8, !tbaa !11
  %69 = load double, ptr %11, align 8, !tbaa !11
  %70 = fdiv double %68, %69
  store double %70, ptr %6, align 8, !tbaa !11
  %71 = load double, ptr %10, align 8, !tbaa !11
  %72 = load double, ptr %6, align 8, !tbaa !11
  %73 = load double, ptr %6, align 8, !tbaa !11
  %74 = fmul double %72, %73
  %75 = call double @llvm.fmuladd.f64(double %71, double %74, double 1.000000e+00)
  store double %75, ptr %10, align 8, !tbaa !11
  %76 = load double, ptr %11, align 8, !tbaa !11
  store double %76, ptr %13, align 8, !tbaa !11
  br label %89

77:                                               ; preds = %63
  %78 = load double, ptr %11, align 8, !tbaa !11
  %79 = fcmp une double %78, 0.000000e+00
  br i1 %79, label %80, label %88

80:                                               ; preds = %77
  %81 = load double, ptr %11, align 8, !tbaa !11
  %82 = load double, ptr %13, align 8, !tbaa !11
  %83 = fdiv double %81, %82
  store double %83, ptr %6, align 8, !tbaa !11
  %84 = load double, ptr %6, align 8, !tbaa !11
  %85 = load double, ptr %6, align 8, !tbaa !11
  %86 = load double, ptr %10, align 8, !tbaa !11
  %87 = call double @llvm.fmuladd.f64(double %84, double %85, double %86)
  store double %87, ptr %10, align 8, !tbaa !11
  br label %88

88:                                               ; preds = %80, %77
  br label %89

89:                                               ; preds = %88, %67
  br label %90

90:                                               ; preds = %89, %62
  br label %96

91:                                               ; preds = %33
  %92 = load double, ptr %11, align 8, !tbaa !11
  %93 = load double, ptr %11, align 8, !tbaa !11
  %94 = load double, ptr %9, align 8, !tbaa !11
  %95 = call double @llvm.fmuladd.f64(double %92, double %93, double %94)
  store double %95, ptr %9, align 8, !tbaa !11
  br label %96

96:                                               ; preds = %91, %90
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %7, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %7, align 4, !tbaa !5
  br label %20, !llvm.loop !13

100:                                              ; preds = %20
  %101 = load double, ptr %8, align 8, !tbaa !11
  %102 = fcmp une double %101, 0.000000e+00
  br i1 %102, label %103, label %114

103:                                              ; preds = %100
  %104 = load double, ptr %12, align 8, !tbaa !11
  %105 = load double, ptr %8, align 8, !tbaa !11
  %106 = load double, ptr %9, align 8, !tbaa !11
  %107 = load double, ptr %12, align 8, !tbaa !11
  %108 = fdiv double %106, %107
  %109 = load double, ptr %12, align 8, !tbaa !11
  %110 = fdiv double %108, %109
  %111 = fadd double %105, %110
  %112 = call double @sqrt(double noundef %111) #4
  %113 = fmul double %104, %112
  store double %113, ptr %5, align 8, !tbaa !11
  br label %149

114:                                              ; preds = %100
  %115 = load double, ptr %9, align 8, !tbaa !11
  %116 = fcmp une double %115, 0.000000e+00
  br i1 %116, label %117, label %143

117:                                              ; preds = %114
  %118 = load double, ptr %9, align 8, !tbaa !11
  %119 = load double, ptr %13, align 8, !tbaa !11
  %120 = fcmp oge double %118, %119
  br i1 %120, label %121, label %132

121:                                              ; preds = %117
  %122 = load double, ptr %9, align 8, !tbaa !11
  %123 = load double, ptr %13, align 8, !tbaa !11
  %124 = load double, ptr %9, align 8, !tbaa !11
  %125 = fdiv double %123, %124
  %126 = load double, ptr %13, align 8, !tbaa !11
  %127 = load double, ptr %10, align 8, !tbaa !11
  %128 = fmul double %126, %127
  %129 = call double @llvm.fmuladd.f64(double %125, double %128, double 1.000000e+00)
  %130 = fmul double %122, %129
  %131 = call double @sqrt(double noundef %130) #4
  store double %131, ptr %5, align 8, !tbaa !11
  br label %142

132:                                              ; preds = %117
  %133 = load double, ptr %13, align 8, !tbaa !11
  %134 = load double, ptr %9, align 8, !tbaa !11
  %135 = load double, ptr %13, align 8, !tbaa !11
  %136 = fdiv double %134, %135
  %137 = load double, ptr %13, align 8, !tbaa !11
  %138 = load double, ptr %10, align 8, !tbaa !11
  %139 = call double @llvm.fmuladd.f64(double %137, double %138, double %136)
  %140 = fmul double %133, %139
  %141 = call double @sqrt(double noundef %140) #4
  store double %141, ptr %5, align 8, !tbaa !11
  br label %142

142:                                              ; preds = %132, %121
  br label %148

143:                                              ; preds = %114
  %144 = load double, ptr %13, align 8, !tbaa !11
  %145 = load double, ptr %10, align 8, !tbaa !11
  %146 = call double @sqrt(double noundef %145) #4
  %147 = fmul double %144, %146
  store double %147, ptr %5, align 8, !tbaa !11
  br label %148

148:                                              ; preds = %143, %142
  br label %149

149:                                              ; preds = %148, %103
  %150 = load double, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret double %150
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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: nofree nounwind memory(write, argmem: readwrite) uwtable
define dso_local double @enorm(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = sitofp i32 %0 to double
  %4 = fdiv double 0x5FECCCCCCCCCCCCC, %3
  %5 = icmp sgt i32 %0, 0
  br i1 %5, label %.lr.ph.preheader, label %.thread

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %35
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %35 ]
  %.06278 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %.1, %35 ]
  %.06377 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %.164, %35 ]
  %.06675 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %.167, %35 ]
  %.06874 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %.169, %35 ]
  %.07073 = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %.171, %35 ]
  %6 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %7 = load double, ptr %6, align 8, !tbaa !5
  %8 = tail call double @llvm.fabs.f64(double %7)
  %9 = fcmp ugt double %8, 0x1FFCCCCCCCCCCCCD
  %10 = fcmp ult double %8, %4
  %or.cond = and i1 %9, %10
  br i1 %or.cond, label %33, label %11

11:                                               ; preds = %.lr.ph
  %12 = fcmp ogt double %8, 0x1FFCCCCCCCCCCCCD
  br i1 %12, label %13, label %22

13:                                               ; preds = %11
  %14 = fcmp ogt double %8, %.06377
  br i1 %14, label %15, label %19

15:                                               ; preds = %13
  %16 = fdiv double %.06377, %8
  %17 = fmul double %16, %16
  %18 = tail call double @llvm.fmuladd.f64(double %.07073, double %17, double 1.000000e+00)
  br label %35

19:                                               ; preds = %13
  %20 = fdiv double %8, %.06377
  %21 = tail call double @llvm.fmuladd.f64(double %20, double %20, double %.07073)
  br label %35

22:                                               ; preds = %11
  %23 = fcmp ogt double %8, %.06278
  br i1 %23, label %24, label %28

24:                                               ; preds = %22
  %25 = fdiv double %.06278, %8
  %26 = fmul double %25, %25
  %27 = tail call double @llvm.fmuladd.f64(double %.06675, double %26, double 1.000000e+00)
  br label %35

28:                                               ; preds = %22
  %29 = fcmp une double %7, 0.000000e+00
  br i1 %29, label %30, label %35

30:                                               ; preds = %28
  %31 = fdiv double %8, %.06278
  %32 = tail call double @llvm.fmuladd.f64(double %31, double %31, double %.06675)
  br label %35

33:                                               ; preds = %.lr.ph
  %34 = tail call double @llvm.fmuladd.f64(double %7, double %7, double %.06874)
  br label %35

35:                                               ; preds = %33, %24, %30, %28, %15, %19
  %.171 = phi double [ %18, %15 ], [ %21, %19 ], [ %.07073, %24 ], [ %.07073, %30 ], [ %.07073, %28 ], [ %.07073, %33 ]
  %.169 = phi double [ %.06874, %15 ], [ %.06874, %19 ], [ %.06874, %24 ], [ %.06874, %30 ], [ %.06874, %28 ], [ %34, %33 ]
  %.167 = phi double [ %.06675, %15 ], [ %.06675, %19 ], [ %27, %24 ], [ %32, %30 ], [ %.06675, %28 ], [ %.06675, %33 ]
  %.164 = phi double [ %8, %15 ], [ %.06377, %19 ], [ %.06377, %24 ], [ %.06377, %30 ], [ %.06377, %28 ], [ %.06377, %33 ]
  %.1 = phi double [ %.06278, %15 ], [ %.06278, %19 ], [ %8, %24 ], [ %.06278, %30 ], [ %.06278, %28 ], [ %.06278, %33 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %35
  %36 = fcmp une double %.171, 0.000000e+00
  br i1 %36, label %37, label %43

37:                                               ; preds = %._crit_edge
  %38 = fdiv double %.169, %.164
  %39 = fdiv double %38, %.164
  %40 = fadd double %.171, %39
  %41 = tail call double @sqrt(double noundef %40) #3
  %42 = fmul double %.164, %41
  br label %60

43:                                               ; preds = %._crit_edge
  %44 = fcmp une double %.169, 0.000000e+00
  br i1 %44, label %45, label %.thread

45:                                               ; preds = %43
  %46 = fcmp ult double %.169, %.1
  br i1 %46, label %53, label %47

47:                                               ; preds = %45
  %48 = fdiv double %.1, %.169
  %49 = fmul double %.167, %.1
  %50 = tail call double @llvm.fmuladd.f64(double %48, double %49, double 1.000000e+00)
  %51 = fmul double %.169, %50
  %52 = tail call double @sqrt(double noundef %51) #3
  br label %60

53:                                               ; preds = %45
  %54 = fdiv double %.169, %.1
  %55 = tail call double @llvm.fmuladd.f64(double %.1, double %.167, double %54)
  %56 = fmul double %.1, %55
  %57 = tail call double @sqrt(double noundef %56) #3
  br label %60

.thread:                                          ; preds = %2, %43
  %.066.lcssa9096 = phi double [ %.167, %43 ], [ 0.000000e+00, %2 ]
  %.062.lcssa9195 = phi double [ %.1, %43 ], [ 0.000000e+00, %2 ]
  %58 = tail call double @sqrt(double noundef %.066.lcssa9096) #3
  %59 = fmul double %.062.lcssa9195, %58
  br label %60

60:                                               ; preds = %.thread, %53, %47, %37
  %.0 = phi double [ %42, %37 ], [ %52, %47 ], [ %57, %53 ], [ %59, %.thread ]
  ret double %.0
}

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

; 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)
declare double @sqrt(double noundef) local_unnamed_addr #2

attributes #0 = { nofree nounwind memory(write, argmem: readwrite) 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass