; LLVM IR from kobalicek/simdtests :: rgbhsv/rgbhsv_test.ll (Z12rgbhsv_benchPKcPFvPfPKfiES5_S1_S1_i)

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

@.str = external hidden unnamed_addr constant [45 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12rgbhsv_benchPKcPFvPfPKfiES5_S1_S1_i(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca %struct.SimdTimer, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store i32 %5, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 1000, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  call void @_ZN9SimdTimerC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %15)
  %16 = load ptr, ptr %10, align 8, !tbaa !5
  %17 = load i32, ptr %12, align 4, !tbaa !9
  call void @_ZL11rgbhsv_fillPfi(ptr noundef %16, i32 noundef %17)
  call void @_ZN9SimdTimer5startEv(ptr noundef nonnull align 4 dereferenceable(4) %15)
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %27, %6
  %19 = load i32, ptr %13, align 4, !tbaa !9
  %20 = load i32, ptr %14, align 4, !tbaa !9
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %22, label %30

22:                                               ; preds = %18
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = load i32, ptr %12, align 4, !tbaa !9
  call void %23(ptr noundef %24, ptr noundef %25, i32 noundef %26)
  br label %27

27:                                               ; preds = %22
  %28 = load i32, ptr %13, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %13, align 4, !tbaa !9
  br label %18, !llvm.loop !11

30:                                               ; preds = %18
  call void @_ZN9SimdTimer4stopEv(ptr noundef nonnull align 4 dereferenceable(4) %15)
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4) %15)
  %33 = udiv i32 %32, 1000
  %34 = call noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4) %15)
  %35 = urem i32 %34, 1000
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %31, i32 noundef %33, i32 noundef %35)
  call void @_ZN9SimdTimer5startEv(ptr noundef nonnull align 4 dereferenceable(4) %15)
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %46, %30
  %38 = load i32, ptr %13, align 4, !tbaa !9
  %39 = load i32, ptr %14, align 4, !tbaa !9
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %49

41:                                               ; preds = %37
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = load i32, ptr %12, align 4, !tbaa !9
  call void %42(ptr noundef %43, ptr noundef %44, i32 noundef %45)
  br label %46

46:                                               ; preds = %41
  %47 = load i32, ptr %13, align 4, !tbaa !9
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %13, align 4, !tbaa !9
  br label %37, !llvm.loop !13

49:                                               ; preds = %37
  call void @_ZN9SimdTimer4stopEv(ptr noundef nonnull align 4 dereferenceable(4) %15)
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = call noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4) %15)
  %52 = udiv i32 %51, 1000
  %53 = call noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4) %15)
  %54 = urem i32 %53, 1000
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %50, i32 noundef %52, i32 noundef %54)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  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 nounwind uwtable
declare dso_local void @_ZN9SimdTimerC2Ev(ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL11rgbhsv_fillPfi(ptr noundef, i32 noundef) #3

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN9SimdTimer5startEv(ptr noundef nonnull align 4 dereferenceable(4)) #4 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN9SimdTimer4stopEv(ptr noundef nonnull align 4 dereferenceable(4)) #2 align 2

declare i32 @printf(ptr noundef, ...) #5

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4)) #2 align 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 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 = { 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 = { 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 #5 = { "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 #6 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@.str = external hidden unnamed_addr constant [45 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [45 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z12rgbhsv_benchPKcPFvPfPKfiES5_S1_S1_i(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr noundef %3, ptr noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = alloca %struct.SimdTimer, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #6
  call void @_ZN9SimdTimerC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @_ZL11rgbhsv_fillPfi(ptr noundef %3, i32 noundef %5)
  call void @_ZN9SimdTimer5startEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  br label %8

8:                                                ; preds = %6, %8
  %.017 = phi i32 [ 0, %6 ], [ %9, %8 ]
  call void %1(ptr noundef %4, ptr noundef %3, i32 noundef %5)
  %9 = add nuw nsw i32 %.017, 1
  %exitcond.not = icmp eq i32 %9, 1000
  br i1 %exitcond.not, label %10, label %8, !llvm.loop !5

10:                                               ; preds = %8
  call void @_ZN9SimdTimer4stopEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  %11 = call noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  %12 = udiv i32 %11, 1000
  %13 = call noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  %14 = urem i32 %13, 1000
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef %0, i32 noundef %12, i32 noundef %14)
  call void @_ZN9SimdTimer5startEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  br label %16

16:                                               ; preds = %10, %16
  %.118 = phi i32 [ 0, %10 ], [ %17, %16 ]
  call void %2(ptr noundef %3, ptr noundef %4, i32 noundef %5)
  %17 = add nuw nsw i32 %.118, 1
  %exitcond19.not = icmp eq i32 %17, 1000
  br i1 %exitcond19.not, label %18, label %16, !llvm.loop !7

18:                                               ; preds = %16
  call void @_ZN9SimdTimer4stopEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  %19 = call noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  %20 = udiv i32 %19, 1000
  %21 = call noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4) %7)
  %22 = urem i32 %21, 1000
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef %0, i32 noundef %20, i32 noundef %22)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  ret void
}

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN9SimdTimerC2Ev(ptr noundef nonnull align 4 dereferenceable(4)) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL11rgbhsv_fillPfi(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline mustprogress uwtable
declare dso_local void @_ZN9SimdTimer5startEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4 align 2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local void @_ZN9SimdTimer4stopEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK9SimdTimer3getEv(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { 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 #5 = { nofree 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 #6 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass