; LLVM IR from ermig1979/Simd :: src/Simd/SimdBaseStatistic.ll (ZN4Simd4Base12GetStatisticEPKhmmmPhS3_S3_)

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

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Simd4Base12GetStatisticEPKhmmmPhS3_S3_ = external hidden unnamed_addr constant [104 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Simd4Base12GetStatisticEPKhmmmPhS3_S3_(ptr noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i64, align 8
  %22 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !9
  store i64 %2, ptr %10, align 8, !tbaa !9
  store i64 %3, ptr %11, align 8, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  store ptr %6, ptr %14, align 8, !tbaa !5
  %23 = load i64, ptr %10, align 8, !tbaa !9
  %24 = load i64, ptr %11, align 8, !tbaa !9
  %25 = mul i64 %23, %24
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %7
  br label %30

28:                                               ; preds = %7
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 33, ptr noundef @__PRETTY_FUNCTION__._ZN4Simd4Base12GetStatisticEPKhmmmPhS3_S3_) #4
  unreachable

29:                                               ; No predecessors!
  br label %30

30:                                               ; preds = %29, %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  store i64 0, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 255, ptr %16, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  store i64 0, ptr %18, align 8, !tbaa !9
  br label %31

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

35:                                               ; preds = %31
  store i32 2, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %71

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  store i32 0, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  store i64 0, ptr %21, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %57, %36
  %38 = load i64, ptr %21, align 8, !tbaa !9
  %39 = load i64, ptr %10, align 8, !tbaa !9
  %40 = icmp ult i64 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 5, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  br label %60

42:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = load i64, ptr %21, align 8, !tbaa !9
  %45 = getelementptr inbounds i8, ptr %43, i64 %44
  %46 = load i8, ptr %45, align 1, !tbaa !13
  %47 = zext i8 %46 to i32
  store i32 %47, ptr %22, align 4, !tbaa !11
  %48 = load i32, ptr %22, align 4, !tbaa !11
  %49 = load i32, ptr %17, align 4, !tbaa !11
  %50 = call noundef i32 @_ZN4Simd4Base5MaxU8Eii(i32 noundef %48, i32 noundef %49)
  store i32 %50, ptr %17, align 4, !tbaa !11
  %51 = load i32, ptr %22, align 4, !tbaa !11
  %52 = load i32, ptr %16, align 4, !tbaa !11
  %53 = call noundef i32 @_ZN4Simd4Base5MinU8Eii(i32 noundef %51, i32 noundef %52)
  store i32 %53, ptr %16, align 4, !tbaa !11
  %54 = load i32, ptr %22, align 4, !tbaa !11
  %55 = load i32, ptr %20, align 4, !tbaa !11
  %56 = add nsw i32 %55, %54
  store i32 %56, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  br label %57

57:                                               ; preds = %42
  %58 = load i64, ptr %21, align 8, !tbaa !9
  %59 = add i64 %58, 1
  store i64 %59, ptr %21, align 8, !tbaa !9
  br label %37, !llvm.loop !14

60:                                               ; preds = %41
  %61 = load i32, ptr %20, align 4, !tbaa !11
  %62 = sext i32 %61 to i64
  %63 = load i64, ptr %15, align 8, !tbaa !9
  %64 = add i64 %63, %62
  store i64 %64, ptr %15, align 8, !tbaa !9
  %65 = load i64, ptr %9, align 8, !tbaa !9
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i64 %65
  store ptr %67, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  br label %68

68:                                               ; preds = %60
  %69 = load i64, ptr %18, align 8, !tbaa !9
  %70 = add i64 %69, 1
  store i64 %70, ptr %18, align 8, !tbaa !9
  br label %31, !llvm.loop !16

71:                                               ; preds = %35
  %72 = load i64, ptr %15, align 8, !tbaa !9
  %73 = load i64, ptr %10, align 8, !tbaa !9
  %74 = load i64, ptr %11, align 8, !tbaa !9
  %75 = mul i64 %73, %74
  %76 = udiv i64 %75, 2
  %77 = add i64 %72, %76
  %78 = load i64, ptr %10, align 8, !tbaa !9
  %79 = load i64, ptr %11, align 8, !tbaa !9
  %80 = mul i64 %78, %79
  %81 = udiv i64 %77, %80
  %82 = trunc i64 %81 to i8
  %83 = load ptr, ptr %14, align 8, !tbaa !5
  store i8 %82, ptr %83, align 1, !tbaa !13
  %84 = load i32, ptr %16, align 4, !tbaa !11
  %85 = trunc i32 %84 to i8
  %86 = load ptr, ptr %12, align 8, !tbaa !5
  store i8 %85, ptr %86, align 1, !tbaa !13
  %87 = load i32, ptr %17, align 4, !tbaa !11
  %88 = trunc i32 %87 to i8
  %89 = load ptr, ptr %13, align 8, !tbaa !5
  store i8 %88, ptr %89, align 1, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Simd4Base5MaxU8Eii(i32 noundef, i32 noundef) #3

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Simd4Base5MinU8Eii(i32 noundef, i32 noundef) #3

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

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 = { noreturn 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 willreturn memory(argmem: readwrite) }
attributes #3 = { alwaysinline mustprogress 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 = { noreturn nounwind }
attributes #5 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !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"

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [79 x i8], align 1
@__PRETTY_FUNCTION__._ZN4Simd4Base12GetStatisticEPKhmmmPhS3_S3_ = external hidden unnamed_addr constant [104 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Simd4Base12GetStatisticEPKhmmmPhS3_S3_(ptr nocapture noundef readonly %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #0 {
  %8 = mul i64 %3, %2
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %21, label %.preheader37

.preheader37:                                     ; preds = %7
  %.not55 = icmp eq i64 %3, 0
  %.not56 = icmp eq i64 %2, 0
  %or.cond = or i1 %.not55, %.not56
  br i1 %or.cond, label %._crit_edge49, label %.preheader.us

.preheader.us:                                    ; preds = %.preheader37, %._crit_edge.us
  %.048.us = phi ptr [ %19, %._crit_edge.us ], [ %0, %.preheader37 ]
  %.03147.us = phi i64 [ %20, %._crit_edge.us ], [ 0, %.preheader37 ]
  %.03246.us = phi i32 [ %13, %._crit_edge.us ], [ 0, %.preheader37 ]
  %.03345.us = phi i32 [ %14, %._crit_edge.us ], [ 255, %.preheader37 ]
  %.03544.us = phi i64 [ %18, %._crit_edge.us ], [ 0, %.preheader37 ]
  br label %9

9:                                                ; preds = %.preheader.us, %9
  %.02941.us = phi i64 [ 0, %.preheader.us ], [ %16, %9 ]
  %.03040.us = phi i32 [ 0, %.preheader.us ], [ %15, %9 ]
  %.139.us = phi i32 [ %.03246.us, %.preheader.us ], [ %13, %9 ]
  %.13438.us = phi i32 [ %.03345.us, %.preheader.us ], [ %14, %9 ]
  %10 = getelementptr inbounds i8, ptr %.048.us, i64 %.02941.us
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = zext i8 %11 to i32
  %13 = tail call noundef i32 @_ZN4Simd4Base5MaxU8Eii(i32 noundef %12, i32 noundef %.139.us)
  %14 = tail call noundef i32 @_ZN4Simd4Base5MinU8Eii(i32 noundef %12, i32 noundef %.13438.us)
  %15 = add nuw nsw i32 %.03040.us, %12
  %16 = add nuw i64 %.02941.us, 1
  %exitcond.not = icmp eq i64 %16, %2
  br i1 %exitcond.not, label %._crit_edge.us, label %9, !llvm.loop !8

._crit_edge.us:                                   ; preds = %9
  %17 = zext nneg i32 %15 to i64
  %18 = add i64 %.03544.us, %17
  %19 = getelementptr inbounds i8, ptr %.048.us, i64 %1
  %20 = add nuw i64 %.03147.us, 1
  %exitcond61.not = icmp eq i64 %20, %3
  br i1 %exitcond61.not, label %._crit_edge49.loopexit57, label %.preheader.us, !llvm.loop !10

21:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 33, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4Simd4Base12GetStatisticEPKhmmmPhS3_S3_) #3
  unreachable

._crit_edge49.loopexit57:                         ; preds = %._crit_edge.us
  %22 = trunc i32 %14 to i8
  %23 = trunc i32 %13 to i8
  br label %._crit_edge49

._crit_edge49:                                    ; preds = %._crit_edge49.loopexit57, %.preheader37
  %.035.lcssa = phi i64 [ 0, %.preheader37 ], [ %18, %._crit_edge49.loopexit57 ]
  %.033.lcssa = phi i8 [ -1, %.preheader37 ], [ %22, %._crit_edge49.loopexit57 ]
  %.032.lcssa = phi i8 [ 0, %.preheader37 ], [ %23, %._crit_edge49.loopexit57 ]
  %24 = lshr i64 %8, 1
  %25 = add i64 %.035.lcssa, %24
  %26 = udiv i64 %25, %8
  %27 = trunc i64 %26 to i8
  store i8 %27, ptr %6, align 1, !tbaa !5
  store i8 %.033.lcssa, ptr %4, align 1, !tbaa !5
  store i8 %.032.lcssa, ptr %5, align 1, !tbaa !5
  ret void
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Simd4Base5MaxU8Eii(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4Simd4Base5MinU8Eii(i32 noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 #1 = { noreturn 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 = { alwaysinline mustprogress 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 = { noreturn 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 = !{!"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,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass