; LLVM IR from Pi-Man/PiE :: source/Camera5DoF.ll (ZN3PiE10Camera5DoF6rotateEfff)

; 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"

%"class.std::lock_guard" = type { ptr }
%"struct.PiE::Camera" = type { ptr, %"class.std::mutex", %"struct.PiE::Matrix", %"struct.PiE::Matrix", %"struct.PiE::Matrix", %"struct.PiE::Matrix", ptr, i8, float, float, float }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"struct.PiE::Matrix" = type { %"struct.std::array" }
%"struct.std::array" = type { [16 x float] }
%"struct.PiE::Camera5DoF" = type <{ %"struct.PiE::Camera", float, float, %"struct.PiE::Vec", [4 x i8] }>
%"struct.PiE::Vec" = type { %"struct.std::array.0" }
%"struct.std::array.0" = type { [3 x float] }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt10lock_guardISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3PiE10Camera5DoF6rotateEfff(ptr noundef nonnull align 8 dereferenceable(348) %0, float noundef %1, float noundef %2, float noundef %3) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca %"class.std::lock_guard", align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %13 = getelementptr inbounds %"struct.PiE::Camera", ptr %12, i32 0, i32 1
  call void @_ZNSt10lock_guardISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(40) %13)
  %14 = getelementptr inbounds %"struct.PiE::Camera", ptr %12, i32 0, i32 2
  %15 = load float, ptr %6, align 4, !tbaa !9
  %16 = fneg float %15
  %17 = invoke noundef nonnull align 4 dereferenceable(64) ptr @_ZN3PiE6MatrixIfLi4ELi4EE7rotateDILi2ELi0ESt9enable_ifILb1EvEEERS1_f(ptr noundef nonnull align 4 dereferenceable(64) %14, float noundef %16)
          to label %18 unwind label %28

18:                                               ; preds = %4
  %19 = load float, ptr %7, align 4, !tbaa !9
  %20 = getelementptr inbounds %"struct.PiE::Camera5DoF", ptr %12, i32 0, i32 1
  %21 = load float, ptr %20, align 8, !tbaa !11
  %22 = fadd float %21, %19
  store float %22, ptr %20, align 8, !tbaa !11
  %23 = getelementptr inbounds %"struct.PiE::Camera5DoF", ptr %12, i32 0, i32 1
  %24 = load float, ptr %23, align 8, !tbaa !11
  %25 = fcmp ogt float %24, 0x40567999A0000000
  br i1 %25, label %26, label %32

26:                                               ; preds = %18
  %27 = getelementptr inbounds %"struct.PiE::Camera5DoF", ptr %12, i32 0, i32 1
  store float 0x40567999A0000000, ptr %27, align 8, !tbaa !11
  br label %32

28:                                               ; preds = %4
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %10, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %11, align 4
  call void @_ZNSt10lock_guardISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %39

32:                                               ; preds = %26, %18
  %33 = getelementptr inbounds %"struct.PiE::Camera5DoF", ptr %12, i32 0, i32 1
  %34 = load float, ptr %33, align 8, !tbaa !11
  %35 = fcmp olt float %34, 0xC0567999A0000000
  br i1 %35, label %36, label %38

36:                                               ; preds = %32
  %37 = getelementptr inbounds %"struct.PiE::Camera5DoF", ptr %12, i32 0, i32 1
  store float 0xC0567999A0000000, ptr %37, align 8, !tbaa !11
  br label %38

38:                                               ; preds = %36, %32
  call void @_ZNSt10lock_guardISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret void

