; LLVM IR from erwincoumans/tiny-differentiable-simulator :: src/visualizer/opengl/tiny_opengl3_app.ll (ZN14TinyOpenGL3AppD2Ev)

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

%struct.TinyOpenGL3App = type { %struct.TinyCommonGraphicsApp.base, ptr, ptr, ptr }
%struct.TinyCommonGraphicsApp.base = type <{ ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, float, float, float, float, i8, [3 x i8], [3 x float] }>
%struct.TinyOpenGL3AppInternalData = type { i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i32, i32, i32 }
%struct.TinyCommonGraphicsApp = type <{ ptr, ptr, ptr, ptr, ptr, i8, i8, i8, i8, float, float, float, float, i8, [3 x i8], [3 x float], [4 x i8] }>

@_ZTV14TinyOpenGL3App = external dso_local unnamed_addr constant { [29 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN14TinyOpenGL3AppD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 216) ({ [29 x ptr] }, ptr @_ZTV14TinyOpenGL3App, i32 0, i32 0, i32 2), ptr %3, align 8, !tbaa !9
  %4 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %3, i32 0, i32 3
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = icmp eq ptr %5, null
  br i1 %6, label %11, label %7

7:                                                ; preds = %1
  %8 = load ptr, ptr %5, align 8, !tbaa !9
  %9 = getelementptr inbounds ptr, ptr %8, i64 1
  %10 = load ptr, ptr %9, align 8
  call void %10(ptr noundef nonnull align 8 dereferenceable(60) %5) #4
  br label %11

11:                                               ; preds = %7, %1
  %12 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %3, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  %14 = icmp eq ptr %13, null
  br i1 %14, label %19, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr %13, align 8, !tbaa !9
  %17 = getelementptr inbounds ptr, ptr %16, i64 1
  %18 = load ptr, ptr %17, align 8
  call void %18(ptr noundef nonnull align 8 dereferenceable(32) %13) #4
  br label %19

19:                                               ; preds = %15, %11
  %20 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %3, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = getelementptr inbounds %struct.TinyOpenGL3AppInternalData, ptr %21, i32 0, i32 2
  %23 = load ptr, ptr %22, align 8, !tbaa !18
  invoke void @_Z10sth_deleteP9sth_stash(ptr noundef %23)
          to label %24 unwind label %70

24:                                               ; preds = %19
  %25 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %3, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = getelementptr inbounds %struct.TinyOpenGL3AppInternalData, ptr %26, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %29 = icmp eq ptr %28, null
  br i1 %29, label %34, label %30

30:                                               ; preds = %24
  %31 = load ptr, ptr %28, align 8, !tbaa !9
  %32 = getelementptr inbounds ptr, ptr %31, i64 1
  %33 = load ptr, ptr %32, align 8
  call void %33(ptr noundef nonnull align 8 dereferenceable(8) %28) #4
  br label %34

34:                                               ; preds = %30, %24
  %35 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %3, i32 0, i32 1
  %36 = load ptr, ptr %35, align 8, !tbaa !17
  %37 = getelementptr inbounds %struct.TinyOpenGL3AppInternalData, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !22
  invoke void @_Z10sth_deleteP9sth_stash(ptr noundef %38)
          to label %39 unwind label %70

39:                                               ; preds = %34
  %40 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %3, i32 0, i32 1
  %41 = load ptr, ptr %40, align 8, !tbaa !17
  %42 = getelementptr inbounds %struct.TinyOpenGL3AppInternalData, ptr %41, i32 0, i32 5
  %43 = load ptr, ptr %42, align 8, !tbaa !23
  %44 = icmp eq ptr %43, null
  br i1 %44, label %49, label %45

45:                                               ; preds = %39
  %46 = load ptr, ptr %43, align 8, !tbaa !9
  %47 = getelementptr inbounds ptr, ptr %46, i64 1
  %48 = load ptr, ptr %47, align 8
  call void %48(ptr noundef nonnull align 8 dereferenceable(8) %43) #4
  br label %49

49:                                               ; preds = %45, %39
  invoke void @_Z20TwDeleteDefaultFontsv()
          to label %50 unwind label %70

50:                                               ; preds = %49
  %51 = getelementptr inbounds %struct.TinyCommonGraphicsApp, ptr %3, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !24
  %53 = load ptr, ptr %52, align 8, !tbaa !9
  %54 = getelementptr inbounds ptr, ptr %53, i64 4
  %55 = load ptr, ptr %54, align 8
  invoke void %55(ptr noundef nonnull align 8 dereferenceable(8) %52)
          to label %56 unwind label %70

56:                                               ; preds = %50
  %57 = getelementptr inbounds %struct.TinyCommonGraphicsApp, ptr %3, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !24
  %59 = icmp eq ptr %58, null
  br i1 %59, label %64, label %60

60:                                               ; preds = %56
  %61 = load ptr, ptr %58, align 8, !tbaa !9
  %62 = getelementptr inbounds ptr, ptr %61, i64 1
  %63 = load ptr, ptr %62, align 8
  call void %63(ptr noundef nonnull align 8 dereferenceable(8) %58) #4
  br label %64

64:                                               ; preds = %60, %56
  %65 = getelementptr inbounds %struct.TinyOpenGL3App, ptr %3, i32 0, i32 1
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = icmp eq ptr %66, null
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  call void @_ZdlPvm(ptr noundef %66, i64 noundef 104) #5
  br label %69

69:                                               ; preds = %68, %64
  call void @_ZN21TinyCommonGraphicsAppD2Ev(ptr noundef nonnull align 8 dereferenceable(76) %3) #4
  ret void

70:                                               ; preds = %50, %49, %34, %19
  %71 = landingpad { ptr, i32 }
          catch ptr null
  %72 = extractvalue { ptr, i32 } %71, 0
  call void @__clang_call_terminate(ptr %72) #6
  unreachable
}

