; LLVM IR from leonmavr/gfx-v4 :: src (algos)

; 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.vec2i_t = type { i32, i32 }

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

declare void @gfx_point(i32 noundef, i32 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: nounwind uwtable
define dso_local void @algos_triangle_fill_sweep(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, 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 4, ptr %7) #3
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.vec2i_t, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = sitofp i32 %25 to float
  store float %26, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.vec2i_t, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !14
  %30 = sitofp i32 %29 to float
  store float %30, ptr %8, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.vec2i_t, ptr %31, i32 0, i32 0
  %33 = load i32, ptr %32, align 4, !tbaa !9
  %34 = sitofp i32 %33 to float
  store float %34, ptr %9, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.vec2i_t, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !14
  %38 = sitofp i32 %37 to float
  store float %38, ptr %10, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.vec2i_t, ptr %39, i32 0, i32 0
  %41 = load i32, ptr %40, align 4, !tbaa !9
  %42 = sitofp i32 %41 to float
  store float %42, ptr %11, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.vec2i_t, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !14
  %46 = sitofp i32 %45 to float
  store float %46, ptr %12, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %47 = load float, ptr %11, align 4, !tbaa !12
  %48 = load float, ptr %7, align 4, !tbaa !12
  %49 = fsub float %47, %48
  %50 = load float, ptr %12, align 4, !tbaa !12
  %51 = load float, ptr %8, align 4, !tbaa !12
  %52 = fsub float %50, %51
  %53 = fdiv float %49, %52
  store float %53, ptr %13, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %54 = load float, ptr %9, align 4, !tbaa !12
  %55 = load float, ptr %7, align 4, !tbaa !12
  %56 = fsub float %54, %55
  %57 = load float, ptr %10, align 4, !tbaa !12
  %58 = load float, ptr %8, align 4, !tbaa !12
  %59 = fsub float %57, %58
  %60 = fdiv float %56, %59
  store float %60, ptr %14, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %61 = load float, ptr %11, align 4, !tbaa !12
  %62 = load float, ptr %9, align 4, !tbaa !12
  %63 = fsub float %61, %62
  %64 = load float, ptr %12, align 4, !tbaa !12
  %65 = load float, ptr %10, align 4, !tbaa !12
  %66 = fsub float %64, %65
  %67 = fdiv float %63, %66
  store float %67, ptr %15, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %68 = load float, ptr %7, align 4, !tbaa !12
  store float %68, ptr %16, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %69 = load float, ptr %7, align 4, !tbaa !12
  store float %69, ptr %17, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %70 = load float, ptr %8, align 4, !tbaa !12
  %71 = fptosi float %70 to i32
  store i32 %71, ptr %18, align 4, !tbaa !15
  br label %72

72:                                               ; preds = %100, %3
  %73 = load i32, ptr %18, align 4, !tbaa !15
  %74 = sitofp i32 %73 to float
  %75 = load float, ptr %10, align 4, !tbaa !12
  %76 = fcmp olt float %74, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %72
  store i32 2, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %103

78:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %79 = load float, ptr %16, align 4, !tbaa !12
  %80 = fptosi float %79 to i32
  store i32 %80, ptr %20, align 4, !tbaa !15
  br label %81

81:                                               ; preds = %90, %78
  %82 = load i32, ptr %20, align 4, !tbaa !15
  %83 = load float, ptr %17, align 4, !tbaa !12
  %84 = fptosi float %83 to i32
  %85 = icmp slt i32 %82, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %81
  store i32 5, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  br label %93

87:                                               ; preds = %81
  %88 = load i32, ptr %20, align 4, !tbaa !15
  %89 = load i32, ptr %18, align 4, !tbaa !15
  call void @gfx_point(i32 noundef %88, i32 noundef %89)
  br label %90

90:                                               ; preds = %87
  %91 = load i32, ptr %20, align 4, !tbaa !15
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %20, align 4, !tbaa !15
  br label %81, !llvm.loop !16

93:                                               ; preds = %86
  %94 = load float, ptr %13, align 4, !tbaa !12
  %95 = load float, ptr %16, align 4, !tbaa !12
  %96 = fadd float %95, %94
  store float %96, ptr %16, align 4, !tbaa !12
  %97 = load float, ptr %14, align 4, !tbaa !12
  %98 = load float, ptr %17, align 4, !tbaa !12
  %99 = fadd float %98, %97
  store float %99, ptr %17, align 4, !tbaa !12
  br label %100

100:                                              ; preds = %93
  %101 = load i32, ptr %18, align 4, !tbaa !15
  %102 = add nsw i32 %101, 1
  store i32 %102, ptr %18, align 4, !tbaa !15
  br label %72, !llvm.loop !18

103:                                              ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %104 = load float, ptr %10, align 4, !tbaa !12
  %105 = fptosi float %104 to i32
  store i32 %105, ptr %21, align 4, !tbaa !15
  br label %106

106:                                              ; preds = %134, %103
  %107 = load i32, ptr %21, align 4, !tbaa !15
  %108 = sitofp i32 %107 to float
  %109 = load float, ptr %12, align 4, !tbaa !12
  %110 = fcmp olt float %108, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %106
  store i32 8, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %137

112:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %113 = load float, ptr %16, align 4, !tbaa !12
  %114 = fptosi float %113 to i32
  store i32 %114, ptr %22, align 4, !tbaa !15
  br label %115

115:                                              ; preds = %124, %112
  %116 = load i32, ptr %22, align 4, !tbaa !15
  %117 = load float, ptr %17, align 4, !tbaa !12
  %118 = fptosi float %117 to i32
  %119 = icmp slt i32 %116, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %115
  store i32 11, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  br label %127

121:                                              ; preds = %115
  %122 = load i32, ptr %22, align 4, !tbaa !15
  %123 = load i32, ptr %21, align 4, !tbaa !15
  call void @gfx_point(i32 noundef %122, i32 noundef %123)
  br label %124

124:                                              ; preds = %121
  %125 = load i32, ptr %22, align 4, !tbaa !15
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %22, align 4, !tbaa !15
  br label %115, !llvm.loop !19

127:                                              ; preds = %120
  %128 = load float, ptr %13, align 4, !tbaa !12
  %129 = load float, ptr %16, align 4, !tbaa !12
  %130 = fadd float %129, %128
  store float %130, ptr %16, align 4, !tbaa !12
  %131 = load float, ptr %15, align 4, !tbaa !12
  %132 = load float, ptr %17, align 4, !tbaa !12
  %133 = fadd float %132, %131
  store float %133, ptr %17, align 4, !tbaa !12
  br label %134

134:                                              ; preds = %127
  %135 = load i32, ptr %21, align 4, !tbaa !15
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %21, align 4, !tbaa !15
  br label %106, !llvm.loop !20

137:                                              ; preds = %111
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  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 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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, !11, i64 0}
!10 = !{!"vec2i_t", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!10, !11, i64 4}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}
!20 = distinct !{!20, !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"

declare void @gfx_point(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @algos_triangle_fill_sweep(ptr nocapture noundef readonly %0, ptr nocapture noundef readnone %1, ptr nocapture noundef readnone %2) local_unnamed_addr #1 {
  %4 = load i32, ptr %0, align 4, !tbaa !5
  %5 = sitofp i32 %4 to float
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !10
  %8 = sitofp i32 %7 to float
  %9 = fsub float %5, %5
  %10 = fsub float %8, %8
  %11 = fdiv float %9, %10
  %12 = fptosi float %8 to i32
  %13 = sitofp i32 %12 to float
  %14 = fcmp olt float %13, %8
  br i1 %14, label %.lr.ph59.preheader, label %._crit_edge69

.lr.ph59.preheader:                               ; preds = %3
  %15 = insertelement <2 x float> poison, float %5, i64 0
  %16 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> zeroinitializer
  %17 = insertelement <2 x float> poison, float %11, i64 0
  %18 = shufflevector <2 x float> %17, <2 x float> poison, <2 x i32> zeroinitializer
  br label %.lr.ph59

.preheader:                                       ; preds = %._crit_edge
  br i1 %14, label %.lr.ph68, label %._crit_edge69

.lr.ph59:                                         ; preds = %.lr.ph59.preheader, %._crit_edge
  %.04957 = phi i32 [ %25, %._crit_edge ], [ %12, %.lr.ph59.preheader ]
  %19 = phi <2 x float> [ %24, %._crit_edge ], [ %16, %.lr.ph59.preheader ]
  %20 = fptosi <2 x float> %19 to <2 x i32>
  %21 = extractelement <2 x i32> %20, i64 0
  %22 = extractelement <2 x i32> %20, i64 1
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph59
  %24 = fadd <2 x float> %18, %19
  %25 = add nsw i32 %.04957, 1
  %26 = sitofp i32 %25 to float
  %27 = fcmp olt float %26, %8
  br i1 %27, label %.lr.ph59, label %.preheader, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph59, %.lr.ph
  %.04854 = phi i32 [ %28, %.lr.ph ], [ %21, %.lr.ph59 ]
  tail call void @gfx_point(i32 noundef %.04854, i32 noundef %.04957) #2
  %28 = add i32 %.04854, 1
  %exitcond.not = icmp eq i32 %28, %22
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge69:                                    ; preds = %._crit_edge64, %3, %.preheader
  ret void

.lr.ph68:                                         ; preds = %.preheader, %._crit_edge64
  %.04767 = phi i32 [ %35, %._crit_edge64 ], [ %12, %.preheader ]
  %29 = phi <2 x float> [ %34, %._crit_edge64 ], [ %24, %.preheader ]
  %30 = fptosi <2 x float> %29 to <2 x i32>
  %31 = extractelement <2 x i32> %30, i64 0
  %32 = extractelement <2 x i32> %30, i64 1
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %.lr.ph63, label %._crit_edge64

._crit_edge64:                                    ; preds = %.lr.ph63, %.lr.ph68
  %34 = fadd <2 x float> %18, %29
  %35 = add nsw i32 %.04767, 1
  %36 = sitofp i32 %35 to float
  %37 = fcmp olt float %36, %8
  br i1 %37, label %.lr.ph68, label %._crit_edge69, !llvm.loop !14

.lr.ph63:                                         ; preds = %.lr.ph68, %.lr.ph63
  %.061 = phi i32 [ %38, %.lr.ph63 ], [ %31, %.lr.ph68 ]
  tail call void @gfx_point(i32 noundef %.061, i32 noundef %.04767) #2
  %38 = add i32 %.061, 1
  %exitcond71.not = icmp eq i32 %38, %32
  br i1 %exitcond71.not, label %._crit_edge64, label %.lr.ph63, !llvm.loop !15
}

attributes #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 = { 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, !7, i64 0}
!6 = !{!"vec2i_t", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}


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