; LLVM IR from paroj/gltut :: Tut 13 Impostors/GeomImpostor.ll (Z8keyboardhii)

; 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.3 }
%union.anon.3 = type { %struct.anon }
%struct.anon = type { float, float, float }
%"struct.glm::detail::tvec2" = type { %union.anon.6 }
%union.anon.6 = type { %struct.anon.7 }
%struct.anon.7 = type { i32, i32 }
%"struct.glm::detail::tquat" = type { float, float, float, float }
%"class.Framework::Timer" = type { i32, float, i8, i8, float, float }

@g_viewPole = external dso_local global %"class.glutil::ViewPole", align 8
@g_pPlaneMesh = external dso_local global ptr, align 8
@g_pSphereMesh = external dso_local global ptr, align 8
@g_bDrawCameraPos = external dso_local global i8, align 1
@g_bDrawLights = external dso_local global i8, align 1
@g_sphereTimer = external dso_local global %"class.Framework::Timer", align 4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8keyboardhii(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i8 %0, ptr %4, align 1, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !8
  store i32 %2, ptr %6, align 4, !tbaa !8
  %7 = load i8, ptr %4, align 1, !tbaa !5
  %8 = zext i8 %7 to i32
  switch i32 %8, label %32 [
    i32 27, label %9
    i32 112, label %18
    i32 45, label %20
    i32 61, label %21
    i32 116, label %22
    i32 103, label %27
  ]

9:                                                ; preds = %3
  %10 = load ptr, ptr @g_pPlaneMesh, align 8, !tbaa !10
  %11 = icmp eq ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @_ZN9Framework4MeshD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #4
  call void @_ZdlPvm(ptr noundef %10, i64 noundef 8) #5
  br label %13

13:                                               ; preds = %12, %9
  %14 = load ptr, ptr @g_pSphereMesh, align 8, !tbaa !10
  %15 = icmp eq ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %13
  call void @_ZN9Framework4MeshD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #4
  call void @_ZdlPvm(ptr noundef %14, i64 noundef 8) #5
  br label %17

17:                                               ; preds = %16, %13
  store ptr null, ptr @g_pPlaneMesh, align 8, !tbaa !10
  store ptr null, ptr @g_pSphereMesh, align 8, !tbaa !10
  call void @glutLeaveMainLoop()
  br label %34

18:                                               ; preds = %3
  %19 = call noundef zeroext i1 @_ZN9Framework5Timer11TogglePauseEv(ptr noundef nonnull align 4 dereferenceable(20) @g_sphereTimer)
  br label %32

20:                                               ; preds = %3
  call void @_ZN9Framework5Timer6RewindEf(ptr noundef nonnull align 4 dereferenceable(20) @g_sphereTimer, float noundef 5.000000e-01)
  br label %32

21:                                               ; preds = %3
  call void @_ZN9Framework5Timer11FastforwardEf(ptr noundef nonnull align 4 dereferenceable(20) @g_sphereTimer, float noundef 5.000000e-01)
  br label %32

22:                                               ; preds = %3
  %23 = load i8, ptr @g_bDrawCameraPos, align 1, !tbaa !12, !range !14, !noundef !15
  %24 = trunc i8 %23 to i1
  %25 = xor i1 %24, true
  %26 = zext i1 %25 to i8
  store i8 %26, ptr @g_bDrawCameraPos, align 1, !tbaa !12
  br label %32

27:                                               ; preds = %3
  %28 = load i8, ptr @g_bDrawLights, align 1, !tbaa !12, !range !14, !noundef !15
  %29 = trunc i8 %28 to i1
  %30 = xor i1 %29, true
  %31 = zext i1 %30 to i8
  store i8 %31, ptr @g_bDrawLights, align 1, !tbaa !12
  br label %32

32:                                               ; preds = %27, %22, %21, %20, %18, %3
  %33 = load i8, ptr %4, align 1, !tbaa !5
  call void @_ZN6glutil8ViewPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(148) @g_viewPole, i8 noundef signext %33)
  br label %34

34:                                               ; preds = %32, %17
  ret void
}

; Function Attrs: nounwind
declare void @_ZN9Framework4MeshD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

declare void @glutLeaveMainLoop() #3

declare noundef zeroext i1 @_ZN9Framework5Timer11TogglePauseEv(ptr noundef nonnull align 4 dereferenceable(20)) #3

declare void @_ZN9Framework5Timer6RewindEf(ptr noundef nonnull align 4 dereferenceable(20), float noundef) #3

declare void @_ZN9Framework5Timer11FastforwardEf(ptr noundef nonnull align 4 dereferenceable(20), float noundef) #3

declare void @_ZN6glutil8ViewPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(148), i8 noundef signext) #3

attributes #0 = { nobuiltin nounwind "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 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 "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 = { "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 #4 = { nounwind }
attributes #5 = { builtin 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, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"bool", !6, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}


; 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.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.3 }
%union.anon.3 = type { %struct.anon }
%struct.anon = type { float, float, float }
%"struct.glm::detail::tvec2" = type { %union.anon.6 }
%union.anon.6 = type { %struct.anon.7 }
%struct.anon.7 = type { i32, i32 }
%"struct.glm::detail::tquat" = type { float, float, float, float }
%"class.Framework::Timer" = type { i32, float, i8, i8, float, float }

@g_viewPole = external dso_local global %"class.glutil::ViewPole", align 8
@g_pPlaneMesh = external dso_local local_unnamed_addr global ptr, align 8
@g_pSphereMesh = external dso_local local_unnamed_addr global ptr, align 8
@g_bDrawCameraPos = external dso_local local_unnamed_addr global i8, align 1
@g_bDrawLights = external dso_local local_unnamed_addr global i8, align 1
@g_sphereTimer = external dso_local global %"class.Framework::Timer", align 4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8keyboardhii(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  switch i8 %0, label %23 [
    i8 27, label %4
    i8 112, label %13
    i8 45, label %15
    i8 61, label %16
    i8 116, label %17
    i8 103, label %20
  ]

4:                                                ; preds = %3
  %5 = load ptr, ptr @g_pPlaneMesh, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %8, label %7

7:                                                ; preds = %4
  tail call void @_ZN9Framework4MeshD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #4
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 8) #5
  br label %8

8:                                                ; preds = %7, %4
  %9 = load ptr, ptr @g_pSphereMesh, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  tail call void @_ZN9Framework4MeshD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #4
  tail call void @_ZdlPvm(ptr noundef nonnull %9, i64 noundef 8) #5
  br label %12

12:                                               ; preds = %11, %8
  store ptr null, ptr @g_pPlaneMesh, align 8, !tbaa !5
  store ptr null, ptr @g_pSphereMesh, align 8, !tbaa !5
  tail call void @glutLeaveMainLoop()
  br label %24

13:                                               ; preds = %3
  %14 = tail call noundef zeroext i1 @_ZN9Framework5Timer11TogglePauseEv(ptr noundef nonnull align 4 dereferenceable(20) @g_sphereTimer)
  br label %23

15:                                               ; preds = %3
  tail call void @_ZN9Framework5Timer6RewindEf(ptr noundef nonnull align 4 dereferenceable(20) @g_sphereTimer, float noundef 5.000000e-01)
  br label %23

16:                                               ; preds = %3
  tail call void @_ZN9Framework5Timer11FastforwardEf(ptr noundef nonnull align 4 dereferenceable(20) @g_sphereTimer, float noundef 5.000000e-01)
  br label %23

17:                                               ; preds = %3
  %18 = load i8, ptr @g_bDrawCameraPos, align 1, !tbaa !9, !range !11, !noundef !12
  %19 = xor i8 %18, 1
  store i8 %19, ptr @g_bDrawCameraPos, align 1, !tbaa !9
  br label %23

20:                                               ; preds = %3
  %21 = load i8, ptr @g_bDrawLights, align 1, !tbaa !9, !range !11, !noundef !12
  %22 = xor i8 %21, 1
  store i8 %22, ptr @g_bDrawLights, align 1, !tbaa !9
  br label %23

23:                                               ; preds = %20, %17, %16, %15, %13, %3
  tail call void @_ZN6glutil8ViewPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(148) @g_viewPole, i8 noundef signext %0)
  br label %24

24:                                               ; preds = %23, %12
  ret void
}

; Function Attrs: nounwind
declare void @_ZN9Framework4MeshD1Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2

declare void @glutLeaveMainLoop() local_unnamed_addr #3

declare noundef zeroext i1 @_ZN9Framework5Timer11TogglePauseEv(ptr noundef nonnull align 4 dereferenceable(20)) local_unnamed_addr #3

declare void @_ZN9Framework5Timer6RewindEf(ptr noundef nonnull align 4 dereferenceable(20), float noundef) local_unnamed_addr #3

declare void @_ZN9Framework5Timer11FastforwardEf(ptr noundef nonnull align 4 dereferenceable(20), float noundef) local_unnamed_addr #3

declare void @_ZN6glutil8ViewPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(148), i8 noundef signext) local_unnamed_addr #3

attributes #0 = { nobuiltin nounwind "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 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 "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 = { "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 #4 = { nounwind }
attributes #5 = { builtin 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,TailCallElimPass