; LLVM IR from robinrodricks/InspiritImage :: Inspirit.Assurf/clib (utils)

; 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._IPointMatch = type { ptr, ptr, ptr, double, double, i32, i32, i32 }
%struct._IPoint = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, double, double, i32, i32, i32, double, ptr, i32, [256 x i8] }

@__const.getHomographyPoints2.idx = external hidden unnamed_addr constant [16 x [4 x i32]], align 16

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

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare dso_local void @perpendicularRegression(ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @getHomographyPoints2(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [8 x %struct._IPointMatch], align 16
  %10 = alloca [16 x [4 x i32]], align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 448, ptr %9) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = getelementptr inbounds [8 x %struct._IPointMatch], ptr %9, i64 0, i64 0
  call void @perpendicularRegression(ptr noundef %17, i32 noundef %18, ptr noundef %19)
  call void @llvm.lifetime.start.p0(i64 256, ptr %10) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %10, ptr align 16 @__const.getHomographyPoints2.idx, i64 256, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  store i32 0, ptr %14, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %90, %4
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = icmp slt i32 %21, 16
  br i1 %22, label %23, label %93

23:                                               ; preds = %20
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %86, %23
  %25 = load i32, ptr %12, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 4
  br i1 %26, label %27, label %89

27:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [16 x [4 x i32]], ptr %10, i64 0, i64 %29
  %31 = load i32, ptr %12, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [4 x i32], ptr %30, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [8 x %struct._IPointMatch], ptr %9, i64 0, i64 %35
  %37 = getelementptr inbounds %struct._IPointMatch, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  store ptr %38, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [16 x [4 x i32]], ptr %10, i64 0, i64 %40
  %42 = load i32, ptr %12, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [4 x i32], ptr %41, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [8 x %struct._IPointMatch], ptr %9, i64 0, i64 %46
  %48 = getelementptr inbounds %struct._IPointMatch, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !14
  store ptr %49, ptr %16, align 8, !tbaa !5
  %50 = load ptr, ptr %15, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._IPoint, ptr %50, i32 0, i32 4
  %52 = load i32, ptr %51, align 8, !tbaa !15
  %53 = sitofp i32 %52 to double
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %13, align 4, !tbaa !9
  %57 = sext i32 %55 to i64
  %58 = getelementptr inbounds double, ptr %54, i64 %57
  store double %53, ptr %58, align 8, !tbaa !17
  %59 = load ptr, ptr %15, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._IPoint, ptr %59, i32 0, i32 5
  %61 = load i32, ptr %60, align 4, !tbaa !18
  %62 = sitofp i32 %61 to double
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load i32, ptr %13, align 4, !tbaa !9
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %13, align 4, !tbaa !9
  %66 = sext i32 %64 to i64
  %67 = getelementptr inbounds double, ptr %63, i64 %66
  store double %62, ptr %67, align 8, !tbaa !17
  %68 = load ptr, ptr %16, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._IPoint, ptr %68, i32 0, i32 4
  %70 = load i32, ptr %69, align 8, !tbaa !15
  %71 = sitofp i32 %70 to double
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = load i32, ptr %14, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %14, align 4, !tbaa !9
  %75 = sext i32 %73 to i64
  %76 = getelementptr inbounds double, ptr %72, i64 %75
  store double %71, ptr %76, align 8, !tbaa !17
  %77 = load ptr, ptr %16, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct._IPoint, ptr %77, i32 0, i32 5
  %79 = load i32, ptr %78, align 4, !tbaa !18
  %80 = sitofp i32 %79 to double
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  %82 = load i32, ptr %14, align 4, !tbaa !9
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %14, align 4, !tbaa !9
  %84 = sext i32 %82 to i64
  %85 = getelementptr inbounds double, ptr %81, i64 %84
  store double %80, ptr %85, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  br label %86

86:                                               ; preds = %27
  %87 = load i32, ptr %12, align 4, !tbaa !9
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %12, align 4, !tbaa !9
  br label %24, !llvm.loop !19

89:                                               ; preds = %24
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %11, align 4, !tbaa !9
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %11, align 4, !tbaa !9
  br label %20, !llvm.loop !21

93:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 256, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 448, ptr %9) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_IPointMatch", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !13, i64 32, !10, i64 40, !10, i64 44, !10, i64 48}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !6, i64 8}
!15 = !{!16, !10, i64 16}
!16 = !{!"_IPoint", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !13, i64 40, !13, i64 48, !10, i64 56, !10, i64 60, !10, i64 64, !13, i64 72, !6, i64 80, !10, i64 88, !7, i64 92}
!17 = !{!13, !13, i64 0}
!18 = !{!16, !10, i64 20}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


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

%struct._IPointMatch = type { ptr, ptr, ptr, double, double, i32, i32, i32 }

