; LLVM IR from rdguez-mariano/fast_imas_IPOL :: libSimuTilts/library.ll (Z5histoPfS_S_PiS_ic)

; 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.4 = external hidden unnamed_addr constant [47 x i8], align 1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z3maxPfPii(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z3minPfPii(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5clearPffi(ptr noundef, float noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #3

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #4

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

26:                                               ; preds = %7
  %27 = load i8, ptr %15, align 1, !tbaa !11
  %28 = sext i8 %27 to i32
  %29 = icmp ne i32 %28, 110
  br i1 %29, label %30, label %32

30:                                               ; preds = %26
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  store ptr null, ptr %8, align 8
  br label %129

32:                                               ; preds = %26, %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = load float, ptr %36, align 4, !tbaa !12
  store float %37, ptr %16, align 4, !tbaa !12
  br label %42

38:                                               ; preds = %32
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = load i32, ptr %14, align 4, !tbaa !9
  %41 = call noundef float @_Z3minPfPii(ptr noundef %39, ptr noundef null, i32 noundef %40)
  store float %41, ptr %16, align 4, !tbaa !12
  br label %42

42:                                               ; preds = %38, %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %43 = load ptr, ptr %11, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %48

45:                                               ; preds = %42
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = load float, ptr %46, align 4, !tbaa !12
  store float %47, ptr %17, align 4, !tbaa !12
  br label %52

48:                                               ; preds = %42
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %50 = load i32, ptr %14, align 4, !tbaa !9
  %51 = call noundef float @_Z3maxPfPii(ptr noundef %49, ptr noundef null, i32 noundef %50)
  store float %51, ptr %17, align 4, !tbaa !12
  br label %52

52:                                               ; preds = %48, %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %53 = load i8, ptr %15, align 1, !tbaa !11
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 110
  br i1 %55, label %56, label %67

56:                                               ; preds = %52
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = load i32, ptr %57, align 4, !tbaa !9
  store i32 %58, ptr %18, align 4, !tbaa !9
  %59 = load float, ptr %17, align 4, !tbaa !12
  %60 = load float, ptr %16, align 4, !tbaa !12
  %61 = fsub float %59, %60
  %62 = load i32, ptr %18, align 4, !tbaa !9
  %63 = sitofp i32 %62 to float
  %64 = fdiv float %61, %63
  store float %64, ptr %19, align 4, !tbaa !12
  %65 = load float, ptr %19, align 4, !tbaa !12
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  store float %65, ptr %66, align 4, !tbaa !12
  br label %80

67:                                               ; preds = %52
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = load float, ptr %68, align 4, !tbaa !12
  store float %69, ptr %19, align 4, !tbaa !12
  %70 = load float, ptr %17, align 4, !tbaa !12
  %71 = load float, ptr %16, align 4, !tbaa !12
  %72 = fsub float %70, %71
  %73 = load float, ptr %19, align 4, !tbaa !12
  %74 = fdiv float %72, %73
  %75 = fpext float %74 to double
  %76 = fadd double 5.000000e-01, %75
  %77 = fptosi double %76 to i32
  store i32 %77, ptr %18, align 4, !tbaa !9
  %78 = load i32, ptr %18, align 4, !tbaa !9
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 %78, ptr %79, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %67, %56
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %81 = load i32, ptr %18, align 4, !tbaa !9
  %82 = sext i32 %81 to i64
  %83 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %82, i64 4)
  %84 = extractvalue { i64, i1 } %83, 1
  %85 = extractvalue { i64, i1 } %83, 0
  %86 = select i1 %84, i64 -1, i64 %85
  %87 = call noalias noundef nonnull ptr @_Znam(i64 noundef %86) #7
  store ptr %87, ptr %20, align 8, !tbaa !5
  %88 = load ptr, ptr %20, align 8, !tbaa !5
  %89 = load i32, ptr %18, align 4, !tbaa !9
  call void @_Z5clearPffi(ptr noundef %88, float noundef 0.000000e+00, i32 noundef %89)
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %90

90:                                               ; preds = %124, %80
  %91 = load i32, ptr %21, align 4, !tbaa !9
  %92 = load i32, ptr %14, align 4, !tbaa !9
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %95, label %94

94:                                               ; preds = %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  br label %127

95:                                               ; preds = %90
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #6
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = load i32, ptr %21, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds float, ptr %96, i64 %98
  %100 = load float, ptr %99, align 4, !tbaa !12
  %101 = load float, ptr %16, align 4, !tbaa !12
  %102 = fsub float %100, %101
  %103 = load float, ptr %19, align 4, !tbaa !12
  %104 = fdiv float %102, %103
  %105 = call float @llvm.floor.f32(float %104)
  %106 = fptosi float %105 to i32
  store i32 %106, ptr %22, align 4, !tbaa !9
  %107 = load i32, ptr %22, align 4, !tbaa !9
  %108 = icmp slt i32 %107, 0
  br i1 %108, label %109, label %110

109:                                              ; preds = %95
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %110

110:                                              ; preds = %109, %95
  %111 = load i32, ptr %22, align 4, !tbaa !9
  %112 = load i32, ptr %18, align 4, !tbaa !9
  %113 = icmp sge i32 %111, %112
  br i1 %113, label %114, label %117

114:                                              ; preds = %110
  %115 = load i32, ptr %18, align 4, !tbaa !9
  %116 = sub nsw i32 %115, 1
  store i32 %116, ptr %22, align 4, !tbaa !9
  br label %117

117:                                              ; preds = %114, %110
  %118 = load ptr, ptr %20, align 8, !tbaa !5
  %119 = load i32, ptr %22, align 4, !tbaa !9
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds float, ptr %118, i64 %120
  %122 = load float, ptr %121, align 4, !tbaa !12
  %123 = fadd float %122, 1.000000e+00
  store float %123, ptr %121, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #6
  br label %124

124:                                              ; preds = %117
  %125 = load i32, ptr %21, align 4, !tbaa !9
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %21, align 4, !tbaa !9
  br label %90, !llvm.loop !14

127:                                              ; preds = %94
  %128 = load ptr, ptr %20, align 8, !tbaa !5
  store ptr %128, ptr %8, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %129

129:                                              ; preds = %127, %30
  %130 = load ptr, ptr %8, align 8
  ret ptr %130
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.floor.f32(float) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nobuiltin allocsize(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 = { 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }

!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"}


; 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.4 = external hidden unnamed_addr constant [47 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z3maxPfPii(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z3minPfPii(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5clearPffi(ptr noundef, float noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z5histoPfS_S_PiS_ic(ptr noundef %0, ptr noundef readonly %1, ptr noundef readonly %2, ptr nocapture noundef %3, ptr nocapture noundef %4, i32 noundef %5, i8 noundef signext %6) local_unnamed_addr #3 {
  switch i8 %6, label %8 [
    i8 115, label %10
    i8 110, label %10
  ]

8:                                                ; preds = %7
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %.loopexit

10:                                               ; preds = %7, %7
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %13, label %11

11:                                               ; preds = %10
  %12 = load float, ptr %1, align 4, !tbaa !5
  br label %15

13:                                               ; preds = %10
  %14 = tail call noundef float @_Z3minPfPii(ptr noundef %0, ptr noundef null, i32 noundef %5)
  br label %15

15:                                               ; preds = %13, %11
  %.047 = phi float [ %12, %11 ], [ %14, %13 ]
  %.not50 = icmp eq ptr %2, null
  br i1 %.not50, label %18, label %16

16:                                               ; preds = %15
  %17 = load float, ptr %2, align 4, !tbaa !5
  br label %20

18:                                               ; preds = %15
  %19 = tail call noundef float @_Z3maxPfPii(ptr noundef %0, ptr noundef null, i32 noundef %5)
  br label %20

20:                                               ; preds = %18, %16
  %.046 = phi float [ %17, %16 ], [ %19, %18 ]
  %21 = icmp eq i8 %6, 110
  %22 = fsub float %.046, %.047
  br i1 %21, label %23, label %27

23:                                               ; preds = %20
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = sitofp i32 %24 to float
  %26 = fdiv float %22, %25
  store float %26, ptr %4, align 4, !tbaa !5
  br label %33

27:                                               ; preds = %20
  %28 = load float, ptr %4, align 4, !tbaa !5
  %29 = fdiv float %22, %28
  %30 = fpext float %29 to double
  %31 = fadd double %30, 5.000000e-01
  %32 = fptosi double %31 to i32
  store i32 %32, ptr %3, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %27, %23
  %.045 = phi i32 [ %24, %23 ], [ %32, %27 ]
  %.044 = phi float [ %26, %23 ], [ %28, %27 ]
  %34 = sext i32 %.045 to i64
  %35 = icmp slt i32 %.045, 0
  %36 = shl nsw i64 %34, 2
  %37 = select i1 %35, i64 -1, i64 %36
  %38 = tail call noalias noundef nonnull ptr @_Znam(i64 noundef %37) #6
  tail call void @_Z5clearPffi(ptr noundef nonnull %38, float noundef 0.000000e+00, i32 noundef %.045)
  %39 = icmp sgt i32 %5, 0
  br i1 %39, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %33
  %40 = add nsw i32 %.045, -1
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %41

41:                                               ; preds = %.lr.ph, %41
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %41 ]
  %42 = getelementptr inbounds float, ptr %0, i64 %indvars.iv
  %43 = load float, ptr %42, align 4, !tbaa !5
  %44 = fsub float %43, %.047
  %45 = fdiv float %44, %.044
  %46 = tail call float @llvm.floor.f32(float %45)
  %47 = fptosi float %46 to i32
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %47, i32 0)
  %.not51 = icmp slt i32 %spec.store.select, %.045
  %spec.select = select i1 %.not51, i32 %spec.store.select, i32 %40
  %48 = sext i32 %spec.select to i64
  %49 = getelementptr inbounds float, ptr %38, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !5
  %51 = fadd float %50, 1.000000e+00
  store float %51, ptr %49, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %41, !llvm.loop !11

.loopexit:                                        ; preds = %41, %33, %8
  %.043 = phi ptr [ null, %8 ], [ %38, %33 ], [ %38, %41 ]
  ret ptr %.043
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.floor.f32(float) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #5

attributes #0 = { 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 #1 = { 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 #2 = { nobuiltin allocsize(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 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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { builtin allocsize(0) }

!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 = !{!"float", !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"}


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