; LLVM IR from paroj/gltut :: glsdk/glutil/source/MousePoles.ll (ZN6glutil8ViewPole8MoveAwayEb)

; 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.glutil::ViewPole" = type <{ %"class.glutil::ViewProvider", %"struct.glutil::ViewData", %"struct.glutil::ViewScale", %"struct.glutil::ViewData", i32, i8, i8, [2 x i8], i32, float, %"struct.glm::detail::tvec2", %"struct.glm::detail::tquat", [4 x i8] }>
%"class.glutil::ViewProvider" = type { ptr }
%"struct.glutil::ViewScale" = type { float, float, float, float, float, float, float }
%"struct.glutil::ViewData" = type { %"struct.glm::detail::tvec3", %"struct.glm::detail::tquat", float, float }
%"struct.glm::detail::tvec3" = type { %union.anon }
%union.anon = type { %struct.anon }
%struct.anon = type { float, float, float }
%"struct.glm::detail::tvec2" = type { %union.anon.2 }
%union.anon.2 = type { %struct.anon.3 }
%struct.anon.3 = type { i32, i32 }
%"struct.glm::detail::tquat" = type { float, float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6glutil8ViewPole8MoveAwayEb(ptr noundef nonnull align 8 dereferenceable(148) %0, i1 noundef zeroext %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  %5 = zext i1 %1 to i8
  store i8 %5, ptr %4, align 1, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  %7 = load i8, ptr %4, align 1, !tbaa !9, !range !11, !noundef !12
  %8 = trunc i8 %7 to i1
  br i1 %8, label %9, label %17

9:                                                ; preds = %2
  %10 = getelementptr inbounds %"class.glutil::ViewPole", ptr %6, i32 0, i32 2
  %11 = getelementptr inbounds %"struct.glutil::ViewScale", ptr %10, i32 0, i32 2
  %12 = load float, ptr %11, align 4, !tbaa !13
  %13 = getelementptr inbounds %"class.glutil::ViewPole", ptr %6, i32 0, i32 1
  %14 = getelementptr inbounds %"struct.glutil::ViewData", ptr %13, i32 0, i32 2
  %15 = load float, ptr %14, align 4, !tbaa !24
  %16 = fadd float %15, %12
  store float %16, ptr %14, align 4, !tbaa !24
  br label %25

17:                                               ; preds = %2
  %18 = getelementptr inbounds %"class.glutil::ViewPole", ptr %6, i32 0, i32 2
  %19 = getelementptr inbounds %"struct.glutil::ViewScale", ptr %18, i32 0, i32 3
  %20 = load float, ptr %19, align 4, !tbaa !25
  %21 = getelementptr inbounds %"class.glutil::ViewPole", ptr %6, i32 0, i32 1
  %22 = getelementptr inbounds %"struct.glutil::ViewData", ptr %21, i32 0, i32 2
  %23 = load float, ptr %22, align 4, !tbaa !24
  %24 = fadd float %23, %20
  store float %24, ptr %22, align 4, !tbaa !24
  br label %25

25:                                               ; preds = %17, %9
  %26 = getelementptr inbounds %"class.glutil::ViewPole", ptr %6, i32 0, i32 1
  %27 = getelementptr inbounds %"struct.glutil::ViewData", ptr %26, i32 0, i32 2
  %28 = load float, ptr %27, align 4, !tbaa !24
  %29 = getelementptr inbounds %"class.glutil::ViewPole", ptr %6, i32 0, i32 2
  %30 = getelementptr inbounds %"struct.glutil::ViewScale", ptr %29, i32 0, i32 1
  %31 = load float, ptr %30, align 4, !tbaa !26
  %32 = fcmp ogt float %28, %31
  br i1 %32, label %33, label %39

33:                                               ; preds = %25
  %34 = getelementptr inbounds %"class.glutil::ViewPole", ptr %6, i32 0, i32 2
  %35 = getelementptr inbounds %"struct.glutil::ViewScale", ptr %34, i32 0, i32 1
  %36 = load float, ptr %35, align 4, !tbaa !26
  %37 = getelementptr inbounds %"class.glutil::ViewPole", ptr %6, i32 0, i32 1
  %38 = getelementptr inbounds %"struct.glutil::ViewData", ptr %37, i32 0, i32 2
  store float %36, ptr %38, align 4, !tbaa !24
  br label %39

39:                                               ; preds = %33, %25
  ret void
}

attributes #0 = { 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" }

!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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !19, i64 52}
!14 = !{!"_ZTSN6glutil8ViewPoleE", !15, i64 0, !16, i64 8, !20, i64 44, !16, i64 72, !21, i64 108, !10, i64 112, !10, i64 113, !22, i64 116, !19, i64 120, !23, i64 124, !18, i64 132}
!15 = !{!"_ZTSN6glutil12ViewProviderE"}
!16 = !{!"_ZTSN6glutil8ViewDataE", !17, i64 0, !18, i64 12, !19, i64 28, !19, i64 32}
!17 = !{!"_ZTSN3glm6detail5tvec3IfEE", !7, i64 0}
!18 = !{!"_ZTSN3glm6detail5tquatIfEE", !19, i64 0, !19, i64 4, !19, i64 8, !19, i64 12}
!19 = !{!"float", !7, i64 0}
!20 = !{!"_ZTSN6glutil9ViewScaleE", !19, i64 0, !19, i64 4, !19, i64 8, !19, i64 12, !19, i64 16, !19, i64 20, !19, i64 24}
!21 = !{!"_ZTSN6glutil12MouseButtonsE", !7, i64 0}
!22 = !{!"_ZTSN6glutil8ViewPole10RotateModeE", !7, i64 0}
!23 = !{!"_ZTSN3glm6detail5tvec2IiEE", !7, i64 0}
!24 = !{!14, !19, i64 36}
!25 = !{!14, !19, i64 56}
!26 = !{!14, !19, i64 48}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN6glutil8ViewPole8MoveAwayEb(ptr nocapture noundef nonnull align 8 dereferenceable(148) %0, i1 noundef zeroext %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 36
  %4 = load float, ptr %3, align 4, !tbaa !5
  %. = select i1 %1, i64 52, i64 56
  %5 = getelementptr inbounds i8, ptr %0, i64 %.
  %6 = load float, ptr %5, align 4, !tbaa !19
  %7 = fadd float %6, %4
  store float %7, ptr %3, align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = load float, ptr %8, align 8, !tbaa !20
  %10 = fcmp ogt float %7, %9
  br i1 %10, label %11, label %13

11:                                               ; preds = %2
  %12 = getelementptr inbounds i8, ptr %0, i64 36
  store float %9, ptr %12, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %11, %2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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" }

!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, !13, i64 36}
!6 = !{!"_ZTSN6glutil8ViewPoleE", !7, i64 0, !8, i64 8, !14, i64 44, !8, i64 72, !15, i64 108, !16, i64 112, !16, i64 113, !17, i64 116, !13, i64 120, !18, i64 124, !12, i64 132}
!7 = !{!"_ZTSN6glutil12ViewProviderE"}
!8 = !{!"_ZTSN6glutil8ViewDataE", !9, i64 0, !12, i64 12, !13, i64 28, !13, i64 32}
!9 = !{!"_ZTSN3glm6detail5tvec3IfEE", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"_ZTSN3glm6detail5tquatIfEE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12}
!13 = !{!"float", !10, i64 0}
!14 = !{!"_ZTSN6glutil9ViewScaleE", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24}
!15 = !{!"_ZTSN6glutil12MouseButtonsE", !10, i64 0}
!16 = !{!"bool", !10, i64 0}
!17 = !{!"_ZTSN6glutil8ViewPole10RotateModeE", !10, i64 0}
!18 = !{!"_ZTSN3glm6detail5tvec2IiEE", !10, i64 0}
!19 = !{!13, !13, i64 0}
!20 = !{!6, !13, i64 48}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass