; LLVM IR from zeux/meshoptimizer :: gltf (material)

; 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_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 }
%struct.cgltf_memory_options = type { ptr, ptr, ptr }
%struct.cgltf_file_options = type { ptr, ptr, ptr }
%struct.cgltf_material = type { ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.cgltf_pbr_metallic_roughness, %struct.cgltf_pbr_specular_glossiness, %struct.cgltf_clearcoat, %struct.cgltf_ior, %struct.cgltf_specular, %struct.cgltf_sheen, %struct.cgltf_transmission, %struct.cgltf_volume, %struct.cgltf_emissive_strength, %struct.cgltf_iridescence, %struct.cgltf_diffuse_transmission, %struct.cgltf_anisotropy, %struct.cgltf_dispersion, %struct.cgltf_texture_view, %struct.cgltf_texture_view, %struct.cgltf_texture_view, [3 x float], i32, float, i32, i32, %struct.cgltf_extras, i64, ptr }
%struct.cgltf_pbr_metallic_roughness = type { %struct.cgltf_texture_view, %struct.cgltf_texture_view, [4 x float], float, float }
%struct.cgltf_pbr_specular_glossiness = type { %struct.cgltf_texture_view, %struct.cgltf_texture_view, [4 x float], [3 x float], float }
%struct.cgltf_clearcoat = type { %struct.cgltf_texture_view, %struct.cgltf_texture_view, %struct.cgltf_texture_view, float, float }
%struct.cgltf_ior = type { float }
%struct.cgltf_specular = type { %struct.cgltf_texture_view, %struct.cgltf_texture_view, [3 x float], float }
%struct.cgltf_sheen = type { %struct.cgltf_texture_view, [3 x float], %struct.cgltf_texture_view, float }
%struct.cgltf_transmission = type { %struct.cgltf_texture_view, float }
%struct.cgltf_volume = type { %struct.cgltf_texture_view, float, [3 x float], float }
%struct.cgltf_emissive_strength = type { float }
%struct.cgltf_iridescence = type { float, %struct.cgltf_texture_view, float, float, float, %struct.cgltf_texture_view }
%struct.cgltf_diffuse_transmission = type { %struct.cgltf_texture_view, float, [3 x float], %struct.cgltf_texture_view }
%struct.cgltf_anisotropy = type { float, float, %struct.cgltf_texture_view }
%struct.cgltf_dispersion = type { float }
%struct.cgltf_texture_view = type { ptr, i32, float, i32, %struct.cgltf_texture_transform }
%struct.cgltf_texture_transform = type { [2 x float], float, [2 x float], i32, i32 }

; 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 nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI12MaterialInfoSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16analyzeMaterialsP10cgltf_dataRSt6vectorI12MaterialInfoSaIS2_EERS1_I11TextureInfoSaIS6_EERS1_I9ImageInfoSaISA_EE(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  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) #3
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %29, %4
  %11 = load i64, ptr %9, align 8, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.cgltf_data, ptr %12, i32 0, i32 6
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = icmp ult i64 %11, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %32

17:                                               ; preds = %10
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.cgltf_data, ptr %18, i32 0, i32 5
  %20 = load ptr, ptr %19, align 8, !tbaa !18
  %21 = load i64, ptr %9, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.cgltf_material, ptr %20, i64 %21
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI12MaterialInfoSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %23, i64 noundef %24) #3
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZL15analyzeMaterialRK14cgltf_materialR12MaterialInfoP10cgltf_dataRSt6vectorI11TextureInfoSaIS7_EERS6_I9ImageInfoSaISB_EE(ptr noundef nonnull align 8 dereferenceable(1352) %22, ptr noundef nonnull align 4 dereferenceable(12) %25, ptr noundef %26, ptr noundef nonnull align 8 dereferenceable(24) %27, ptr noundef nonnull align 8 dereferenceable(24) %28)
  br label %29

29:                                               ; preds = %17
  %30 = load i64, ptr %9, align 8, !tbaa !9
  %31 = add i64 %30, 1
  store i64 %31, ptr %9, align 8, !tbaa !9
  br label %10, !llvm.loop !19

32:                                               ; preds = %16
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL15analyzeMaterialRK14cgltf_materialR12MaterialInfoP10cgltf_dataRSt6vectorI11TextureInfoSaIS7_EERS6_I9ImageInfoSaISB_EE(ptr noundef nonnull align 8 dereferenceable(1352), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #2

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


; 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_material = type { ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, %struct.cgltf_pbr_metallic_roughness, %struct.cgltf_pbr_specular_glossiness, %struct.cgltf_clearcoat, %struct.cgltf_ior, %struct.cgltf_specular, %struct.cgltf_sheen, %struct.cgltf_transmission, %struct.cgltf_volume, %struct.cgltf_emissive_strength, %struct.cgltf_iridescence, %struct.cgltf_diffuse_transmission, %struct.cgltf_anisotropy, %struct.cgltf_dispersion, %struct.cgltf_texture_view, %struct.cgltf_texture_view, %struct.cgltf_texture_view, [3 x float], i32, float, i32, i32, %struct.cgltf_extras, i64, ptr }
%struct.cgltf_pbr_metallic_roughness = type { %struct.cgltf_texture_view, %struct.cgltf_texture_view, [4 x float], float, float }
%struct.cgltf_pbr_specular_glossiness = type { %struct.cgltf_texture_view, %struct.cgltf_texture_view, [4 x float], [3 x float], float }
%struct.cgltf_clearcoat = type { %struct.cgltf_texture_view, %struct.cgltf_texture_view, %struct.cgltf_texture_view, float, float }
%struct.cgltf_ior = type { float }
%struct.cgltf_specular = type { %struct.cgltf_texture_view, %struct.cgltf_texture_view, [3 x float], float }
%struct.cgltf_sheen = type { %struct.cgltf_texture_view, [3 x float], %struct.cgltf_texture_view, float }
%struct.cgltf_transmission = type { %struct.cgltf_texture_view, float }
%struct.cgltf_volume = type { %struct.cgltf_texture_view, float, [3 x float], float }
%struct.cgltf_emissive_strength = type { float }
%struct.cgltf_iridescence = type { float, %struct.cgltf_texture_view, float, float, float, %struct.cgltf_texture_view }
%struct.cgltf_diffuse_transmission = type { %struct.cgltf_texture_view, float, [3 x float], %struct.cgltf_texture_view }
%struct.cgltf_anisotropy = type { float, float, %struct.cgltf_texture_view }
%struct.cgltf_dispersion = type { float }
%struct.cgltf_texture_view = type { ptr, i32, float, i32, %struct.cgltf_texture_transform }
%struct.cgltf_texture_transform = type { [2 x float], float, [2 x float], i32, i32 }
%struct.cgltf_extras = type { i64, i64, ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI12MaterialInfoSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16analyzeMaterialsP10cgltf_dataRSt6vectorI12MaterialInfoSaIS2_EERS1_I11TextureInfoSaIS6_EERS1_I9ImageInfoSaISA_EE(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %0, i64 112
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 104
  br label %8

._crit_edge:                                      ; preds = %8, %4
  ret void

8:                                                ; preds = %.lr.ph, %8
  %.09 = phi i64 [ 0, %.lr.ph ], [ %12, %8 ]
  %9 = load ptr, ptr %7, align 8, !tbaa !16
  %10 = getelementptr inbounds %struct.cgltf_material, ptr %9, i64 %.09
  %11 = tail call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorI12MaterialInfoSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.09) #2
  tail call void @_ZL15analyzeMaterialRK14cgltf_materialR12MaterialInfoP10cgltf_dataRSt6vectorI11TextureInfoSaIS7_EERS6_I9ImageInfoSaISB_EE(ptr noundef nonnull align 8 dereferenceable(1352) %10, ptr noundef nonnull align 4 dereferenceable(12) %11, ptr noundef nonnull %0, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %3)
  %12 = add nuw i64 %.09, 1
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = icmp ult i64 %12, %13
  br i1 %14, label %8, label %._crit_edge, !llvm.loop !17
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL15analyzeMaterialRK14cgltf_materialR12MaterialInfoP10cgltf_dataRSt6vectorI11TextureInfoSaIS7_EERS6_I9ImageInfoSaISB_EE(ptr noundef nonnull align 8 dereferenceable(1352), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef, ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

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 = { 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, !13, i64 112}
!6 = !{!"_ZTS10cgltf_data", !7, i64 0, !10, i64 8, !11, i64 16, !10, i64 88, !13, i64 96, !10, i64 104, !13, i64 112, !10, i64 120, !13, i64 128, !10, i64 136, !13, i64 144, !10, i64 152, !13, i64 160, !10, i64 168, !13, i64 176, !10, i64 184, !13, i64 192, !10, i64 200, !13, i64 208, !10, i64 216, !13, i64 224, !10, i64 232, !13, i64 240, !10, i64 248, !13, i64 256, !10, i64 264, !13, i64 272, !10, i64 280, !13, i64 288, !10, i64 296, !10, i64 304, !13, i64 312, !10, i64 320, !13, i64 328, !12, i64 336, !13, i64 360, !10, i64 368, !10, i64 376, !13, i64 384, !10, i64 392, !13, i64 400, !10, i64 408, !13, i64 416, !10, i64 424, !13, i64 432, !14, i64 440, !15, i64 464}
!7 = !{!"_ZTS15cgltf_file_type", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTS11cgltf_asset", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !12, i64 32, !13, i64 56, !10, i64 64}
!12 = !{!"_ZTS12cgltf_extras", !13, i64 0, !13, i64 8, !10, i64 16}
!13 = !{!"long", !8, i64 0}
!14 = !{!"_ZTS20cgltf_memory_options", !10, i64 0, !10, i64 8, !10, i64 16}
!15 = !{!"_ZTS18cgltf_file_options", !10, i64 0, !10, i64 8, !10, i64 16}
!16 = !{!6, !10, i64 104}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass