; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/Netlib/src/netlib/slatec (initds)

; 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"

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [38 x i8], align 1
@c__2 = external hidden global i64, align 8
@c__1 = external hidden global i64, align 8
@.str.3 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @initds_(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca float, align 4
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds double, ptr %13, i32 -1
  store ptr %14, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %15, align 8, !tbaa !9
  %17 = icmp slt i64 %16, 1
  br i1 %17, label %18, label %20

18:                                               ; preds = %3
  %19 = call i32 @xermsg_(ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.2, ptr noundef @c__2, ptr noundef @c__1, i64 noundef 6, i64 noundef 6, i64 noundef 37)
  br label %20

20:                                               ; preds = %18, %3
  store float 0.000000e+00, ptr %12, align 4, !tbaa !11
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load i64, ptr %21, align 8, !tbaa !9
  store i64 %22, ptr %8, align 8, !tbaa !9
  store i64 1, ptr %11, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %57, %20
  %24 = load i64, ptr %11, align 8, !tbaa !9
  %25 = load i64, ptr %8, align 8, !tbaa !9
  %26 = icmp sle i64 %24, %25
  br i1 %26, label %27, label %60

27:                                               ; preds = %23
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = add nsw i64 %29, 1
  %31 = load i64, ptr %11, align 8, !tbaa !9
  %32 = sub nsw i64 %30, %31
  store i64 %32, ptr %10, align 8, !tbaa !9
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load i64, ptr %10, align 8, !tbaa !9
  %35 = getelementptr inbounds double, ptr %33, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !13
  %37 = fptrunc double %36 to float
  store float %37, ptr %9, align 4, !tbaa !11
  %38 = load float, ptr %9, align 4, !tbaa !11
  %39 = fcmp oge float %38, 0.000000e+00
  br i1 %39, label %40, label %42

40:                                               ; preds = %27
  %41 = load float, ptr %9, align 4, !tbaa !11
  br label %45

42:                                               ; preds = %27
  %43 = load float, ptr %9, align 4, !tbaa !11
  %44 = fneg float %43
  br label %45

45:                                               ; preds = %42, %40
  %46 = phi float [ %41, %40 ], [ %44, %42 ]
  %47 = fpext float %46 to double
  %48 = fptrunc double %47 to float
  %49 = load float, ptr %12, align 4, !tbaa !11
  %50 = fadd float %49, %48
  store float %50, ptr %12, align 4, !tbaa !11
  %51 = load float, ptr %12, align 4, !tbaa !11
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load float, ptr %52, align 4, !tbaa !11
  %54 = fcmp ogt float %51, %53
  br i1 %54, label %55, label %56

55:                                               ; preds = %45
  br label %61

56:                                               ; preds = %45
  br label %57

57:                                               ; preds = %56
  %58 = load i64, ptr %11, align 8, !tbaa !9
  %59 = add nsw i64 %58, 1
  store i64 %59, ptr %11, align 8, !tbaa !9
  br label %23, !llvm.loop !15

60:                                               ; preds = %23
  br label %61

61:                                               ; preds = %60, %55
  %62 = load i64, ptr %10, align 8, !tbaa !9
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i64, ptr %63, align 8, !tbaa !9
  %65 = icmp eq i64 %62, %64
  br i1 %65, label %66, label %68

66:                                               ; preds = %61
  %67 = call i32 @xermsg_(ptr noundef @.str, ptr noundef @.str.1, ptr noundef @.str.3, ptr noundef @c__1, ptr noundef @c__1, i64 noundef 6, i64 noundef 6, i64 noundef 49)
  br label %68

68:                                               ; preds = %66, %61
  %69 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %69, ptr %7, align 8, !tbaa !9
  %70 = load i64, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i64 %70
}

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

declare i32 @xermsg_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef) #2

; 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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [38 x i8], align 1
@c__2 = external hidden global i64, align 8
@c__1 = external hidden global i64, align 8
@.str.3 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i64 @initds_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 -8
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = icmp slt i64 %5, 1
  br i1 %6, label %7, label %.lr.ph

7:                                                ; preds = %3
  %8 = tail call i32 @xermsg_(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, ptr noundef nonnull @c__2, ptr noundef nonnull @c__1, i64 noundef 6, i64 noundef 6, i64 noundef 37) #2
  %.pre = load i64, ptr %1, align 8, !tbaa !5
  %.not22 = icmp slt i64 %.pre, 1
  br i1 %.not22, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %7
  %9 = phi i64 [ %.pre, %7 ], [ %5, %3 ]
  %10 = add nuw i64 %9, 1
  %11 = load float, ptr %2, align 4, !tbaa !9
  br label %14

12:                                               ; preds = %14
  %13 = add nuw i64 %.01923, 1
  %exitcond.not = icmp eq i64 %.01923, %9
  br i1 %exitcond.not, label %._crit_edge, label %14, !llvm.loop !11

14:                                               ; preds = %.lr.ph, %12
  %.024 = phi float [ 0.000000e+00, %.lr.ph ], [ %22, %12 ]
  %.01923 = phi i64 [ 1, %.lr.ph ], [ %13, %12 ]
  %15 = sub i64 %10, %.01923
  %16 = getelementptr inbounds double, ptr %4, i64 %15
  %17 = load double, ptr %16, align 8, !tbaa !13
  %18 = fptrunc double %17 to float
  %19 = fcmp oge float %18, 0.000000e+00
  %20 = fneg float %18
  %21 = select i1 %19, float %18, float %20
  %22 = fadd float %.024, %21
  %23 = fcmp ogt float %22, %11
  br i1 %23, label %._crit_edge, label %12

._crit_edge:                                      ; preds = %14, %12, %7
  %24 = phi i64 [ %.pre, %7 ], [ %9, %12 ], [ %9, %14 ]
  %.1 = phi i64 [ 0, %7 ], [ %15, %14 ], [ 1, %12 ]
  %25 = icmp eq i64 %.1, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %._crit_edge
  %27 = tail call i32 @xermsg_(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.3, ptr noundef nonnull @c__1, ptr noundef nonnull @c__1, i64 noundef 6, i64 noundef 6, i64 noundef 49) #2
  br label %28

28:                                               ; preds = %26, %._crit_edge
  ret i64 %.1
}

declare i32 @xermsg_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #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 = { "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 #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"double", !7, i64 0}


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