; LLVM IR from zeux/meshoptimizer :: gltf/gltfpack.ll (Z8defaultsv)

; 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.Settings = type { i32, i32, i32, i32, i8, i8, i8, i8, i32, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, float, float, i8, i8, i8, float, i32, i8, i8, i8, i8, i8, [4 x float], [4 x i32], [4 x i32], [4 x i32], i32, i8, i8, i8, i8, 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
define dso_local void @_Z8defaultsv(ptr dead_on_unwind noalias writable sret(%struct.Settings) align 4 %0) #1 {
  %2 = alloca i32, align 4
  call void @llvm.memset.p0.i64(ptr align 4 %0, i8 0, i64 148, i1 false)
  %3 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 37
  store i8 1, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 0
  store i32 14, ptr %4, align 4, !tbaa !12
  %5 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 1
  store i32 12, ptr %5, align 4, !tbaa !13
  %6 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 2
  store i32 8, ptr %6, align 4, !tbaa !14
  %7 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 3
  store i32 8, ptr %7, align 4, !tbaa !15
  %8 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 8
  store i32 16, ptr %8, align 4, !tbaa !16
  %9 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 9
  store i32 12, ptr %9, align 4, !tbaa !17
  %10 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 10
  store i32 16, ptr %10, align 4, !tbaa !18
  %11 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 11
  store i32 30, ptr %11, align 4, !tbaa !19
  %12 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 17
  store i8 1, ptr %12, align 1, !tbaa !20
  %13 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 20
  store float 1.000000e+00, ptr %13, align 4, !tbaa !21
  %14 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 21
  store float 0x3F847AE140000000, ptr %14, align 4, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !23
  br label %15

15:                                               ; preds = %32, %1
  %16 = load i32, ptr %2, align 4, !tbaa !23
  %17 = icmp slt i32 %16, 4
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %35

19:                                               ; preds = %15
  %20 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 34
  %21 = load i32, ptr %2, align 4, !tbaa !23
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [4 x i32], ptr %20, i64 0, i64 %22
  store i32 0, ptr %23, align 4, !tbaa !24
  %24 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 32
  %25 = load i32, ptr %2, align 4, !tbaa !23
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [4 x float], ptr %24, i64 0, i64 %26
  store float 1.000000e+00, ptr %27, align 4, !tbaa !26
  %28 = getelementptr inbounds %struct.Settings, ptr %0, i32 0, i32 35
  %29 = load i32, ptr %2, align 4, !tbaa !23
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [4 x i32], ptr %28, i64 0, i64 %30
  store i32 8, ptr %31, align 4, !tbaa !23
  br label %32

32:                                               ; preds = %19
  %33 = load i32, ptr %2, align 4, !tbaa !23
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !23
  br label %15, !llvm.loop !27

35:                                               ; preds = %18
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 140}
!6 = !{!"_ZTS8Settings", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 17, !10, i64 18, !10, i64 19, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !10, i64 36, !10, i64 37, !10, i64 38, !10, i64 39, !10, i64 40, !10, i64 41, !10, i64 42, !10, i64 43, !11, i64 44, !11, i64 48, !10, i64 52, !10, i64 53, !10, i64 54, !11, i64 56, !7, i64 60, !10, i64 64, !10, i64 65, !10, i64 66, !10, i64 67, !10, i64 68, !8, i64 72, !8, i64 88, !8, i64 104, !8, i64 120, !7, i64 136, !10, i64 140, !10, i64 141, !10, i64 142, !10, i64 143, !7, i64 144}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 12}
!16 = !{!6, !7, i64 20}
!17 = !{!6, !7, i64 24}
!18 = !{!6, !7, i64 28}
!19 = !{!6, !7, i64 32}
!20 = !{!6, !10, i64 41}
!21 = !{!6, !11, i64 44}
!22 = !{!6, !11, i64 48}
!23 = !{!7, !7, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"_ZTS11TextureMode", !8, i64 0}
!26 = !{!11, !11, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"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.Settings = type { i32, i32, i32, i32, i8, i8, i8, i8, i32, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, float, float, i8, i8, i8, float, i32, i8, i8, i8, i8, i8, [4 x float], [4 x i32], [4 x i32], [4 x i32], i32, i8, i8, i8, i8, i32 }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_Z8defaultsv(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.Settings) align 4 %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(148) %2, i8 0, i64 132, i1 false)
  %3 = getelementptr inbounds i8, ptr %0, i64 140
  store i8 1, ptr %3, align 4, !tbaa !5
  store <4 x i32> <i32 14, i32 12, i32 8, i32 8>, ptr %0, align 4, !tbaa !12
  %4 = getelementptr inbounds i8, ptr %0, i64 20
  store <4 x i32> <i32 16, i32 12, i32 16, i32 30>, ptr %4, align 4, !tbaa !12
  %5 = getelementptr inbounds i8, ptr %0, i64 41
  store i8 1, ptr %5, align 1, !tbaa !13
  %6 = getelementptr inbounds i8, ptr %0, i64 44
  store <2 x float> <float 1.000000e+00, float 0x3F847AE140000000>, ptr %6, align 4, !tbaa !14
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  %8 = getelementptr inbounds i8, ptr %0, i64 120
  store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %7, align 4, !tbaa !14
  store <4 x i32> <i32 8, i32 8, i32 8, i32 8>, ptr %8, align 4, !tbaa !12
  ret void
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 nounwind willreturn memory(argmem: write) }

!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, !10, i64 140}
!6 = !{!"_ZTS8Settings", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 17, !10, i64 18, !10, i64 19, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !10, i64 36, !10, i64 37, !10, i64 38, !10, i64 39, !10, i64 40, !10, i64 41, !10, i64 42, !10, i64 43, !11, i64 44, !11, i64 48, !10, i64 52, !10, i64 53, !10, i64 54, !11, i64 56, !7, i64 60, !10, i64 64, !10, i64 65, !10, i64 66, !10, i64 67, !10, i64 68, !8, i64 72, !8, i64 88, !8, i64 104, !8, i64 120, !7, i64 136, !10, i64 140, !10, i64 141, !10, i64 142, !10, i64 143, !7, i64 144}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !10, i64 41}
!14 = !{!11, !11, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass