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

; 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 uwtable
declare dso_local void @_ZN6glutil8ViewPole15BeginDragRotateERKN3glm6detail5tvec2IiEENS0_10RotateModeE(ptr noundef nonnull align 8 dereferenceable(148), ptr noundef nonnull align 4 dereferenceable(8), i32 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6glutil8ViewPole13EndDragRotateERKN3glm6detail5tvec2IiEEb(ptr noundef nonnull align 8 dereferenceable(148), ptr noundef nonnull align 4 dereferenceable(8), i1 noundef zeroext) #0 align 2

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

15:                                               ; preds = %5
  %16 = getelementptr inbounds %"class.glutil::ViewPole", ptr %12, i32 0, i32 6
  %17 = load i8, ptr %16, align 1, !tbaa !17, !range !15, !noundef !16
  %18 = trunc i8 %17 to i1
  br i1 %18, label %41, label %19

19:                                               ; preds = %15
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = getelementptr inbounds %"class.glutil::ViewPole", ptr %12, i32 0, i32 4
  %22 = load i32, ptr %21, align 4, !tbaa !27
  %23 = icmp eq i32 %20, %22
  br i1 %23, label %24, label %40

24:                                               ; preds = %19
  %25 = load i32, ptr %9, align 4, !tbaa !13
  %26 = and i32 %25, 2
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %24
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN6glutil8ViewPole15BeginDragRotateERKN3glm6detail5tvec2IiEENS0_10RotateModeE(ptr noundef nonnull align 8 dereferenceable(148) %12, ptr noundef nonnull align 4 dereferenceable(8) %29, i32 noundef 1)
  br label %39

30:                                               ; preds = %24
  %31 = load i32, ptr %9, align 4, !tbaa !13
  %32 = and i32 %31, 4
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %36

34:                                               ; preds = %30
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN6glutil8ViewPole15BeginDragRotateERKN3glm6detail5tvec2IiEENS0_10RotateModeE(ptr noundef nonnull align 8 dereferenceable(148) %12, ptr noundef nonnull align 4 dereferenceable(8) %35, i32 noundef 4)
  br label %38

36:                                               ; preds = %30
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN6glutil8ViewPole15BeginDragRotateERKN3glm6detail5tvec2IiEENS0_10RotateModeE(ptr noundef nonnull align 8 dereferenceable(148) %12, ptr noundef nonnull align 4 dereferenceable(8) %37, i32 noundef 0)
  br label %38

38:                                               ; preds = %36, %34
  br label %39

39:                                               ; preds = %38, %28
  br label %40

40:                                               ; preds = %39, %19
  br label %41

41:                                               ; preds = %40, %15
  br label %68

42:                                               ; preds = %5
  %43 = getelementptr inbounds %"class.glutil::ViewPole", ptr %12, i32 0, i32 6
  %44 = load i8, ptr %43, align 1, !tbaa !17, !range !15, !noundef !16
  %45 = trunc i8 %44 to i1
  br i1 %45, label %46, label %67

46:                                               ; preds = %42
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = getelementptr inbounds %"class.glutil::ViewPole", ptr %12, i32 0, i32 4
  %49 = load i32, ptr %48, align 4, !tbaa !27
  %50 = icmp eq i32 %47, %49
  br i1 %50, label %51, label %66

51:                                               ; preds = %46
  %52 = getelementptr inbounds %"class.glutil::ViewPole", ptr %12, i32 0, i32 8
  %53 = load i32, ptr %52, align 4, !tbaa !28
  %54 = icmp eq i32 %53, 0
  br i1 %54, label %63, label %55

55:                                               ; preds = %51
  %56 = getelementptr inbounds %"class.glutil::ViewPole", ptr %12, i32 0, i32 8
  %57 = load i32, ptr %56, align 4, !tbaa !28
  %58 = icmp eq i32 %57, 4
  br i1 %58, label %63, label %59

59:                                               ; preds = %55
  %60 = getelementptr inbounds %"class.glutil::ViewPole", ptr %12, i32 0, i32 8
  %61 = load i32, ptr %60, align 4, !tbaa !28
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %65

63:                                               ; preds = %59, %55, %51
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN6glutil8ViewPole13EndDragRotateERKN3glm6detail5tvec2IiEEb(ptr noundef nonnull align 8 dereferenceable(148) %12, ptr noundef nonnull align 4 dereferenceable(8) %64, i1 noundef zeroext true)
  br label %65

65:                                               ; preds = %63, %59
  br label %66

66:                                               ; preds = %65, %46
  br label %67

67:                                               ; preds = %66, %42
  br label %68

68:                                               ; preds = %67, %41
  ret void
}

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

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


; 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 uwtable
declare dso_local void @_ZN6glutil8ViewPole15BeginDragRotateERKN3glm6detail5tvec2IiEENS0_10RotateModeE(ptr noundef nonnull align 8 dereferenceable(148), ptr noundef nonnull align 4 dereferenceable(8), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6glutil8ViewPole13EndDragRotateERKN3glm6detail5tvec2IiEEb(ptr noundef nonnull align 8 dereferenceable(148), ptr noundef nonnull align 4 dereferenceable(8), i1 noundef zeroext) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6glutil8ViewPole10MouseClickENS_12MouseButtonsEbiRKN3glm6detail5tvec2IiEE(ptr noundef nonnull align 8 dereferenceable(148) %0, i32 noundef %1, i1 noundef zeroext %2, i32 noundef %3, ptr noundef nonnull align 4 dereferenceable(8) %4) local_unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 113
  %7 = load i8, ptr %6, align 1, !tbaa !5, !range !19, !noundef !20
  %8 = trunc nuw i8 %7 to i1
  %9 = getelementptr inbounds i8, ptr %0, i64 108
  %10 = load i32, ptr %9, align 4
  br i1 %2, label %11, label %20

11:                                               ; preds = %5
  %12 = icmp ne i32 %10, %1
  %or.cond.not = select i1 %8, i1 true, i1 %12
  br i1 %or.cond.not, label %26, label %13

13:                                               ; preds = %11
  %14 = and i32 %3, 2
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %16, label %15

15:                                               ; preds = %13
  tail call void @_ZN6glutil8ViewPole15BeginDragRotateERKN3glm6detail5tvec2IiEENS0_10RotateModeE(ptr noundef nonnull align 8 dereferenceable(148) %0, ptr noundef nonnull align 4 dereferenceable(8) %4, i32 noundef 1)
  br label %26

16:                                               ; preds = %13
  %17 = and i32 %3, 4
  %.not9 = icmp eq i32 %17, 0
  br i1 %.not9, label %19, label %18

18:                                               ; preds = %16
  tail call void @_ZN6glutil8ViewPole15BeginDragRotateERKN3glm6detail5tvec2IiEENS0_10RotateModeE(ptr noundef nonnull align 8 dereferenceable(148) %0, ptr noundef nonnull align 4 dereferenceable(8) %4, i32 noundef 4)
  br label %26

19:                                               ; preds = %16
  tail call void @_ZN6glutil8ViewPole15BeginDragRotateERKN3glm6detail5tvec2IiEENS0_10RotateModeE(ptr noundef nonnull align 8 dereferenceable(148) %0, ptr noundef nonnull align 4 dereferenceable(8) %4, i32 noundef 0)
  br label %26

20:                                               ; preds = %5
  %21 = icmp eq i32 %10, %1
  %or.cond15 = select i1 %8, i1 %21, i1 false
  br i1 %or.cond15, label %22, label %26

22:                                               ; preds = %20
  %23 = getelementptr inbounds i8, ptr %0, i64 116
  %24 = load i32, ptr %23, align 4, !tbaa !21
  switch i32 %24, label %26 [
    i32 0, label %25
    i32 4, label %25
    i32 1, label %25
  ]

25:                                               ; preds = %22, %22, %22
  tail call void @_ZN6glutil8ViewPole13EndDragRotateERKN3glm6detail5tvec2IiEEb(ptr noundef nonnull align 8 dereferenceable(148) %0, ptr noundef nonnull align 4 dereferenceable(8) %4, i1 noundef zeroext true)
  br label %26

26:                                               ; preds = %22, %20, %25, %11, %15, %19, %18
  ret void
}

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

!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 113}
!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 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!6, !17, i64 116}


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