; LLVM IR from kajott/GIPS :: src/gips_core.ll (ZN4GIPS8Pipeline4freeEv)

; 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.GIPS::Pipeline" = type <{ %"class.std::vector.3", i32, i32, i32, [2 x i32], %"class.GLutil::FBO", i8, [3 x i8], %"class.GLutil::Shader", i32, i8, i8, [2 x i8], float, [4 x i8] }>
%"class.std::vector.3" = type { %"struct.std::_Vector_base.4" }
%"struct.std::_Vector_base.4" = type { %"struct.std::_Vector_base<GIPS::Node *, std::allocator<GIPS::Node *>>::_Vector_impl" }
%"struct.std::_Vector_base<GIPS::Node *, std::allocator<GIPS::Node *>>::_Vector_impl" = type { %"struct.std::_Vector_base<GIPS::Node *, std::allocator<GIPS::Node *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<GIPS::Node *, std::allocator<GIPS::Node *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.GLutil::FBO" = type { i32, i32 }
%"class.GLutil::Shader" = type <{ i32, i32, i32, [4 x i8], ptr, i8, [7 x i8] }>

@_ZN6GLutil11initializedE = external global i8, align 1
@glad_glDeleteTextures = external global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4GIPS8Pipeline5clearEv(ptr noundef nonnull align 8 dereferenceable(100)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4GIPS8Pipeline4freeEv(ptr noundef nonnull align 8 dereferenceable(100) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  call void @_ZN4GIPS8Pipeline5clearEv(ptr noundef nonnull align 8 dereferenceable(100) %3)
  %4 = getelementptr inbounds %"class.GIPS::Pipeline", ptr %3, i32 0, i32 5
  call void @_ZN6GLutil3FBO4freeEv(ptr noundef nonnull align 4 dereferenceable(8) %4)
  %5 = getelementptr inbounds %"class.GIPS::Pipeline", ptr %3, i32 0, i32 8
  call void @_ZN6GLutil6Shader4freeEv(ptr noundef nonnull align 8 dereferenceable(25) %5)
  %6 = getelementptr inbounds %"class.GIPS::Pipeline", ptr %3, i32 0, i32 4
  %7 = getelementptr inbounds [2 x i32], ptr %6, i64 0, i64 0
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %15, label %10

10:                                               ; preds = %1
  %11 = getelementptr inbounds %"class.GIPS::Pipeline", ptr %3, i32 0, i32 4
  %12 = getelementptr inbounds [2 x i32], ptr %11, i64 0, i64 1
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %26

15:                                               ; preds = %10, %1
  %16 = load i8, ptr @_ZN6GLutil11initializedE, align 1, !tbaa !11, !range !13, !noundef !14
  %17 = trunc i8 %16 to i1
  br i1 %17, label %18, label %26

18:                                               ; preds = %15
  %19 = load ptr, ptr @glad_glDeleteTextures, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.GIPS::Pipeline", ptr %3, i32 0, i32 4
  %21 = getelementptr inbounds [2 x i32], ptr %20, i64 0, i64 0
  call void %19(i32 noundef 2, ptr noundef %21)
  %22 = getelementptr inbounds %"class.GIPS::Pipeline", ptr %3, i32 0, i32 4
  %23 = getelementptr inbounds [2 x i32], ptr %22, i64 0, i64 1
  store i32 0, ptr %23, align 4, !tbaa !9
  %24 = getelementptr inbounds %"class.GIPS::Pipeline", ptr %3, i32 0, i32 4
  %25 = getelementptr inbounds [2 x i32], ptr %24, i64 0, i64 0
  store i32 0, ptr %25, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %18, %15, %10
  ret void
}

declare void @_ZN6GLutil3FBO4freeEv(ptr noundef nonnull align 4 dereferenceable(8)) #2

declare void @_ZN6GLutil6Shader4freeEv(ptr noundef nonnull align 8 dereferenceable(25)) #2

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" }
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 = { "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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


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

@_ZN6GLutil11initializedE = external local_unnamed_addr global i8, align 1
@glad_glDeleteTextures = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4GIPS8Pipeline5clearEv(ptr noundef nonnull align 8 dereferenceable(100)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4GIPS8Pipeline4freeEv(ptr noundef nonnull align 8 dereferenceable(100) %0) local_unnamed_addr #1 align 2 {
  tail call void @_ZN4GIPS8Pipeline5clearEv(ptr noundef nonnull align 8 dereferenceable(100) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 44
  tail call void @_ZN6GLutil3FBO4freeEv(ptr noundef nonnull align 4 dereferenceable(8) %2)
  %3 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @_ZN6GLutil6Shader4freeEv(ptr noundef nonnull align 8 dereferenceable(25) %3)
  %4 = getelementptr inbounds i8, ptr %0, i64 36
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %5, 0
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load i32, ptr %6, align 8
  %.not1 = icmp eq i32 %7, 0
  %or.cond = select i1 %.not, i1 %.not1, i1 false
  br i1 %or.cond, label %13, label %8

8:                                                ; preds = %1
  %9 = load i8, ptr @_ZN6GLutil11initializedE, align 1, !tbaa !9, !range !11, !noundef !12
  %10 = trunc nuw i8 %9 to i1
  br i1 %10, label %11, label %13

11:                                               ; preds = %8
  %12 = load ptr, ptr @glad_glDeleteTextures, align 8, !tbaa !13
  tail call void %12(i32 noundef 2, ptr noundef nonnull %4)
  store i32 0, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %1, %11, %8
  ret void
}

declare void @_ZN6GLutil3FBO4freeEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

declare void @_ZN6GLutil6Shader4freeEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #2

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" }
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 = { "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 = !{!"int", !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 = !{!"any pointer", !7, i64 0}


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