39:                                               ; preds = %28
  %40 = load ptr, ptr %10, align 8
  %41 = load i32, ptr %11, align 4
  %42 = insertvalue { ptr, i32 } poison, ptr %40, 0
  %43 = insertvalue { ptr, i32 } %42, i32 %41, 1
  resume { ptr, i32 } %43
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(64) ptr @_ZN3PiE6MatrixIfLi4ELi4EE7rotateDILi2ELi0ESt9enable_ifILb1EvEEERS1_f(ptr noundef nonnull align 4 dereferenceable(64), float noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 328}
!12 = !{!"_ZTSN3PiE10Camera5DoFE", !13, i64 0, !10, i64 328, !10, i64 332, !19, i64 336}
!13 = !{!"_ZTSN3PiE6CameraE", !14, i64 8, !16, i64 48, !16, i64 112, !16, i64 176, !16, i64 240, !6, i64 304, !18, i64 312, !10, i64 316, !10, i64 320, !10, i64 324}
!14 = !{!"_ZTSSt5mutex", !15, i64 0}
!15 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!16 = !{!"_ZTSN3PiE6MatrixIfLi4ELi4EEE", !17, i64 0}
!17 = !{!"_ZTSSt5arrayIfLm16EE", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"_ZTSN3PiE3VecIfLi3EEE", !20, i64 0}
!20 = !{!"_ZTSSt5arrayIfLm3EE", !7, i64 0}


; 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"

%"class.std::lock_guard" = type { ptr }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt10lock_guardISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3PiE10Camera5DoF6rotateEfff(ptr noundef nonnull align 8 dereferenceable(348) %0, float noundef %1, float noundef %2, float noundef %3) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.std::lock_guard", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  call void @_ZNSt10lock_guardISt5mutexEC2ERS0_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(40) %6)
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = fneg float %1
  %9 = invoke noundef nonnull align 4 dereferenceable(64) ptr @_ZN3PiE6MatrixIfLi4ELi4EE7rotateDILi2ELi0ESt9enable_ifILb1EvEEERS1_f(ptr noundef nonnull align 4 dereferenceable(64) %7, float noundef %8)
          to label %10 unwind label %16

10:                                               ; preds = %4
  %11 = getelementptr inbounds i8, ptr %0, i64 328
  %12 = load float, ptr %11, align 8, !tbaa !5
  %13 = fadd float %12, %2
  %14 = fcmp ogt float %13, 0x40567999A0000000
  %storemerge = select i1 %14, float 0x40567999A0000000, float %13
  %15 = fcmp olt float %storemerge, 0xC0567999A0000000
  %storemerge4 = select i1 %15, float 0xC0567999A0000000, float %storemerge
  store float %storemerge4, ptr %11, align 8, !tbaa !5
  call void @_ZNSt10lock_guardISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret void

16:                                               ; preds = %4
  %17 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt10lock_guardISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  resume { ptr, i32 } %17
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(64) ptr @_ZN3PiE6MatrixIfLi4ELi4EE7rotateDILi2ELi0ESt9enable_ifILb1EvEEERS1_f(ptr noundef nonnull align 4 dereferenceable(64), float noundef) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !16, i64 328}
!6 = !{!"_ZTSN3PiE10Camera5DoFE", !7, i64 0, !16, i64 328, !16, i64 332, !17, i64 336}
!7 = !{!"_ZTSN3PiE6CameraE", !8, i64 8, !12, i64 48, !12, i64 112, !12, i64 176, !12, i64 240, !14, i64 304, !15, i64 312, !16, i64 316, !16, i64 320, !16, i64 324}
!8 = !{!"_ZTSSt5mutex", !9, i64 0}
!9 = !{!"_ZTSSt12__mutex_base", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN3PiE6MatrixIfLi4ELi4EEE", !13, i64 0}
!13 = !{!"_ZTSSt5arrayIfLm16EE", !10, i64 0}
!14 = !{!"any pointer", !10, i64 0}
!15 = !{!"bool", !10, i64 0}
!16 = !{!"float", !10, i64 0}
!17 = !{!"_ZTSN3PiE3VecIfLi3EEE", !18, i64 0}
!18 = !{!"_ZTSSt5arrayIfLm3EE", !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass