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

; 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.Vec = type <{ ptr, float, float, float, [4 x i8] }>
%struct.BoundingBox = type { %struct.Vec, %struct.Vec }
%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 uwtable
define dso_local void @_ZN7Encoder6mapVecERK3VecIfERK11BoundingBoxRKS0_IhE(ptr dead_on_unwind noalias writable sret(%struct.Vec.0) align 8 %0, ptr noundef nonnull align 8 dereferenceable(20) %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 %struct.Vec, ptr %12, i32 0, i32 1
  %14 = load float, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.BoundingBox, ptr %15, i32 0, i32 0
  %17 = getelementptr inbounds %struct.Vec, ptr %16, i32 0, i32 1
  %18 = load float, ptr %17, align 8, !tbaa !12
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.BoundingBox, ptr %19, i32 0, i32 1
  %21 = getelementptr inbounds %struct.Vec, ptr %20, i32 0, i32 1
  %22 = load float, ptr %21, align 8, !tbaa !14
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.Vec.1, ptr %23, i32 0, i32 1
  %25 = load i8, ptr %24, align 8, !tbaa !15
  %26 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %14, float noundef %18, float noundef %22, i8 noundef zeroext %25)
          to label %27 unwind label %67

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

45:                                               ; preds = %27
  %46 = zext i32 %44 to i64
  %47 = getelementptr inbounds %struct.Vec.0, ptr %0, i32 0, i32 2
  store i64 %46, ptr %47, align 8, !tbaa !24
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Vec, ptr %48, i32 0, i32 3
  %50 = load float, ptr %49, align 8, !tbaa !25
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.BoundingBox, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.Vec, ptr %52, i32 0, i32 3
  %54 = load float, ptr %53, align 8, !tbaa !26
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.BoundingBox, ptr %55, i32 0, i32 1
  %57 = getelementptr inbounds %struct.Vec, ptr %56, i32 0, i32 3
  %58 = load float, ptr %57, align 8, !tbaa !27
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.Vec.1, ptr %59, i32 0, i32 3
  %61 = load i8, ptr %60, align 2, !tbaa !28
  %62 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %50, float noundef %54, float noundef %58, i8 noundef zeroext %61)
          to label %63 unwind label %67

63:                                               ; preds = %45
  %64 = zext i32 %62 to i64
  %65 = getelementptr inbounds %struct.Vec.0, ptr %0, i32 0, i32 3
  store i64 %64, ptr %65, align 8, !tbaa !29
  store i1 true, ptr %9, align 1
  %66 = load i1, ptr %9, align 1
  br i1 %66, label %72, label %71

67:                                               ; preds = %45, %27, %4
  %68 = landingpad { ptr, i32 }
          cleanup
  %69 = extractvalue { ptr, i32 } %68, 0
  store ptr %69, ptr %10, align 8
  %70 = extractvalue { ptr, i32 } %68, 1
  store i32 %70, ptr %11, align 4
  call void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  br label %73

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

72:                                               ; preds = %71, %63
  ret void

73:                                               ; preds = %67
  %74 = load ptr, ptr %10, align 8
  %75 = load i32, ptr %11, align 4
  %76 = insertvalue { ptr, i32 } poison, ptr %74, 0
  %77 = insertvalue { ptr, i32 } %76, i32 %75, 1
  resume { ptr, i32 } %77
}

; 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

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 = !{!10, !11, i64 8}
!10 = !{!"_ZTS3VecIfE", !11, i64 8, !11, i64 12, !11, i64 16}
!11 = !{!"float", !7, i64 0}
!12 = !{!13, !11, i64 8}
!13 = !{!"_ZTS11BoundingBox", !10, i64 0, !10, i64 24}
!14 = !{!13, !11, 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 = !{!10, !11, i64 12}
!21 = !{!13, !11, i64 12}
!22 = !{!13, !11, i64 36}
!23 = !{!16, !7, i64 9}
!24 = !{!18, !19, i64 16}
!25 = !{!10, !11, i64 16}
!26 = !{!13, !11, i64 16}
!27 = !{!13, !11, i64 40}
!28 = !{!16, !7, i64 10}
!29 = !{!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 uwtable
define dso_local void @_ZN7Encoder6mapVecERK3VecIfERK11BoundingBoxRKS0_IhE(ptr dead_on_unwind noalias nonnull writable sret(%struct.Vec.0) align 8 %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(20) %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 8
  %6 = load float, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  %8 = load float, ptr %7, align 8, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %2, i64 32
  %10 = load float, ptr %9, align 8, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %3, i64 8
  %12 = load i8, ptr %11, align 8, !tbaa !13
  %13 = invoke noundef i32 @_ZN7Encoder8mapToBitEfffh(float noundef %6, float noundef %8, float noundef %10, i8 noundef zeroext %12)
          to label %14 unwind label %41

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

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

38:                                               ; preds = %26
  %39 = zext i32 %37 to i64
  %40 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %39, ptr %40, align 8, !tbaa !27
  ret void

41:                                               ; preds = %26, %14, %4
  %42 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN3VecImED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  resume { ptr, i32 } %42
}

; 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

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


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