; LLVM IR from Overload-Technologies/Overload :: Dependencies/assimp/code/Material (MaterialSystem)

; 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.aiMaterial = type { ptr, i32, i32 }
%struct.aiMaterialProperty = type { %struct.aiString, i32, i32, i32, i32, ptr }
%struct.aiString = type { i32, [1024 x i8] }

; 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 uwtable
define dso_local noundef i32 @_ZN6Assimp19ComputeMaterialHashEPK10aiMaterialb(ptr noundef %0, i1 noundef zeroext %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %8 = zext i1 %1 to i8
  store i8 %8, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 1503, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %9

9:                                                ; preds = %65, %2
  %10 = load i32, ptr %6, align 4, !tbaa !11
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.aiMaterial, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = icmp ult i32 %10, %13
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.aiMaterial, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !15
  %20 = load i32, ptr %6, align 4, !tbaa !11
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds ptr, ptr %19, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  store ptr %23, ptr %7, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = icmp ne ptr null, %24
  br i1 %25, label %26, label %64

26:                                               ; preds = %16
  %27 = load i8, ptr %4, align 1, !tbaa !9, !range !16, !noundef !17
  %28 = trunc i8 %27 to i1
  br i1 %28, label %37, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.aiMaterialProperty, ptr %30, i32 0, i32 0
  %32 = getelementptr inbounds %struct.aiString, ptr %31, i32 0, i32 1
  %33 = getelementptr inbounds [1024 x i8], ptr %32, i64 0, i64 0
  %34 = load i8, ptr %33, align 4, !tbaa !18
  %35 = sext i8 %34 to i32
  %36 = icmp ne i32 %35, 63
  br i1 %36, label %37, label %64

37:                                               ; preds = %29, %26
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.aiMaterialProperty, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct.aiString, ptr %39, i32 0, i32 1
  %41 = getelementptr inbounds [1024 x i8], ptr %40, i64 0, i64 0
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.aiMaterialProperty, ptr %42, i32 0, i32 0
  %44 = getelementptr inbounds %struct.aiString, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !19
  %46 = load i32, ptr %5, align 4, !tbaa !11
  %47 = call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef %41, i32 noundef %45, i32 noundef %46)
  store i32 %47, ptr %5, align 4, !tbaa !11
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.aiMaterialProperty, ptr %48, i32 0, i32 5
  %50 = load ptr, ptr %49, align 8, !tbaa !23
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.aiMaterialProperty, ptr %51, i32 0, i32 3
  %53 = load i32, ptr %52, align 4, !tbaa !24
  %54 = load i32, ptr %5, align 4, !tbaa !11
  %55 = call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef %50, i32 noundef %53, i32 noundef %54)
  store i32 %55, ptr %5, align 4, !tbaa !11
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.aiMaterialProperty, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %5, align 4, !tbaa !11
  %59 = call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef %57, i32 noundef 4, i32 noundef %58)
  store i32 %59, ptr %5, align 4, !tbaa !11
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.aiMaterialProperty, ptr %60, i32 0, i32 2
  %62 = load i32, ptr %5, align 4, !tbaa !11
  %63 = call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef %61, i32 noundef 4, i32 noundef %62)
  store i32 %63, ptr %5, align 4, !tbaa !11
  br label %64

64:                                               ; preds = %37, %29, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %6, align 4, !tbaa !11
  %67 = add i32 %66, 1
  store i32 %67, ptr %6, align 4, !tbaa !11
  br label %9, !llvm.loop !25

68:                                               ; preds = %15
  %69 = load i32, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 %69
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef, i32 noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 #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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_ZTS10aiMaterial", !6, i64 0, !12, i64 8, !12, i64 12}
!15 = !{!14, !6, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !12, i64 0}
!20 = !{!"_ZTS18aiMaterialProperty", !21, i64 0, !12, i64 1028, !12, i64 1032, !12, i64 1036, !22, i64 1040, !6, i64 1048}
!21 = !{!"_ZTS8aiString", !12, i64 0, !7, i64 4}
!22 = !{!"_ZTS18aiPropertyTypeInfo", !7, i64 0}
!23 = !{!20, !6, i64 1048}
!24 = !{!20, !12, i64 1036}
!25 = distinct !{!25, !26}
!26 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN6Assimp19ComputeMaterialHashEPK10aiMaterialb(ptr nocapture noundef readonly %0, i1 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not23 = icmp eq i32 %4, 0
  br i1 %.not23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  br i1 %1, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %22
  %5 = phi i32 [ %23, %22 ], [ %4, %.lr.ph ]
  %indvars.iv26 = phi i64 [ %indvars.iv.next27, %22 ], [ 0, %.lr.ph ]
  %.022.us = phi i32 [ %.1.us, %22 ], [ 1503, %.lr.ph ]
  %6 = load ptr, ptr %0, align 8, !tbaa !11
  %7 = getelementptr inbounds ptr, ptr %6, i64 %indvars.iv26
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  %.not.us = icmp eq ptr %8, null
  br i1 %.not.us, label %22, label %9

9:                                                ; preds = %.lr.ph.split.us
  %10 = getelementptr inbounds i8, ptr %8, i64 4
  %11 = load i32, ptr %8, align 8, !tbaa !13
  %12 = tail call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef nonnull %10, i32 noundef %11, i32 noundef %.022.us)
  %13 = getelementptr inbounds i8, ptr %8, i64 1048
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %8, i64 1036
  %16 = load i32, ptr %15, align 4, !tbaa !18
  %17 = tail call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef %14, i32 noundef %16, i32 noundef %12)
  %18 = getelementptr inbounds i8, ptr %8, i64 1028
  %19 = tail call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef nonnull %18, i32 noundef 4, i32 noundef %17)
  %20 = getelementptr inbounds i8, ptr %8, i64 1032
  %21 = tail call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef nonnull %20, i32 noundef 4, i32 noundef %19)
  %.pre29 = load i32, ptr %3, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %9, %.lr.ph.split.us
  %23 = phi i32 [ %.pre29, %9 ], [ %5, %.lr.ph.split.us ]
  %.1.us = phi i32 [ %21, %9 ], [ %.022.us, %.lr.ph.split.us ]
  %indvars.iv.next27 = add nuw nsw i64 %indvars.iv26, 1
  %24 = zext i32 %23 to i64
  %25 = icmp ult i64 %indvars.iv.next27, %24
  br i1 %25, label %.lr.ph.split.us, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %45, %22, %2
  %.0.lcssa = phi i32 [ 1503, %2 ], [ %.1.us, %22 ], [ %.1, %45 ]
  ret i32 %.0.lcssa

.lr.ph.split:                                     ; preds = %.lr.ph, %45
  %26 = phi i32 [ %46, %45 ], [ %4, %.lr.ph ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %45 ], [ 0, %.lr.ph ]
  %.022 = phi i32 [ %.1, %45 ], [ 1503, %.lr.ph ]
  %27 = load ptr, ptr %0, align 8, !tbaa !11
  %28 = getelementptr inbounds ptr, ptr %27, i64 %indvars.iv
  %29 = load ptr, ptr %28, align 8, !tbaa !12
  %.not = icmp eq ptr %29, null
  br i1 %.not, label %45, label %30

30:                                               ; preds = %.lr.ph.split
  %31 = getelementptr inbounds i8, ptr %29, i64 4
  %32 = load i8, ptr %31, align 4, !tbaa !21
  %.not20 = icmp eq i8 %32, 63
  br i1 %.not20, label %45, label %33

33:                                               ; preds = %30
  %34 = load i32, ptr %29, align 8, !tbaa !13
  %35 = tail call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef nonnull %31, i32 noundef %34, i32 noundef %.022)
  %36 = getelementptr inbounds i8, ptr %29, i64 1048
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = getelementptr inbounds i8, ptr %29, i64 1036
  %39 = load i32, ptr %38, align 4, !tbaa !18
  %40 = tail call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef %37, i32 noundef %39, i32 noundef %35)
  %41 = getelementptr inbounds i8, ptr %29, i64 1028
  %42 = tail call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef nonnull %41, i32 noundef 4, i32 noundef %40)
  %43 = getelementptr inbounds i8, ptr %29, i64 1032
  %44 = tail call noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef nonnull %43, i32 noundef 4, i32 noundef %42)
  %.pre = load i32, ptr %3, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %33, %30, %.lr.ph.split
  %46 = phi i32 [ %.pre, %33 ], [ %26, %30 ], [ %26, %.lr.ph.split ]
  %.1 = phi i32 [ %44, %33 ], [ %.022, %30 ], [ %.022, %.lr.ph.split ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %47 = zext i32 %46 to i64
  %48 = icmp ult i64 %indvars.iv.next, %47
  br i1 %48, label %.lr.ph.split, label %._crit_edge, !llvm.loop !19
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z13SuperFastHashPKcjj(ptr noundef, i32 noundef, i32 noundef) 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 = { inlinehint 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" }

!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 8}
!6 = !{!"_ZTS10aiMaterial", !7, i64 0, !10, i64 8, !10, i64 12}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS18aiMaterialProperty", !15, i64 0, !10, i64 1028, !10, i64 1032, !10, i64 1036, !16, i64 1040, !7, i64 1048}
!15 = !{!"_ZTS8aiString", !10, i64 0, !8, i64 4}
!16 = !{!"_ZTS18aiPropertyTypeInfo", !8, i64 0}
!17 = !{!14, !7, i64 1048}
!18 = !{!14, !10, i64 1036}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!8, !8, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass