; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseYuvToHsl.ll (ZN4Simd4Base12Yuv444pToHslEPKhmS2_mS2_mmmPhm)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Simd4Base12Yuv444pToHslEPKhmS2_mS2_mmmPhm(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9) #0 {
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i32, align 4
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  store ptr %0, ptr %11, align 8, !tbaa !5
  store i64 %1, ptr %12, align 8, !tbaa !9
  store ptr %2, ptr %13, align 8, !tbaa !5
  store i64 %3, ptr %14, align 8, !tbaa !9
  store ptr %4, ptr %15, align 8, !tbaa !5
  store i64 %5, ptr %16, align 8, !tbaa !9
  store i64 %6, ptr %17, align 8, !tbaa !9
  store i64 %7, ptr %18, align 8, !tbaa !9
  store ptr %8, ptr %19, align 8, !tbaa !5
  store i64 %9, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  store i64 0, ptr %21, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %73, %10
  %26 = load i64, ptr %21, align 8, !tbaa !9
  %27 = load i64, ptr %18, align 8, !tbaa !9
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  store i32 2, ptr %22, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  br label %76

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  store i64 0, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #3
  store i64 0, ptr %24, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %55, %30
  %32 = load i64, ptr %23, align 8, !tbaa !9
  %33 = load i64, ptr %17, align 8, !tbaa !9
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 5, ptr %22, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  br label %60

36:                                               ; preds = %31
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = load i64, ptr %23, align 8, !tbaa !9
  %39 = getelementptr inbounds i8, ptr %37, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !11
  %41 = zext i8 %40 to i32
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = load i64, ptr %23, align 8, !tbaa !9
  %44 = getelementptr inbounds i8, ptr %42, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !11
  %46 = zext i8 %45 to i32
  %47 = load ptr, ptr %15, align 8, !tbaa !5
  %48 = load i64, ptr %23, align 8, !tbaa !9
  %49 = getelementptr inbounds i8, ptr %47, i64 %48
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = zext i8 %50 to i32
  %52 = load ptr, ptr %19, align 8, !tbaa !5
  %53 = load i64, ptr %24, align 8, !tbaa !9
  %54 = getelementptr inbounds i8, ptr %52, i64 %53
  call void @_ZN4Simd4Base8YuvToHslEiiiPh(i32 noundef %41, i32 noundef %46, i32 noundef %51, ptr noundef %54)
  br label %55

55:                                               ; preds = %36
  %56 = load i64, ptr %23, align 8, !tbaa !9
  %57 = add i64 %56, 1
  store i64 %57, ptr %23, align 8, !tbaa !9
  %58 = load i64, ptr %24, align 8, !tbaa !9
  %59 = add i64 %58, 3
  store i64 %59, ptr %24, align 8, !tbaa !9
  br label %31, !llvm.loop !12

60:                                               ; preds = %35
  %61 = load i64, ptr %12, align 8, !tbaa !9
  %62 = load ptr, ptr %11, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i64 %61
  store ptr %63, ptr %11, align 8, !tbaa !5
  %64 = load i64, ptr %14, align 8, !tbaa !9
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %65, i64 %64
  store ptr %66, ptr %13, align 8, !tbaa !5
  %67 = load i64, ptr %16, align 8, !tbaa !9
  %68 = load ptr, ptr %15, align 8, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %68, i64 %67
  store ptr %69, ptr %15, align 8, !tbaa !5
  %70 = load i64, ptr %20, align 8, !tbaa !9
  %71 = load ptr, ptr %19, align 8, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %71, i64 %70
  store ptr %72, ptr %19, align 8, !tbaa !5
  br label %73

73:                                               ; preds = %60
  %74 = load i64, ptr %21, align 8, !tbaa !9
  %75 = add i64 %74, 1
  store i64 %75, ptr %21, align 8, !tbaa !9
  br label %25, !llvm.loop !14

76:                                               ; preds = %29
  ret void
}

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

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd4Base8YuvToHslEiiiPh(i32 noundef, i32 noundef, i32 noundef, ptr 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 = { mustprogress 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 = { alwaysinline mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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 uwtable
define dso_local void @_ZN4Simd4Base12Yuv444pToHslEPKhmS2_mS2_mmmPhm(ptr nocapture noundef readonly %0, i64 noundef %1, ptr nocapture noundef readonly %2, i64 noundef %3, ptr nocapture noundef readonly %4, i64 noundef %5, i64 noundef %6, i64 noundef %7, ptr noundef %8, i64 noundef %9) local_unnamed_addr #0 {
  %.not = icmp eq i64 %7, 0
  %.not36 = icmp eq i64 %6, 0
  %or.cond = or i1 %.not, %.not36
  br i1 %or.cond, label %._crit_edge35, label %.preheader.us

.preheader.us:                                    ; preds = %10, %._crit_edge.us
  %.02334.us = phi i64 [ %28, %._crit_edge.us ], [ 0, %10 ]
  %.02433.us = phi ptr [ %24, %._crit_edge.us ], [ %0, %10 ]
  %.02532.us = phi ptr [ %27, %._crit_edge.us ], [ %8, %10 ]
  %.02631.us = phi ptr [ %25, %._crit_edge.us ], [ %2, %10 ]
  %.02730.us = phi ptr [ %26, %._crit_edge.us ], [ %4, %10 ]
  br label %11

11:                                               ; preds = %.preheader.us, %11
  %.029.us = phi i64 [ 0, %.preheader.us ], [ %23, %11 ]
  %.02228.us = phi i64 [ 0, %.preheader.us ], [ %22, %11 ]
  %12 = getelementptr inbounds i8, ptr %.02433.us, i64 %.02228.us
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = zext i8 %13 to i32
  %15 = getelementptr inbounds i8, ptr %.02631.us, i64 %.02228.us
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = zext i8 %16 to i32
  %18 = getelementptr inbounds i8, ptr %.02730.us, i64 %.02228.us
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = zext i8 %19 to i32
  %21 = getelementptr inbounds i8, ptr %.02532.us, i64 %.029.us
  tail call void @_ZN4Simd4Base8YuvToHslEiiiPh(i32 noundef %14, i32 noundef %17, i32 noundef %20, ptr noundef %21)
  %22 = add nuw i64 %.02228.us, 1
  %23 = add i64 %.029.us, 3
  %exitcond.not = icmp eq i64 %22, %6
  br i1 %exitcond.not, label %._crit_edge.us, label %11, !llvm.loop !8

._crit_edge.us:                                   ; preds = %11
  %24 = getelementptr inbounds i8, ptr %.02433.us, i64 %1
  %25 = getelementptr inbounds i8, ptr %.02631.us, i64 %3
  %26 = getelementptr inbounds i8, ptr %.02730.us, i64 %5
  %27 = getelementptr inbounds i8, ptr %.02532.us, i64 %9
  %28 = add nuw i64 %.02334.us, 1
  %exitcond38.not = icmp eq i64 %28, %7
  br i1 %exitcond38.not, label %._crit_edge35, label %.preheader.us, !llvm.loop !10

._crit_edge35:                                    ; preds = %._crit_edge.us, %10
  ret void
}

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN4Simd4Base8YuvToHslEiiiPh(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { alwaysinline mustprogress 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" }

!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"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}


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