@__const.getHomographyPoints2.idx = external hidden unnamed_addr constant [16 x [4 x i32]], align 16

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @perpendicularRegression(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @getHomographyPoints2(ptr noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #1 {
  %5 = alloca [8 x %struct._IPointMatch], align 16
  call void @llvm.lifetime.start.p0(i64 448, ptr nonnull %5) #2
  call void @perpendicularRegression(ptr noundef %0, i32 noundef %1, ptr noundef nonnull %5)
  br label %.preheader

.preheader:                                       ; preds = %4, %.preheader
  %indvars.iv41 = phi i64 [ 0, %4 ], [ %indvars.iv.next42, %.preheader ]
  %indvars.iv = phi i64 [ 0, %4 ], [ %indvars.iv.next, %.preheader ]
  %6 = getelementptr inbounds [16 x [4 x i32]], ptr @__const.getHomographyPoints2.idx, i64 0, i64 %indvars.iv, i64 0
  %7 = load i32, ptr %6, align 16, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [8 x %struct._IPointMatch], ptr %5, i64 0, i64 %8
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %9, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %10, i64 16
  %14 = getelementptr inbounds double, ptr %2, i64 %indvars.iv41
  %indvars.iv.next35 = or disjoint i64 %indvars.iv41, 2
  %15 = load <2 x i32>, ptr %13, align 8, !tbaa !5
  %16 = sitofp <2 x i32> %15 to <2 x double>
  store <2 x double> %16, ptr %14, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %12, i64 16
  %18 = getelementptr inbounds double, ptr %3, i64 %indvars.iv41
  %19 = load <2 x i32>, ptr %17, align 8, !tbaa !5
  %20 = sitofp <2 x i32> %19 to <2 x double>
  store <2 x double> %20, ptr %18, align 8, !tbaa !14
  %21 = getelementptr inbounds [16 x [4 x i32]], ptr @__const.getHomographyPoints2.idx, i64 0, i64 %indvars.iv, i64 1
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [8 x %struct._IPointMatch], ptr %5, i64 0, i64 %23
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = getelementptr inbounds i8, ptr %24, i64 8
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %25, i64 16
  %29 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next35
  %indvars.iv.next35.1 = or disjoint i64 %indvars.iv41, 4
  %30 = load <2 x i32>, ptr %28, align 8, !tbaa !5
  %31 = sitofp <2 x i32> %30 to <2 x double>
  store <2 x double> %31, ptr %29, align 8, !tbaa !14
  %32 = getelementptr inbounds i8, ptr %27, i64 16
  %33 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next35
  %34 = load <2 x i32>, ptr %32, align 8, !tbaa !5
  %35 = sitofp <2 x i32> %34 to <2 x double>
  store <2 x double> %35, ptr %33, align 8, !tbaa !14
  %36 = getelementptr inbounds [16 x [4 x i32]], ptr @__const.getHomographyPoints2.idx, i64 0, i64 %indvars.iv, i64 2
  %37 = load i32, ptr %36, align 8, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [8 x %struct._IPointMatch], ptr %5, i64 0, i64 %38
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = getelementptr inbounds i8, ptr %39, i64 8
  %42 = load ptr, ptr %41, align 8, !tbaa !13
  %43 = getelementptr inbounds i8, ptr %40, i64 16
  %44 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next35.1
  %indvars.iv.next35.2 = or disjoint i64 %indvars.iv41, 6
  %45 = load <2 x i32>, ptr %43, align 8, !tbaa !5
  %46 = sitofp <2 x i32> %45 to <2 x double>
  store <2 x double> %46, ptr %44, align 8, !tbaa !14
  %47 = getelementptr inbounds i8, ptr %42, i64 16
  %48 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next35.1
  %49 = load <2 x i32>, ptr %47, align 8, !tbaa !5
  %50 = sitofp <2 x i32> %49 to <2 x double>
  store <2 x double> %50, ptr %48, align 8, !tbaa !14
  %51 = getelementptr inbounds [16 x [4 x i32]], ptr @__const.getHomographyPoints2.idx, i64 0, i64 %indvars.iv, i64 3
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [8 x %struct._IPointMatch], ptr %5, i64 0, i64 %53
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  %56 = getelementptr inbounds i8, ptr %54, i64 8
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  %58 = getelementptr inbounds i8, ptr %55, i64 16
  %59 = getelementptr inbounds double, ptr %2, i64 %indvars.iv.next35.2
  %60 = load <2 x i32>, ptr %58, align 8, !tbaa !5
  %61 = sitofp <2 x i32> %60 to <2 x double>
  store <2 x double> %61, ptr %59, align 8, !tbaa !14
  %62 = getelementptr inbounds i8, ptr %57, i64 16
  %63 = getelementptr inbounds double, ptr %3, i64 %indvars.iv.next35.2
  %64 = load <2 x i32>, ptr %62, align 8, !tbaa !5
  %65 = sitofp <2 x i32> %64 to <2 x double>
  store <2 x double> %65, ptr %63, align 8, !tbaa !14
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 16
  br i1 %exitcond.not, label %66, label %.preheader, !llvm.loop !15

66:                                               ; preds = %.preheader
  call void @llvm.lifetime.end.p0(i64 448, ptr nonnull %5) #2
  ret void
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass