; LLVM IR from paroj/gltut :: Tut 18 Bumpy Textures/BumpySquare.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.Framework::Timer" = type { i32, float, i8, i8, float, float }

@g_pViewPole = external dso_local global ptr, align 8
@g_pObjPole = external dso_local global ptr, align 8
@g_pScene = external dso_local global ptr, align 8
@g_timer = external dso_local global %"class.Framework::Timer", align 4
@_ZTISt9exception = external constant ptr
@g_bDrawCameraPos = external dso_local global i8, align 1
@g_bDrawLightPos = external dso_local global i8, align 1
@g_bLongLightRange = external dso_local global i8, align 1
@g_bDrawBumpmap = external dso_local global i8, align 1
@.str.19 = external hidden unnamed_addr constant [30 x i8], align 1

; 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 @_Z17LoadAndSetupScenev() #1

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #3

declare ptr @__cxa_begin_catch(ptr)

declare i32 @printf(ptr noundef, ...) #4

declare void @__cxa_end_catch()

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #5

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8keyboardhii(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2) #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  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
  %10 = load i8, ptr %4, align 1, !tbaa !5
  %11 = zext i8 %10 to i32
  switch i32 %11, label %65 [
    i32 27, label %12
    i32 32, label %17
    i32 116, label %22
    i32 103, label %27
    i32 105, label %32
    i32 112, label %37
    i32 13, label %39
  ]

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

15:                                               ; preds = %12
  call void @_ZN9Framework5SceneD1Ev(ptr noundef nonnull align 8 dereferenceable(8) %13) #7
  call void @_ZdlPvm(ptr noundef %13, i64 noundef 8) #8
  br label %16

16:                                               ; preds = %15, %12
  store ptr null, ptr @g_pScene, align 8, !tbaa !10
  call void @glutLeaveMainLoop()
  br label %73

17:                                               ; preds = %3
  %18 = load i8, ptr @g_bDrawBumpmap, align 1, !tbaa !12, !range !14, !noundef !15
  %19 = trunc i8 %18 to i1
  %20 = xor i1 %19, true
  %21 = zext i1 %20 to i8
  store i8 %21, ptr @g_bDrawBumpmap, align 1, !tbaa !12
  br label %65

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 %65

27:                                               ; preds = %3
  %28 = load i8, ptr @g_bDrawLightPos, 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_bDrawLightPos, align 1, !tbaa !12
  br label %65

32:                                               ; preds = %3
  %33 = load i8, ptr @g_bLongLightRange, align 1, !tbaa !12, !range !14, !noundef !15
  %34 = trunc i8 %33 to i1
  %35 = xor i1 %34, true
  %36 = zext i1 %35 to i8
  store i8 %36, ptr @g_bLongLightRange, align 1, !tbaa !12
  br label %65

37:                                               ; preds = %3
  %38 = call noundef zeroext i1 @_ZN9Framework5Timer11TogglePauseEv(ptr noundef nonnull align 4 dereferenceable(20) @g_timer)
  br label %65

39:                                               ; preds = %3
  invoke void @_Z17LoadAndSetupScenev()
          to label %40 unwind label %41

40:                                               ; preds = %39
  br label %64

41:                                               ; preds = %39
  %42 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %7, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %8, align 4
  br label %45

45:                                               ; preds = %41
  %46 = load i32, ptr %8, align 4
  %47 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt9exception) #7
  %48 = icmp eq i32 %46, %47
  br i1 %48, label %49, label %74

49:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %50 = load ptr, ptr %7, align 8
  %51 = call ptr @__cxa_begin_catch(ptr %50) #7
  store ptr %51, ptr %9, align 8
  %52 = load ptr, ptr %9, align 8, !tbaa !10
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = getelementptr inbounds ptr, ptr %53, i64 2
  %55 = load ptr, ptr %54, align 8
  %56 = call noundef ptr %55(ptr noundef nonnull align 8 dereferenceable(8) %52) #7
  %57 = invoke i32 (ptr, ...) @printf(ptr noundef @.str.19, ptr noundef %56)
          to label %58 unwind label %59

58:                                               ; preds = %49
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %73

59:                                               ; preds = %49
  %60 = landingpad { ptr, i32 }
          cleanup
  %61 = extractvalue { ptr, i32 } %60, 0
  store ptr %61, ptr %7, align 8
  %62 = extractvalue { ptr, i32 } %60, 1
  store i32 %62, ptr %8, align 4
  invoke void @__cxa_end_catch()
          to label %63 unwind label %79

63:                                               ; preds = %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  br label %74

64:                                               ; preds = %40
  br label %65

65:                                               ; preds = %64, %37, %32, %27, %22, %17, %3
  %66 = load ptr, ptr @g_pViewPole, align 8, !tbaa !10
  %67 = icmp ne ptr %66, null
  br i1 %67, label %68, label %73

68:                                               ; preds = %65
  %69 = load ptr, ptr @g_pViewPole, align 8, !tbaa !10
  %70 = load i8, ptr %4, align 1, !tbaa !5
  call void @_ZN6glutil8ViewPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(148) %69, i8 noundef signext %70)
  %71 = load ptr, ptr @g_pObjPole, align 8, !tbaa !10
  %72 = load i8, ptr %4, align 1, !tbaa !5
  call void @_ZN6glutil10ObjectPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(112) %71, i8 noundef signext %72)
  br label %73

73:                                               ; preds = %68, %65, %58, %16
  ret void

