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

; 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.1 = type <{ ptr, i8, i8, i8, [5 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 @_ZN7Encoder6mapVecEPKhRK11BoundingBoxRK3VecIhE(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(11) %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.1, ptr %25, i32 0, i32 1
  %27 = load i8, ptr %26, align 8, !tbaa !15
  %28 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %16, float noundef %20, float noundef %24, i8 noundef zeroext %27)
          to label %29 unwind label %73

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

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

69:                                               ; preds = %49
  %70 = zext i32 %68 to i64
  %71 = getelementptr inbounds %struct.Vec.0, ptr %0, i32 0, i32 3
  store i64 %70, ptr %71, align 8, !tbaa !27
  store i1 true, ptr %9, align 1
  %72 = load i1, ptr %9, align 1
  br i1 %72, label %78, label %77

73:                                               ; preds = %49, %29, %4
  %74 = landingpad { ptr, i32 }
          cleanup
  %75 = extractvalue { ptr, i32 } %74, 0
  store ptr %75, ptr %10, align 8
  %76 = extractvalue { ptr, i32 } %74, 1
  store i32 %76, ptr %11, align 4
  call void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  br label %79

77:                                               ; preds = %69
  call void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  br label %78

78:                                               ; preds = %77, %69
  ret void

79:                                               ; preds = %73
  %80 = load ptr, ptr %10, align 8
  %81 = load i32, ptr %11, align 4
  %82 = insertvalue { ptr, i32 } poison, ptr %80, 0
  %83 = insertvalue { ptr, i32 } %82, i32 %81, 1
  resume { ptr, i32 } %83
}

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, !7, i64 8}
!16 = !{!"_ZTS3VecIhE", !7, i64 8, !7, i64 9, !7, i64 10}
!17 = !{!18, !19, i64 8}
!18 = !{!"_ZTS3VecImE", !19, i64 8, !19, i64 16, !19, i64 24}
!19 = !{!"long", !7, i64 0}
!20 = !{!11, !13, i64 12}
!21 = !{!11, !13, i64 36}
!22 = !{!16, !7, i64 9}
!23 = !{!18, !19, i64 16}
!24 = !{!11, !13, i64 16}
!25 = !{!11, !13, i64 40}
!26 = !{!16, !7, i64 10}
!27 = !{!18, !19, 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 @_ZN7Encoder6mapVecEPKhRK11BoundingBoxRK3VecIhE(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(11) %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 i8, ptr %12, align 8, !tbaa !13
  %14 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %7, float noundef %9, float noundef %11, i8 noundef zeroext %13)
          to label %15 unwind label %44

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

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

41:                                               ; preds = %28
  %42 = zext i32 %40 to i64
  %43 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %42, ptr %43, align 8, !tbaa !25
  ret void

44:                                               ; preds = %28, %15, %4
  %45 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  resume { ptr, i32 } %45
}

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, !6, i64 8}
!14 = !{!"_ZTS3VecIhE", !6, i64 8, !6, i64 9, !6, i64 10}
!15 = !{!16, !17, i64 8}
!16 = !{!"_ZTS3VecImE", !17, i64 8, !17, i64 16, !17, i64 24}
!17 = !{!"long", !6, i64 0}
!18 = !{!9, !11, i64 12}
!19 = !{!9, !11, i64 36}
!20 = !{!14, !6, i64 9}
!21 = !{!16, !17, i64 16}
!22 = !{!9, !11, i64 16}
!23 = !{!9, !11, i64 40}
!24 = !{!14, !6, i64 10}
!25 = !{!16, !17, i64 24}


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