; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z16transform_mmrectRK7Mm_RectRK4Mat24Vec2)

; 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.Mm_Rect = type { %union.Vec2, %union.Vec2 }
%union.Vec2 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float }

; 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: mustprogress nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @_Z16transform_mmrectRK7Mm_RectRK4Mat24Vec2(ptr noundef nonnull align 4 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(16) %1, <2 x float> %2) #1 {
  %4 = alloca %struct.Mm_Rect, align 4
  %5 = alloca %union.Vec2, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = getelementptr inbounds %union.Vec2, ptr %5, i32 0, i32 0
  store <2 x float> %2, ptr %13, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %104, %3
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = icmp slt i32 %15, 2
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %107

18:                                               ; preds = %14
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [2 x float], ptr %5, i64 0, i64 %20
  %22 = load float, ptr %21, align 4, !tbaa !11
  %23 = getelementptr inbounds %struct.Mm_Rect, ptr %4, i32 0, i32 1
  %24 = load i32, ptr %8, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [2 x float], ptr %23, i64 0, i64 %25
  store float %22, ptr %26, align 4, !tbaa !11
  %27 = getelementptr inbounds %struct.Mm_Rect, ptr %4, i32 0, i32 0
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [2 x float], ptr %27, i64 0, i64 %29
  store float %22, ptr %30, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %100, %18
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 2
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %103

35:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [2 x [2 x float]], ptr %36, i64 0, i64 %38
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [2 x float], ptr %39, i64 0, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !11
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Mm_Rect, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [2 x float], ptr %45, i64 0, i64 %47
  %49 = load float, ptr %48, align 4, !tbaa !11
  %50 = fmul float %43, %49
  store float %50, ptr %11, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [2 x [2 x float]], ptr %51, i64 0, i64 %53
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [2 x float], ptr %54, i64 0, i64 %56
  %58 = load float, ptr %57, align 4, !tbaa !11
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Mm_Rect, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [2 x float], ptr %60, i64 0, i64 %62
  %64 = load float, ptr %63, align 4, !tbaa !11
  %65 = fmul float %58, %64
  store float %65, ptr %12, align 4, !tbaa !12
  %66 = load float, ptr %11, align 4, !tbaa !12
  %67 = load float, ptr %12, align 4, !tbaa !12
  %68 = fcmp olt float %66, %67
  br i1 %68, label %69, label %84

69:                                               ; preds = %35
  %70 = load float, ptr %11, align 4, !tbaa !12
  %71 = getelementptr inbounds %struct.Mm_Rect, ptr %4, i32 0, i32 0
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [2 x float], ptr %71, i64 0, i64 %73
  %75 = load float, ptr %74, align 4, !tbaa !11
  %76 = fadd float %75, %70
  store float %76, ptr %74, align 4, !tbaa !11
  %77 = load float, ptr %12, align 4, !tbaa !12
  %78 = getelementptr inbounds %struct.Mm_Rect, ptr %4, i32 0, i32 1
  %79 = load i32, ptr %8, align 4, !tbaa !9
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [2 x float], ptr %78, i64 0, i64 %80
  %82 = load float, ptr %81, align 4, !tbaa !11
  %83 = fadd float %82, %77
  store float %83, ptr %81, align 4, !tbaa !11
  br label %99

84:                                               ; preds = %35
  %85 = load float, ptr %12, align 4, !tbaa !12
  %86 = getelementptr inbounds %struct.Mm_Rect, ptr %4, i32 0, i32 0
  %87 = load i32, ptr %8, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [2 x float], ptr %86, i64 0, i64 %88
  %90 = load float, ptr %89, align 4, !tbaa !11
  %91 = fadd float %90, %85
  store float %91, ptr %89, align 4, !tbaa !11
  %92 = load float, ptr %11, align 4, !tbaa !12
  %93 = getelementptr inbounds %struct.Mm_Rect, ptr %4, i32 0, i32 1
  %94 = load i32, ptr %8, align 4, !tbaa !9
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [2 x float], ptr %93, i64 0, i64 %95
  %97 = load float, ptr %96, align 4, !tbaa !11
  %98 = fadd float %97, %92
  store float %98, ptr %96, align 4, !tbaa !11
  br label %99

