; LLVM IR from b00dle/libpcc :: src/Encoder.ll (ZN7Encoder6mapVecEPKhRK11BoundingBoxRK3VecI8BitCountE)

; 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.Vec.0 = type { ptr, i64, i64, i64 }
%struct.BoundingBox = type { %struct.Vec, %struct.Vec }
%struct.Vec = type <{ ptr, float, float, float, [4 x i8] }>
%struct.Vec.3 = type <{ ptr, i32, i32, i32, [4 x i8] }>

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef, float noundef, float noundef, i8 noundef zeroext) #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3VecImEC2Emmm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, i64 noundef, i64 noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Encoder6mapVecEPKhRK11BoundingBoxRK3VecI8BitCountE(ptr dead_on_unwind noalias writable sret(%struct.Vec.0) align 8 %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(48) %2, ptr noundef nonnull align 8 dereferenceable(20) %3) #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i1, align 1
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  store i1 false, ptr %9, align 1
  call void @_ZN3VecImEC2Emmm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef 0, i64 noundef 0, i64 noundef 0)
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 1
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %15 = zext i8 %14 to i64
  %16 = uitofp i64 %15 to float
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.BoundingBox, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.Vec, ptr %18, i32 0, i32 1
  %20 = load float, ptr %19, align 8, !tbaa !10
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.BoundingBox, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds %struct.Vec, ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 8, !tbaa !14
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.Vec.3, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !15
  %28 = trunc i32 %27 to i8
  %29 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %16, float noundef %20, float noundef %24, i8 noundef zeroext %28)
          to label %30 unwind label %76

30:                                               ; preds = %4
  %31 = zext i32 %29 to i64
  %32 = getelementptr inbounds %struct.Vec.0, ptr %0, i32 0, i32 1
  store i64 %31, ptr %32, align 8, !tbaa !18
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %33, i64 2
  %35 = load i8, ptr %34, align 1, !tbaa !9
  %36 = zext i8 %35 to i64
  %37 = uitofp i64 %36 to float
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.BoundingBox, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct.Vec, ptr %39, i32 0, i32 2
  %41 = load float, ptr %40, align 4, !tbaa !21
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.BoundingBox, ptr %42, i32 0, i32 1
  %44 = getelementptr inbounds %struct.Vec, ptr %43, i32 0, i32 2
  %45 = load float, ptr %44, align 4, !tbaa !22
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Vec.3, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 4, !tbaa !23
  %49 = trunc i32 %48 to i8
  %50 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %37, float noundef %41, float noundef %45, i8 noundef zeroext %49)
          to label %51 unwind label %76

51:                                               ; preds = %30
  %52 = zext i32 %50 to i64
  %53 = getelementptr inbounds %struct.Vec.0, ptr %0, i32 0, i32 2
  store i64 %52, ptr %53, align 8, !tbaa !24
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 3
  %56 = load i8, ptr %55, align 1, !tbaa !9
  %57 = zext i8 %56 to i64
  %58 = uitofp i64 %57 to float
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.BoundingBox, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds %struct.Vec, ptr %60, i32 0, i32 3
  %62 = load float, ptr %61, align 8, !tbaa !25
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.BoundingBox, ptr %63, i32 0, i32 1
  %65 = getelementptr inbounds %struct.Vec, ptr %64, i32 0, i32 3
  %66 = load float, ptr %65, align 8, !tbaa !26
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.Vec.3, ptr %67, i32 0, i32 3
  %69 = load i32, ptr %68, align 8, !tbaa !27
  %70 = trunc i32 %69 to i8
  %71 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %58, float noundef %62, float noundef %66, i8 noundef zeroext %70)
          to label %72 unwind label %76

72:                                               ; preds = %51
  %73 = zext i32 %71 to i64
  %74 = getelementptr inbounds %struct.Vec.0, ptr %0, i32 0, i32 3
  store i64 %73, ptr %74, align 8, !tbaa !28
  store i1 true, ptr %9, align 1
  %75 = load i1, ptr %9, align 1
  br i1 %75, label %81, label %80

76:                                               ; preds = %51, %30, %4
  %77 = landingpad { ptr, i32 }
          cleanup
  %78 = extractvalue { ptr, i32 } %77, 0
  store ptr %78, ptr %10, align 8
  %79 = extractvalue { ptr, i32 } %77, 1
  store i32 %79, ptr %11, align 4
  call void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  br label %82

80:                                               ; preds = %72
  call void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  br label %81

81:                                               ; preds = %80, %72
  ret void