74:                                               ; preds = %63, %45
  %75 = load ptr, ptr %7, align 8
  %76 = load i32, ptr %8, align 4
  %77 = insertvalue { ptr, i32 } poison, ptr %75, 0
  %78 = insertvalue { ptr, i32 } %77, i32 %76, 1
  resume { ptr, i32 } %78

79:                                               ; preds = %59
  %80 = landingpad { ptr, i32 }
          catch ptr null
  %81 = extractvalue { ptr, i32 } %80, 0
  call void @__clang_call_terminate(ptr %81) #9
  unreachable
}

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

declare void @glutLeaveMainLoop() #4

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

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

declare void @_ZN6glutil10ObjectPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(112), i8 noundef signext) #4

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 = { 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 #3 = { nounwind memory(none) }
attributes #4 = { "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 #5 = { noinline noreturn nounwind uwtable "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 #6 = { 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 #7 = { nounwind }
attributes #8 = { builtin nounwind }
attributes #9 = { noreturn 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 = !{}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !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.Framework::Timer" = type { i32, float, i8, i8, float, float }

@g_pViewPole = external dso_local local_unnamed_addr global ptr, align 8
@g_pObjPole = external dso_local local_unnamed_addr global ptr, align 8
@g_pScene = external dso_local local_unnamed_addr global ptr, align 8
@g_timer = external dso_local global %"class.Framework::Timer", align 4
@_ZTISt9exception = external constant ptr
@g_bDrawCameraPos = external dso_local local_unnamed_addr global i8, align 1
@g_bDrawLightPos = external dso_local local_unnamed_addr global i8, align 1
@g_bLongLightRange = external dso_local local_unnamed_addr global i8, align 1
@g_bDrawBumpmap = external dso_local local_unnamed_addr global i8, align 1
@.str.19 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z17LoadAndSetupScenev() local_unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #2

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare void @__cxa_end_catch() local_unnamed_addr

; Function Attrs: mustprogress uwtable
define dso_local void @_Z8keyboardhii(i8 noundef zeroext %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  switch i8 %0, label %37 [
    i8 27, label %4
    i8 32, label %9
    i8 116, label %12
    i8 103, label %15
    i8 105, label %18
    i8 112, label %21
    i8 13, label %23
  ]

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

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

8:                                                ; preds = %7, %4
  store ptr null, ptr @g_pScene, align 8, !tbaa !5
  tail call void @glutLeaveMainLoop()
  br label %41

9:                                                ; preds = %3
  %10 = load i8, ptr @g_bDrawBumpmap, align 1, !tbaa !9, !range !11, !noundef !12
  %11 = xor i8 %10, 1
  store i8 %11, ptr @g_bDrawBumpmap, align 1, !tbaa !9
  br label %37

12:                                               ; preds = %3
  %13 = load i8, ptr @g_bDrawCameraPos, align 1, !tbaa !9, !range !11, !noundef !12
  %14 = xor i8 %13, 1
  store i8 %14, ptr @g_bDrawCameraPos, align 1, !tbaa !9
  br label %37

15:                                               ; preds = %3
  %16 = load i8, ptr @g_bDrawLightPos, align 1, !tbaa !9, !range !11, !noundef !12
  %17 = xor i8 %16, 1
  store i8 %17, ptr @g_bDrawLightPos, align 1, !tbaa !9
  br label %37

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

21:                                               ; preds = %3
  %22 = tail call noundef zeroext i1 @_ZN9Framework5Timer11TogglePauseEv(ptr noundef nonnull align 4 dereferenceable(20) @g_timer)
  br label %37

23:                                               ; preds = %3
  invoke void @_Z17LoadAndSetupScenev()
          to label %37 unwind label %24

24:                                               ; preds = %23
  %25 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
  %26 = extractvalue { ptr, i32 } %25, 1
  %27 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt9exception) #6
  %28 = icmp eq i32 %26, %27
  br i1 %28, label %29, label %42

29:                                               ; preds = %24
  %30 = extractvalue { ptr, i32 } %25, 0
  %31 = tail call ptr @__cxa_begin_catch(ptr %30) #6
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %34 = load ptr, ptr %33, align 8
  %35 = tail call noundef ptr %34(ptr noundef nonnull align 8 dereferenceable(8) %31) #6
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, ptr noundef %35)
  tail call void @__cxa_end_catch()
  br label %41

37:                                               ; preds = %23, %21, %18, %15, %12, %9, %3
  %38 = load ptr, ptr @g_pViewPole, align 8, !tbaa !5
  %.not = icmp eq ptr %38, null
  br i1 %.not, label %41, label %39

39:                                               ; preds = %37
  tail call void @_ZN6glutil8ViewPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(148) %38, i8 noundef signext %0)
  %40 = load ptr, ptr @g_pObjPole, align 8, !tbaa !5
  tail call void @_ZN6glutil10ObjectPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(112) %40, i8 noundef signext %0)
  br label %41

41:                                               ; preds = %39, %37, %29, %8
  ret void

42:                                               ; preds = %24
  resume { ptr, i32 } %25
}

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

declare void @glutLeaveMainLoop() local_unnamed_addr #5

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

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

declare void @_ZN6glutil10ObjectPole9CharPressEc(ptr noundef nonnull align 8 dereferenceable(112), i8 noundef signext) local_unnamed_addr #5

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 = { 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 #2 = { nofree nosync nounwind memory(none) }
attributes #3 = { nofree 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 #4 = { 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 #5 = { "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 #6 = { nounwind }
attributes #7 = { 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 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}


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