99:                                               ; preds = %84, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %10, align 4, !tbaa !9
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %10, align 4, !tbaa !9
  br label %31, !llvm.loop !14

103:                                              ; preds = %34
  br label %104

104:                                              ; preds = %103
  %105 = load i32, ptr %8, align 4, !tbaa !9
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %8, align 4, !tbaa !9
  br label %14, !llvm.loop !16

107:                                              ; preds = %17
  %108 = load { <2 x float>, <2 x float> }, ptr %4, align 4
  ret { <2 x float>, <2 x float> } %108
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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 norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local { <2 x float>, <2 x float> } @_Z16transform_mmrectRK7Mm_RectRK4Mat24Vec2(ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %1, <2 x float> %2) local_unnamed_addr #0 {
  %4 = shufflevector <2 x float> %2, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %5 = load <4 x float>, ptr %1, align 4
  %6 = shufflevector <4 x float> %5, <4 x float> poison, <2 x i32> <i32 0, i32 poison>
  %7 = load <4 x float>, ptr %0, align 4
  %8 = shufflevector <4 x float> %5, <4 x float> poison, <2 x i32> <i32 1, i32 poison>
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 12
  %12 = load float, ptr %11, align 4, !tbaa !5
  %13 = insertelement <2 x float> %6, float %10, i64 1
  %14 = shufflevector <4 x float> %7, <4 x float> poison, <2 x i32> zeroinitializer
  %15 = fmul <2 x float> %13, %14
  %16 = shufflevector <4 x float> %7, <4 x float> poison, <2 x i32> <i32 2, i32 2>
  %17 = fmul <2 x float> %13, %16
  %18 = fcmp olt <2 x float> %15, %17
  %19 = shufflevector <2 x i1> %18, <2 x i1> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %20 = shufflevector <2 x float> %15, <2 x float> %17, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %21 = shufflevector <2 x float> %15, <2 x float> %17, <4 x i32> <i32 2, i32 3, i32 0, i32 1>
  %22 = select <4 x i1> %19, <4 x float> %20, <4 x float> %21
  %23 = shufflevector <4 x float> %22, <4 x float> poison, <4 x i32> <i32 2, i32 3, i32 0, i32 1>
  %24 = insertelement <2 x float> %8, float %12, i64 1
  %25 = shufflevector <4 x float> %7, <4 x float> poison, <2 x i32> <i32 1, i32 1>
  %26 = fmul <2 x float> %24, %25
  %27 = shufflevector <4 x float> %7, <4 x float> poison, <2 x i32> <i32 3, i32 3>
  %28 = fmul <2 x float> %24, %27
  %29 = fcmp olt <2 x float> %26, %28
  %30 = shufflevector <2 x i1> %29, <2 x i1> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
  %31 = shufflevector <2 x float> %26, <2 x float> %28, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
  %32 = shufflevector <2 x float> %26, <2 x float> %28, <4 x i32> <i32 2, i32 3, i32 0, i32 1>
  %33 = select <4 x i1> %30, <4 x float> %31, <4 x float> %32
  %34 = shufflevector <4 x float> %33, <4 x float> poison, <4 x i32> <i32 2, i32 3, i32 0, i32 1>
  %35 = fadd <4 x float> %23, %4
  %36 = fadd <4 x float> %34, %35
  %37 = shufflevector <4 x float> %36, <4 x float> poison, <2 x i32> <i32 2, i32 3>
  %38 = shufflevector <4 x float> %36, <4 x float> poison, <2 x i32> <i32 0, i32 1>
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %37, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %38, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable "min-legal-vector-width"="64" "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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,VectorCombinePass