; LLVM IR from introlab/odas :: src/init (space)

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

%struct.points_obj = type { i32, ptr }

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

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local float @space_distances_shortest_points(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store float 0x7FF0000000000000, ptr %3, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %13

13:                                               ; preds = %117, %1
  %14 = load i32, ptr %11, align 4, !tbaa !11
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.points_obj, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !13
  %18 = icmp ult i32 %14, %17
  br i1 %18, label %19, label %120

19:                                               ; preds = %13
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.points_obj, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = load i32, ptr %11, align 4, !tbaa !11
  %24 = mul i32 %23, 3
  %25 = add i32 %24, 0
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds float, ptr %22, i64 %26
  %28 = load float, ptr %27, align 4, !tbaa !9
  store float %28, ptr %4, align 4, !tbaa !9
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.points_obj, ptr %29, i32 0, i32 1
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = load i32, ptr %11, align 4, !tbaa !11
  %33 = mul i32 %32, 3
  %34 = add i32 %33, 1
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds float, ptr %31, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !9
  store float %37, ptr %5, align 4, !tbaa !9
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.points_obj, ptr %38, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  %41 = load i32, ptr %11, align 4, !tbaa !11
  %42 = mul i32 %41, 3
  %43 = add i32 %42, 2
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds float, ptr %40, i64 %44
  %46 = load float, ptr %45, align 4, !tbaa !9
  store float %46, ptr %6, align 4, !tbaa !9
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %47

47:                                               ; preds = %113, %19
  %48 = load i32, ptr %12, align 4, !tbaa !11
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.points_obj, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 8, !tbaa !13
  %52 = icmp ult i32 %48, %51
  br i1 %52, label %53, label %116

53:                                               ; preds = %47
  %54 = load i32, ptr %11, align 4, !tbaa !11
  %55 = load i32, ptr %12, align 4, !tbaa !11
  %56 = icmp ne i32 %54, %55
  br i1 %56, label %57, label %112

57:                                               ; preds = %53
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.points_obj, ptr %58, i32 0, i32 1
  %60 = load ptr, ptr %59, align 8, !tbaa !15
  %61 = load i32, ptr %12, align 4, !tbaa !11
  %62 = mul i32 %61, 3
  %63 = add i32 %62, 0
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds float, ptr %60, i64 %64
  %66 = load float, ptr %65, align 4, !tbaa !9
  store float %66, ptr %7, align 4, !tbaa !9
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.points_obj, ptr %67, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !15
  %70 = load i32, ptr %12, align 4, !tbaa !11
  %71 = mul i32 %70, 3
  %72 = add i32 %71, 1
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds float, ptr %69, i64 %73
  %75 = load float, ptr %74, align 4, !tbaa !9
  store float %75, ptr %8, align 4, !tbaa !9
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.points_obj, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !15
  %79 = load i32, ptr %12, align 4, !tbaa !11
  %80 = mul i32 %79, 3
  %81 = add i32 %80, 2
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds float, ptr %78, i64 %82
  %84 = load float, ptr %83, align 4, !tbaa !9
  store float %84, ptr %9, align 4, !tbaa !9
  %85 = load float, ptr %4, align 4, !tbaa !9
  %86 = load float, ptr %7, align 4, !tbaa !9
  %87 = fsub float %85, %86
  %88 = load float, ptr %4, align 4, !tbaa !9
  %89 = load float, ptr %7, align 4, !tbaa !9
  %90 = fsub float %88, %89
  %91 = load float, ptr %5, align 4, !tbaa !9
  %92 = load float, ptr %8, align 4, !tbaa !9
  %93 = fsub float %91, %92
  %94 = load float, ptr %5, align 4, !tbaa !9
  %95 = load float, ptr %8, align 4, !tbaa !9
  %96 = fsub float %94, %95
  %97 = fmul float %93, %96
  %98 = call float @llvm.fmuladd.f32(float %87, float %90, float %97)
  %99 = load float, ptr %6, align 4, !tbaa !9
  %100 = load float, ptr %9, align 4, !tbaa !9
  %101 = fsub float %99, %100
  %102 = load float, ptr %6, align 4, !tbaa !9
  %103 = load float, ptr %9, align 4, !tbaa !9
  %104 = fsub float %102, %103
  %105 = call float @llvm.fmuladd.f32(float %101, float %104, float %98)
  store float %105, ptr %10, align 4, !tbaa !9
  %106 = load float, ptr %10, align 4, !tbaa !9
  %107 = load float, ptr %3, align 4, !tbaa !9
  %108 = fcmp olt float %106, %107
  br i1 %108, label %109, label %111

109:                                              ; preds = %57
  %110 = load float, ptr %10, align 4, !tbaa !9
  store float %110, ptr %3, align 4, !tbaa !9
  br label %111

111:                                              ; preds = %109, %57
  br label %112

112:                                              ; preds = %111, %53
  br label %113

113:                                              ; preds = %112
  %114 = load i32, ptr %12, align 4, !tbaa !11
  %115 = add i32 %114, 1
  store i32 %115, ptr %12, align 4, !tbaa !11
  br label %47, !llvm.loop !16

116:                                              ; preds = %47
  br label %117

117:                                              ; preds = %116
  %118 = load i32, ptr %11, align 4, !tbaa !11
  %119 = add i32 %118, 1
  store i32 %119, ptr %11, align 4, !tbaa !11
  br label %13, !llvm.loop !18

120:                                              ; preds = %13
  %121 = load float, ptr %3, align 4, !tbaa !9
  %122 = call float @sqrtf(float noundef %121) #4
  store float %122, ptr %3, align 4, !tbaa !9
  %123 = load float, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret float %123
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"any pointer", !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"points_obj", !12, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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 float @sqrtf(float noundef) local_unnamed_addr #0

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

; Function Attrs: nofree nounwind memory(readwrite, inaccessiblemem: write) uwtable
define dso_local float @space_distances_shortest_points(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = load i32, ptr %0, align 8, !tbaa !5
  %.not43 = icmp eq i32 %2, 0
  br i1 %.not43, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !11
  %wide.trip.count48 = zext i32 %2 to i64
  br label %5

5:                                                ; preds = %.lr.ph, %43
  %indvars.iv45 = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next46, %43 ]
  %.03741 = phi float [ 0x7FF0000000000000, %.lr.ph ], [ %.2, %43 ]
  %6 = trunc nuw i64 %indvars.iv45 to i32
  %7 = mul i32 %6, 3
  %8 = zext i32 %7 to i64
  %9 = getelementptr inbounds float, ptr %4, i64 %8
  %10 = load float, ptr %9, align 4, !tbaa !12
  %11 = add i32 %7, 1
  %12 = zext i32 %11 to i64
  %13 = getelementptr inbounds float, ptr %4, i64 %12
  %14 = load float, ptr %13, align 4, !tbaa !12
  %15 = add i32 %7, 2
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds float, ptr %4, i64 %16
  %18 = load float, ptr %17, align 4, !tbaa !12
  br label %19

19:                                               ; preds = %5, %42
  %indvars.iv = phi i64 [ 0, %5 ], [ %indvars.iv.next, %42 ]
  %.139 = phi float [ %.03741, %5 ], [ %.2, %42 ]
  %.not = icmp eq i64 %indvars.iv45, %indvars.iv
  br i1 %.not, label %42, label %20

20:                                               ; preds = %19
  %21 = trunc nuw i64 %indvars.iv to i32
  %22 = mul i32 %21, 3
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds float, ptr %4, i64 %23
  %25 = load float, ptr %24, align 4, !tbaa !12
  %26 = add i32 %22, 1
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %4, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !12
  %30 = add i32 %22, 2
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds float, ptr %4, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !12
  %34 = fsub float %10, %25
  %35 = fsub float %14, %29
  %36 = fmul float %35, %35
  %37 = tail call float @llvm.fmuladd.f32(float %34, float %34, float %36)
  %38 = fsub float %18, %33
  %39 = tail call float @llvm.fmuladd.f32(float %38, float %38, float %37)
  %40 = fcmp olt float %39, %.139
  br i1 %40, label %41, label %42

41:                                               ; preds = %20
  br label %42

42:                                               ; preds = %19, %41, %20
  %.2 = phi float [ %39, %41 ], [ %.139, %20 ], [ %.139, %19 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count48
  br i1 %exitcond.not, label %43, label %19, !llvm.loop !14

43:                                               ; preds = %42
  %indvars.iv.next46 = add nuw nsw i64 %indvars.iv45, 1
  %exitcond49.not = icmp eq i64 %indvars.iv.next46, %wide.trip.count48
  br i1 %exitcond49.not, label %._crit_edge, label %5, !llvm.loop !16

._crit_edge:                                      ; preds = %43, %1
  %.037.lcssa = phi float [ 0x7FF0000000000000, %1 ], [ %.2, %43 ]
  %44 = tail call float @sqrtf(float noundef %.037.lcssa) #3
  ret float %44
}

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 = { nofree nounwind memory(readwrite, inaccessiblemem: 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 = { 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, !7, i64 0}
!6 = !{!"points_obj", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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