; LLVM IR from zeux/meshoptimizer :: gltf/parsegltf.ll (Z9parseGltfPKcRSt6vectorI4MeshSaIS2_EERS1_I9AnimationSaIS6_EEPS0_)

; 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.cgltf_options = type { i32, i64, %struct.cgltf_memory_options, %struct.cgltf_file_options }
%struct.cgltf_memory_options = type { ptr, ptr, ptr }
%struct.cgltf_file_options = type { ptr, ptr, ptr }
%struct.cgltf_data = type { i32, ptr, %struct.cgltf_asset, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, i64, ptr, ptr, i64, ptr, i64, %struct.cgltf_extras, i64, ptr, ptr, i64, ptr, i64, ptr, i64, ptr, i64, %struct.cgltf_memory_options, %struct.cgltf_file_options }
%struct.cgltf_asset = type { ptr, ptr, ptr, ptr, %struct.cgltf_extras, i64, ptr }
%struct.cgltf_extras = type { i64, i64, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z9parseGltfPKcRSt6vectorI4MeshSaIS2_EERS1_I9AnimationSaIS6_EEPS0_(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.cgltf_options, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store ptr null, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %10) #5
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call i32 @cgltf_parse_file(ptr noundef %10, ptr noundef %12, ptr noundef %9)
  store i32 %13, ptr %11, align 4, !tbaa !9
  %14 = load i32, ptr %11, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %23

16:                                               ; preds = %4
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.cgltf_data, ptr %17, i32 0, i32 43
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = icmp ne ptr %19, null
  br i1 %20, label %23, label %21

21:                                               ; preds = %16
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZL8freeFileP10cgltf_data(ptr noundef %22)
  br label %23

23:                                               ; preds = %21, %16, %4
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %30

26:                                               ; preds = %23
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call i32 @cgltf_load_buffers(ptr noundef %10, ptr noundef %27, ptr noundef %28)
  br label %32

30:                                               ; preds = %23
  %31 = load i32, ptr %11, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %30, %26
  %33 = phi i32 [ %29, %26 ], [ %31, %30 ]
  store i32 %33, ptr %11, align 4, !tbaa !9
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %39

36:                                               ; preds = %32
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = call i32 @cgltf_validate(ptr noundef %37)
  br label %41

39:                                               ; preds = %32
  %40 = load i32, ptr %11, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %39, %36
  %42 = phi i32 [ %38, %36 ], [ %40, %39 ]
  store i32 %42, ptr %11, align 4, !tbaa !9
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %48

45:                                               ; preds = %41
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = call noundef i32 @_ZL17decompressMeshoptP10cgltf_data(ptr noundef %46)
  br label %50

48:                                               ; preds = %41
  %49 = load i32, ptr %11, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %48, %45
  %51 = phi i32 [ %47, %45 ], [ %49, %48 ]
  store i32 %51, ptr %11, align 4, !tbaa !9
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load i32, ptr %11, align 4, !tbaa !9
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = call noundef ptr @_ZL9parseGltfP10cgltf_data12cgltf_resultRSt6vectorI4MeshSaIS3_EERS2_I9AnimationSaIS7_EEPPKc(ptr noundef %52, i32 noundef %53, ptr noundef nonnull align 8 dereferenceable(24) %54, ptr noundef nonnull align 8 dereferenceable(24) %55, ptr noundef %56)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  ret ptr %57
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare i32 @cgltf_parse_file(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8freeFileP10cgltf_data(ptr noundef) #4

declare i32 @cgltf_load_buffers(ptr noundef, ptr noundef, ptr noundef) #3

declare i32 @cgltf_validate(ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL17decompressMeshoptP10cgltf_data(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL9parseGltfP10cgltf_data12cgltf_resultRSt6vectorI4MeshSaIS3_EERS2_I9AnimationSaIS7_EEPPKc(ptr noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #5 = { 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 = !{!"_ZTS12cgltf_result", !7, i64 0}
!11 = !{!12, !6, i64 424}
!12 = !{!"_ZTS10cgltf_data", !13, i64 0, !6, i64 8, !14, i64 16, !6, i64 88, !16, i64 96, !6, i64 104, !16, i64 112, !6, i64 120, !16, i64 128, !6, i64 136, !16, i64 144, !6, i64 152, !16, i64 160, !6, i64 168, !16, i64 176, !6, i64 184, !16, i64 192, !6, i64 200, !16, i64 208, !6, i64 216, !16, i64 224, !6, i64 232, !16, i64 240, !6, i64 248, !16, i64 256, !6, i64 264, !16, i64 272, !6, i64 280, !16, i64 288, !6, i64 296, !6, i64 304, !16, i64 312, !6, i64 320, !16, i64 328, !15, i64 336, !16, i64 360, !6, i64 368, !6, i64 376, !16, i64 384, !6, i64 392, !16, i64 400, !6, i64 408, !16, i64 416, !6, i64 424, !16, i64 432, !17, i64 440, !18, i64 464}
!13 = !{!"_ZTS15cgltf_file_type", !7, i64 0}
!14 = !{!"_ZTS11cgltf_asset", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !15, i64 32, !16, i64 56, !6, i64 64}
!15 = !{!"_ZTS12cgltf_extras", !16, i64 0, !16, i64 8, !6, i64 16}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTS20cgltf_memory_options", !6, i64 0, !6, i64 8, !6, i64 16}
!18 = !{!"_ZTS18cgltf_file_options", !6, i64 0, !6, i64 8, !6, i64 16}


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

%struct.cgltf_options = type { i32, i64, %struct.cgltf_memory_options, %struct.cgltf_file_options }
%struct.cgltf_memory_options = type { ptr, ptr, ptr }
%struct.cgltf_file_options = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z9parseGltfPKcRSt6vectorI4MeshSaIS2_EERS1_I9AnimationSaIS6_EEPS0_(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  %6 = alloca %struct.cgltf_options, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %6) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(64) %6, i8 0, i64 64, i1 false)
  %7 = call i32 @cgltf_parse_file(ptr noundef nonnull %6, ptr noundef %0, ptr noundef nonnull %5)
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %.thread

9:                                                ; preds = %4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 424
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %13, label %.critedge

13:                                               ; preds = %9
  call void @_ZL8freeFileP10cgltf_data(ptr noundef nonnull %10)
  %.pre = load ptr, ptr %5, align 8, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %13, %9
  %14 = phi ptr [ %.pre, %13 ], [ %10, %9 ]
  %15 = call i32 @cgltf_load_buffers(ptr noundef nonnull %6, ptr noundef %14, ptr noundef %0)
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %.thread

17:                                               ; preds = %.critedge
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call i32 @cgltf_validate(ptr noundef %18)
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %.thread

21:                                               ; preds = %17
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call noundef i32 @_ZL17decompressMeshoptP10cgltf_data(ptr noundef %22)
  br label %.thread

.thread:                                          ; preds = %4, %.critedge, %17, %21
  %24 = phi i32 [ %23, %21 ], [ %19, %17 ], [ %15, %.critedge ], [ %7, %4 ]
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call noundef ptr @_ZL9parseGltfP10cgltf_data12cgltf_resultRSt6vectorI4MeshSaIS3_EERS2_I9AnimationSaIS7_EEPPKc(ptr noundef %25, i32 noundef %24, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  ret ptr %26
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare i32 @cgltf_parse_file(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL8freeFileP10cgltf_data(ptr noundef) local_unnamed_addr #4

declare i32 @cgltf_load_buffers(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @cgltf_validate(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL17decompressMeshoptP10cgltf_data(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden noundef ptr @_ZL9parseGltfP10cgltf_data12cgltf_resultRSt6vectorI4MeshSaIS3_EERS2_I9AnimationSaIS7_EEPPKc(ptr noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #5 = { 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, !6, i64 424}
!10 = !{!"_ZTS10cgltf_data", !11, i64 0, !6, i64 8, !12, i64 16, !6, i64 88, !14, i64 96, !6, i64 104, !14, i64 112, !6, i64 120, !14, i64 128, !6, i64 136, !14, i64 144, !6, i64 152, !14, i64 160, !6, i64 168, !14, i64 176, !6, i64 184, !14, i64 192, !6, i64 200, !14, i64 208, !6, i64 216, !14, i64 224, !6, i64 232, !14, i64 240, !6, i64 248, !14, i64 256, !6, i64 264, !14, i64 272, !6, i64 280, !14, i64 288, !6, i64 296, !6, i64 304, !14, i64 312, !6, i64 320, !14, i64 328, !13, i64 336, !14, i64 360, !6, i64 368, !6, i64 376, !14, i64 384, !6, i64 392, !14, i64 400, !6, i64 408, !14, i64 416, !6, i64 424, !14, i64 432, !15, i64 440, !16, i64 464}
!11 = !{!"_ZTS15cgltf_file_type", !7, i64 0}
!12 = !{!"_ZTS11cgltf_asset", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !14, i64 56, !6, i64 64}
!13 = !{!"_ZTS12cgltf_extras", !14, i64 0, !14, i64 8, !6, i64 16}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTS20cgltf_memory_options", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!"_ZTS18cgltf_file_options", !6, i64 0, !6, i64 8, !6, i64 16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass