; 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] }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [117 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local i32 @aiGetMaterialProperty(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp ne ptr %15, null
  br i1 %16, label %18, label %17

17:                                               ; preds = %5
  call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 65)
  br label %18

18:                                               ; preds = %17, %5
  %19 = phi i1 [ true, %5 ], [ false, %17 ]
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 66)
  br label %23

23:                                               ; preds = %22, %18
  %24 = phi i1 [ true, %18 ], [ false, %22 ]
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 67)
  br label %28

28:                                               ; preds = %27, %23
  %29 = phi i1 [ true, %23 ], [ false, %27 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %86, %28
  %31 = load i32, ptr %12, align 4, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.aiMaterial, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !11
  %35 = icmp ult i32 %31, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %30
  store i32 2, ptr %13, align 4
  br label %89

37:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.aiMaterial, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !13
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds ptr, ptr %40, i64 %42
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  store ptr %44, ptr %14, align 8, !tbaa !5
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = icmp ne ptr %45, null
  br i1 %46, label %47, label %82

47:                                               ; preds = %37
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.aiMaterialProperty, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.aiString, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds [1024 x i8], ptr %50, i64 0, i64 0
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = call i32 @strcmp(ptr noundef %51, ptr noundef %52) #5
  %54 = icmp eq i32 0, %53
  br i1 %54, label %55, label %82

55:                                               ; preds = %47
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = icmp eq i32 -1, %56
  br i1 %57, label %64, label %58

58:                                               ; preds = %55
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.aiMaterialProperty, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %60, align 4, !tbaa !14
  %62 = load i32, ptr %9, align 4, !tbaa !9
  %63 = icmp eq i32 %61, %62
  br i1 %63, label %64, label %82

64:                                               ; preds = %58, %55
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = icmp eq i32 -1, %65
  br i1 %66, label %73, label %67

67:                                               ; preds = %64
  %68 = load ptr, ptr %14, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.aiMaterialProperty, ptr %68, i32 0, i32 2
  %70 = load i32, ptr %69, align 8, !tbaa !18
  %71 = load i32, ptr %10, align 4, !tbaa !9
  %72 = icmp eq i32 %70, %71
  br i1 %72, label %73, label %82

73:                                               ; preds = %67, %64
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.aiMaterial, ptr %74, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !13
  %77 = load i32, ptr %12, align 4, !tbaa !9
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds ptr, ptr %76, i64 %78
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %80, ptr %81, align 8, !tbaa !5
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %83

82:                                               ; preds = %67, %58, %47, %37
  store i32 0, ptr %13, align 4
  br label %83

83:                                               ; preds = %82, %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  %84 = load i32, ptr %13, align 4
  switch i32 %84, label %89 [
    i32 0, label %85
  ]

85:                                               ; preds = %83
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %12, align 4, !tbaa !9
  %88 = add i32 %87, 1
  store i32 %88, ptr %12, align 4, !tbaa !9
  br label %30, !llvm.loop !19

89:                                               ; preds = %83, %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %90 = load i32, ptr %13, align 4
  switch i32 %90, label %95 [
    i32 2, label %91
    i32 1, label %93
  ]

91:                                               ; preds = %89
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr null, ptr %92, align 8, !tbaa !5
  store i32 -1, ptr %6, align 4
  br label %93

93:                                               ; preds = %91, %89
  %94 = load i32, ptr %6, align 4
  ret i32 %94

95:                                               ; preds = %89
  unreachable
}

declare void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef, ptr noundef, i32 noundef) #1

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

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

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

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 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind willreturn memory(read) "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 = { nounwind }
attributes #5 = { nounwind willreturn memory(read) }

!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, !10, i64 8}
!12 = !{!"_ZTS10aiMaterial", !6, i64 0, !10, i64 8, !10, i64 12}
!13 = !{!12, !6, i64 0}
!14 = !{!15, !10, i64 1028}
!15 = !{!"_ZTS18aiMaterialProperty", !16, i64 0, !10, i64 1028, !10, i64 1032, !10, i64 1036, !17, i64 1040, !6, i64 1048}
!16 = !{!"_ZTS8aiString", !10, i64 0, !7, i64 4}
!17 = !{!"_ZTS18aiPropertyTypeInfo", !7, i64 0}
!18 = !{!15, !10, i64 1032}
!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"

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [117 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @aiGetMaterialProperty(ptr noundef readonly %0, ptr noundef readonly %1, i32 noundef %2, i32 noundef %3, ptr noundef writeonly %4) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %6, label %7

6:                                                ; preds = %5
  tail call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 65)
  br label %7

7:                                                ; preds = %6, %5
  %.not29 = icmp eq ptr %1, null
  br i1 %.not29, label %8, label %9

8:                                                ; preds = %7
  tail call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 66)
  br label %9

9:                                                ; preds = %8, %7
  %.not30 = icmp eq ptr %4, null
  br i1 %.not30, label %10, label %11

10:                                               ; preds = %9
  tail call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 67)
  br label %11

11:                                               ; preds = %10, %9
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load i32, ptr %12, align 8, !tbaa !5
  %.not65 = icmp eq i32 %13, 0
  br i1 %.not65, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11
  %14 = load ptr, ptr %0, align 8, !tbaa !11
  %15 = icmp eq i32 %2, -1
  %16 = icmp eq i32 %3, -1
  %wide.trip.count89 = zext i32 %13 to i64
  br i1 %15, label %.lr.ph.split.us, label %.lr.ph.split

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

.lr.ph.split.us.split.us:                         ; preds = %.lr.ph.split.us, %23
  %indvars.iv86 = phi i64 [ %indvars.iv.next87, %23 ], [ 0, %.lr.ph.split.us ]
  %17 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv86
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %.not31.us.us = icmp eq ptr %18, null
  br i1 %.not31.us.us, label %23, label %19

19:                                               ; preds = %.lr.ph.split.us.split.us
  %20 = getelementptr inbounds i8, ptr %18, i64 4
  %21 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %20, ptr noundef nonnull dereferenceable(1) %1) #3
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %._crit_edge, label %23

23:                                               ; preds = %19, %.lr.ph.split.us.split.us
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %exitcond90.not = icmp eq i64 %indvars.iv.next87, %wide.trip.count89
  br i1 %exitcond90.not, label %._crit_edge, label %.lr.ph.split.us.split.us, !llvm.loop !13

.lr.ph.split.us.split:                            ; preds = %.lr.ph.split.us, %34
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %34 ], [ 0, %.lr.ph.split.us ]
  %24 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv81
  %25 = load ptr, ptr %24, align 8, !tbaa !12
  %.not31.us = icmp eq ptr %25, null
  br i1 %.not31.us, label %34, label %26

26:                                               ; preds = %.lr.ph.split.us.split
  %27 = getelementptr inbounds i8, ptr %25, i64 4
  %28 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %27, ptr noundef nonnull dereferenceable(1) %1) #3
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %34

30:                                               ; preds = %26
  %31 = getelementptr inbounds i8, ptr %25, i64 1032
  %32 = load i32, ptr %31, align 8, !tbaa !15
  %33 = icmp eq i32 %32, %3
  br i1 %33, label %._crit_edge, label %34

34:                                               ; preds = %30, %26, %.lr.ph.split.us.split
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %exitcond85.not = icmp eq i64 %indvars.iv.next82, %wide.trip.count89
  br i1 %exitcond85.not, label %._crit_edge, label %.lr.ph.split.us.split, !llvm.loop !13

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

.lr.ph.split.split.us:                            ; preds = %.lr.ph.split, %45
  %indvars.iv76 = phi i64 [ %indvars.iv.next77, %45 ], [ 0, %.lr.ph.split ]
  %35 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv76
  %36 = load ptr, ptr %35, align 8, !tbaa !12
  %.not31.us49 = icmp eq ptr %36, null
  br i1 %.not31.us49, label %45, label %37

37:                                               ; preds = %.lr.ph.split.split.us
  %38 = getelementptr inbounds i8, ptr %36, i64 4
  %39 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %38, ptr noundef nonnull dereferenceable(1) %1) #3
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %45

41:                                               ; preds = %37
  %42 = getelementptr inbounds i8, ptr %36, i64 1028
  %43 = load i32, ptr %42, align 4, !tbaa !19
  %44 = icmp eq i32 %43, %2
  br i1 %44, label %._crit_edge, label %45

45:                                               ; preds = %41, %37, %.lr.ph.split.split.us
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %exitcond80.not = icmp eq i64 %indvars.iv.next77, %wide.trip.count89
  br i1 %exitcond80.not, label %._crit_edge, label %.lr.ph.split.split.us, !llvm.loop !13

.lr.ph.split.split:                               ; preds = %.lr.ph.split, %60
  %indvars.iv = phi i64 [ %indvars.iv.next, %60 ], [ 0, %.lr.ph.split ]
  %46 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv
  %47 = load ptr, ptr %46, align 8, !tbaa !12
  %.not31 = icmp eq ptr %47, null
  br i1 %.not31, label %60, label %48

48:                                               ; preds = %.lr.ph.split.split
  %49 = getelementptr inbounds i8, ptr %47, i64 4
  %50 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %49, ptr noundef nonnull dereferenceable(1) %1) #3
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %60

52:                                               ; preds = %48
  %53 = getelementptr inbounds i8, ptr %47, i64 1028
  %54 = load i32, ptr %53, align 4, !tbaa !19
  %55 = icmp eq i32 %54, %2
  br i1 %55, label %56, label %60

56:                                               ; preds = %52
  %57 = getelementptr inbounds i8, ptr %47, i64 1032
  %58 = load i32, ptr %57, align 8, !tbaa !15
  %59 = icmp eq i32 %58, %3
  br i1 %59, label %._crit_edge, label %60

60:                                               ; preds = %56, %52, %48, %.lr.ph.split.split
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count89
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.split.split, !llvm.loop !13

._crit_edge:                                      ; preds = %56, %60, %41, %45, %30, %34, %19, %23, %11
  %storemerge = phi ptr [ null, %11 ], [ null, %23 ], [ %18, %19 ], [ null, %34 ], [ %25, %30 ], [ null, %45 ], [ %36, %41 ], [ null, %60 ], [ %47, %56 ]
  %.3 = phi i32 [ -1, %11 ], [ -1, %23 ], [ 0, %19 ], [ -1, %34 ], [ 0, %30 ], [ -1, %45 ], [ 0, %41 ], [ -1, %60 ], [ 0, %56 ]
  store ptr %storemerge, ptr %4, align 8, !tbaa !12
  ret i32 %.3
}

declare void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

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 = { "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 nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 1032}
!16 = !{!"_ZTS18aiMaterialProperty", !17, i64 0, !10, i64 1028, !10, i64 1032, !10, i64 1036, !18, i64 1040, !7, i64 1048}
!17 = !{!"_ZTS8aiString", !10, i64 0, !8, i64 4}
!18 = !{!"_ZTS18aiPropertyTypeInfo", !8, i64 0}
!19 = !{!16, !10, i64 1028}


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