declare void @_Z10sth_deleteP9sth_stash(ptr noundef) #2

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

declare void @_Z20TwDeleteDefaultFontsv() #2

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

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 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 #2 = { "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 = { 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 #4 = { nounwind }
attributes #5 = { builtin nounwind }
attributes #6 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 96}
!12 = !{!"_ZTS14TinyOpenGL3App", !13, i64 0, !6, i64 80, !6, i64 88, !6, i64 96}
!13 = !{!"_ZTS21TinyCommonGraphicsApp", !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !14, i64 41, !14, i64 42, !15, i64 44, !15, i64 48, !15, i64 52, !15, i64 56, !14, i64 60, !7, i64 64}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!12, !6, i64 88}
!17 = !{!12, !6, i64 80}
!18 = !{!19, !6, i64 8}
!19 = !{!"_ZTS26TinyOpenGL3AppInternalData", !20, i64 0, !20, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !20, i64 40, !20, i64 44, !20, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !20, i64 88, !20, i64 92, !20, i64 96, !20, i64 100}
!20 = !{!"int", !7, i64 0}
!21 = !{!19, !6, i64 24}
!22 = !{!19, !6, i64 16}
!23 = !{!19, !6, i64 32}
!24 = !{!13, !6, i64 8}


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

@_ZTV14TinyOpenGL3App = external dso_local unnamed_addr constant { [29 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN14TinyOpenGL3AppD2Ev(ptr noundef nonnull align 8 dereferenceable(104) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 216) (i8, ptr @_ZTV14TinyOpenGL3App, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 96
  %3 = load ptr, ptr %2, align 8, !tbaa !8
  %4 = icmp eq ptr %3, null
  br i1 %4, label %9, label %5

5:                                                ; preds = %1
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  %8 = load ptr, ptr %7, align 8
  tail call void %8(ptr noundef nonnull align 8 dereferenceable(60) %3) #4
  br label %9

9:                                                ; preds = %5, %1
  %10 = getelementptr inbounds i8, ptr %0, i64 88
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = icmp eq ptr %11, null
  br i1 %12, label %17, label %13

13:                                               ; preds = %9
  %14 = load ptr, ptr %11, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8
  tail call void %16(ptr noundef nonnull align 8 dereferenceable(32) %11) #4
  br label %17

17:                                               ; preds = %13, %9
  %18 = getelementptr inbounds i8, ptr %0, i64 80
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  invoke void @_Z10sth_deleteP9sth_stash(ptr noundef %21)
          to label %22 unwind label %63

22:                                               ; preds = %17
  %23 = load ptr, ptr %18, align 8, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %23, i64 24
  %25 = load ptr, ptr %24, align 8, !tbaa !20
  %26 = icmp eq ptr %25, null
  br i1 %26, label %31, label %27

27:                                               ; preds = %22
  %28 = load ptr, ptr %25, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 8
  %30 = load ptr, ptr %29, align 8
  tail call void %30(ptr noundef nonnull align 8 dereferenceable(8) %25) #4
  %.pre = load ptr, ptr %18, align 8, !tbaa !16
  br label %31

31:                                               ; preds = %27, %22
  %32 = phi ptr [ %.pre, %27 ], [ %23, %22 ]
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  invoke void @_Z10sth_deleteP9sth_stash(ptr noundef %34)
          to label %35 unwind label %63

35:                                               ; preds = %31
  %36 = load ptr, ptr %18, align 8, !tbaa !16
  %37 = getelementptr inbounds i8, ptr %36, i64 32
  %38 = load ptr, ptr %37, align 8, !tbaa !22
  %39 = icmp eq ptr %38, null
  br i1 %39, label %44, label %40

40:                                               ; preds = %35
  %41 = load ptr, ptr %38, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %41, i64 8
  %43 = load ptr, ptr %42, align 8
  tail call void %43(ptr noundef nonnull align 8 dereferenceable(8) %38) #4
  br label %44

44:                                               ; preds = %40, %35
  invoke void @_Z20TwDeleteDefaultFontsv()
          to label %45 unwind label %63

45:                                               ; preds = %44
  %46 = getelementptr inbounds i8, ptr %0, i64 8
  %47 = load ptr, ptr %46, align 8, !tbaa !23
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %48, i64 32
  %50 = load ptr, ptr %49, align 8
  invoke void %50(ptr noundef nonnull align 8 dereferenceable(8) %47)
          to label %51 unwind label %63

51:                                               ; preds = %45
  %52 = load ptr, ptr %46, align 8, !tbaa !23
  %53 = icmp eq ptr %52, null
  br i1 %53, label %58, label %54

54:                                               ; preds = %51
  %55 = load ptr, ptr %52, align 8, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %55, i64 8
  %57 = load ptr, ptr %56, align 8
  tail call void %57(ptr noundef nonnull align 8 dereferenceable(8) %52) #4
  br label %58

58:                                               ; preds = %54, %51
  %59 = load ptr, ptr %18, align 8, !tbaa !16
  %60 = icmp eq ptr %59, null
  br i1 %60, label %62, label %61

61:                                               ; preds = %58
  tail call void @_ZdlPvm(ptr noundef nonnull %59, i64 noundef 104) #5
  br label %62

62:                                               ; preds = %61, %58
  tail call void @_ZN21TinyCommonGraphicsAppD2Ev(ptr noundef nonnull align 8 dereferenceable(76) %0) #4
  ret void

63:                                               ; preds = %45, %44, %31, %17
  %64 = landingpad { ptr, i32 }
          catch ptr null
  %65 = extractvalue { ptr, i32 } %64, 0
  tail call void @__clang_call_terminate(ptr %65) #6
  unreachable
}

declare void @_Z10sth_deleteP9sth_stash(ptr noundef) local_unnamed_addr #2

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

declare void @_Z20TwDeleteDefaultFontsv() local_unnamed_addr #2

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

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 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 #2 = { "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 = { 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 #4 = { nounwind }
attributes #5 = { builtin nounwind }
attributes #6 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 96}
!9 = !{!"_ZTS14TinyOpenGL3App", !10, i64 0, !11, i64 80, !11, i64 88, !11, i64 96}
!10 = !{!"_ZTS21TinyCommonGraphicsApp", !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !13, i64 40, !13, i64 41, !13, i64 42, !14, i64 44, !14, i64 48, !14, i64 52, !14, i64 56, !13, i64 60, !12, i64 64}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"bool", !12, i64 0}
!14 = !{!"float", !12, i64 0}
!15 = !{!9, !11, i64 88}
!16 = !{!9, !11, i64 80}
!17 = !{!18, !11, i64 8}
!18 = !{!"_ZTS26TinyOpenGL3AppInternalData", !19, i64 0, !19, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !19, i64 40, !19, i64 44, !19, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !19, i64 88, !19, i64 92, !19, i64 96, !19, i64 100}
!19 = !{!"int", !12, i64 0}
!20 = !{!18, !11, i64 24}
!21 = !{!18, !11, i64 16}
!22 = !{!18, !11, i64 32}
!23 = !{!10, !11, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,TailCallElimPass