82:                                               ; preds = %76
  %83 = load ptr, ptr %10, align 8
  %84 = load i32, ptr %11, align 4
  %85 = insertvalue { ptr, i32 } poison, ptr %83, 0
  %86 = insertvalue { ptr, i32 } %85, i32 %84, 1
  resume { ptr, i32 } %86
}

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 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !13, i64 8}
!11 = !{!"_ZTS11BoundingBox", !12, i64 0, !12, i64 24}
!12 = !{!"_ZTS3VecIfE", !13, i64 8, !13, i64 12, !13, i64 16}
!13 = !{!"float", !7, i64 0}
!14 = !{!11, !13, i64 32}
!15 = !{!16, !17, i64 8}
!16 = !{!"_ZTS3VecI8BitCountE", !17, i64 8, !17, i64 12, !17, i64 16}
!17 = !{!"_ZTS8BitCount", !7, i64 0}
!18 = !{!19, !20, i64 8}
!19 = !{!"_ZTS3VecImE", !20, i64 8, !20, i64 16, !20, i64 24}
!20 = !{!"long", !7, i64 0}
!21 = !{!11, !13, i64 12}
!22 = !{!11, !13, i64 36}
!23 = !{!16, !17, i64 12}
!24 = !{!19, !20, i64 16}
!25 = !{!11, !13, i64 16}
!26 = !{!11, !13, i64 40}
!27 = !{!16, !17, i64 16}
!28 = !{!19, !20, i64 24}


; 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.Vec.0 = type { ptr, i64, i64, i64 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef, float noundef, float noundef, i8 noundef zeroext) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3VecImEC2Emmm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef, i64 noundef, i64 noundef) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7Encoder6mapVecEPKhRK11BoundingBoxRK3VecI8BitCountE(ptr dead_on_unwind noalias nonnull writable sret(%struct.Vec.0) align 8 %0, ptr nocapture noundef readonly %1, ptr nocapture noundef nonnull readonly align 8 dereferenceable(48) %2, ptr nocapture noundef nonnull readonly align 8 dereferenceable(20) %3) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN3VecImEC2Emmm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef 0, i64 noundef 0, i64 noundef 0)
  %5 = getelementptr inbounds i8, ptr %1, i64 1
  %6 = load i8, ptr %5, align 1, !tbaa !5
  %7 = uitofp i8 %6 to float
  %8 = getelementptr inbounds i8, ptr %2, i64 8
  %9 = load float, ptr %8, align 8, !tbaa !8
  %10 = getelementptr inbounds i8, ptr %2, i64 32
  %11 = load float, ptr %10, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %3, i64 8
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = trunc i32 %13 to i8
  %15 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %7, float noundef %9, float noundef %11, i8 noundef zeroext %14)
          to label %16 unwind label %47

16:                                               ; preds = %4
  %17 = zext i32 %15 to i64
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %17, ptr %18, align 8, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %1, i64 2
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %21 = uitofp i8 %20 to float
  %22 = getelementptr inbounds i8, ptr %2, i64 12
  %23 = load float, ptr %22, align 4, !tbaa !19
  %24 = getelementptr inbounds i8, ptr %2, i64 36
  %25 = load float, ptr %24, align 4, !tbaa !20
  %26 = getelementptr inbounds i8, ptr %3, i64 12
  %27 = load i32, ptr %26, align 4, !tbaa !21
  %28 = trunc i32 %27 to i8
  %29 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %21, float noundef %23, float noundef %25, i8 noundef zeroext %28)
          to label %30 unwind label %47

30:                                               ; preds = %16
  %31 = zext i32 %29 to i64
  %32 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %31, ptr %32, align 8, !tbaa !22
  %33 = getelementptr inbounds i8, ptr %1, i64 3
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = uitofp i8 %34 to float
  %36 = getelementptr inbounds i8, ptr %2, i64 16
  %37 = load float, ptr %36, align 8, !tbaa !23
  %38 = getelementptr inbounds i8, ptr %2, i64 40
  %39 = load float, ptr %38, align 8, !tbaa !24
  %40 = getelementptr inbounds i8, ptr %3, i64 16
  %41 = load i32, ptr %40, align 8, !tbaa !25
  %42 = trunc i32 %41 to i8
  %43 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %35, float noundef %37, float noundef %39, i8 noundef zeroext %42)
          to label %44 unwind label %47

44:                                               ; preds = %30
  %45 = zext i32 %43 to i64
  %46 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %45, ptr %46, align 8, !tbaa !26
  ret void

47:                                               ; preds = %30, %16, %4
  %48 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  resume { ptr, i32 } %48
}

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 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"_ZTS11BoundingBox", !10, i64 0, !10, i64 24}
!10 = !{!"_ZTS3VecIfE", !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"float", !6, i64 0}
!12 = !{!9, !11, i64 32}
!13 = !{!14, !15, i64 8}
!14 = !{!"_ZTS3VecI8BitCountE", !15, i64 8, !15, i64 12, !15, i64 16}
!15 = !{!"_ZTS8BitCount", !6, i64 0}
!16 = !{!17, !18, i64 8}
!17 = !{!"_ZTS3VecImE", !18, i64 8, !18, i64 16, !18, i64 24}
!18 = !{!"long", !6, i64 0}
!19 = !{!9, !11, i64 12}
!20 = !{!9, !11, i64 36}
!21 = !{!14, !15, i64 12}
!22 = !{!17, !18, i64 16}
!23 = !{!9, !11, i64 16}
!24 = !{!9, !11, i64 40}
!25 = !{!14, !15, i64 16}
!26 = !{!17, !18, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass