; LLVM IR from Overload-Technologies/Overload :: Dependencies/assimp/code/PostProcessing (ConvertToLHProcess)

; 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] }
%struct.aiUVTransform = type { %class.aiVector2t, %class.aiVector2t, float }
%class.aiVector2t = type { float, float }

@.str.1 = external hidden unnamed_addr constant [127 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 x i8], align 1

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

declare noundef ptr @_ZN6Assimp13DefaultLogger3getEv() #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6Assimp14FlipUVsProcess15ProcessMaterialEP10aiMaterial(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %11, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %12

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

18:                                               ; preds = %12
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %66

19:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.aiMaterial, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds ptr, ptr %22, i64 %24
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  store ptr %26, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %31, label %29

29:                                               ; preds = %19
  %30 = call noundef ptr @_ZN6Assimp13DefaultLogger3getEv()
  call void @_ZN6Assimp6Logger12verboseDebugEPKc(ptr noundef nonnull align 8 dereferenceable(12) %30, ptr noundef @.str.10)
  store i32 4, ptr %7, align 4
  br label %60

31:                                               ; preds = %19
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.aiMaterialProperty, ptr %32, i32 0, i32 0
  %34 = getelementptr inbounds %struct.aiString, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds [1024 x i8], ptr %34, i64 0, i64 0
  %36 = call i32 @strcmp(ptr noundef %35, ptr noundef @.str.11) #5
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %59, label %38

38:                                               ; preds = %31
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.aiMaterialProperty, ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 4, !tbaa !14
  %42 = zext i32 %41 to i64
  %43 = icmp uge i64 %42, 20
  br i1 %43, label %45, label %44

44:                                               ; preds = %38
  call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef @.str.12, ptr noundef @.str.1, i32 noundef 281)
  br label %45

45:                                               ; preds = %44, %38
  %46 = phi i1 [ true, %38 ], [ false, %44 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.aiMaterialProperty, ptr %47, i32 0, i32 5
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  store ptr %49, ptr %9, align 8, !tbaa !5
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.aiUVTransform, ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds %class.aiVector2t, ptr %51, i32 0, i32 1
  %53 = load float, ptr %52, align 4, !tbaa !19
  %54 = fmul float %53, -1.000000e+00
  store float %54, ptr %52, align 4, !tbaa !19
  %55 = load ptr, ptr %9, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.aiUVTransform, ptr %55, i32 0, i32 2
  %57 = load float, ptr %56, align 4, !tbaa !23
  %58 = fmul float %57, -1.000000e+00
  store float %58, ptr %56, align 4, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %59

59:                                               ; preds = %45, %31
  store i32 0, ptr %7, align 4
  br label %60

60:                                               ; preds = %59, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %61 = load i32, ptr %7, align 4
  switch i32 %61, label %67 [
    i32 0, label %62
    i32 4, label %63
  ]

62:                                               ; preds = %60
  br label %63

63:                                               ; preds = %62, %60
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = add i32 %64, 1
  store i32 %65, ptr %6, align 4, !tbaa !9
  br label %12, !llvm.loop !24

66:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void

67:                                               ; preds = %60
  unreachable
}

declare void @_ZN6Assimp6Logger12verboseDebugEPKc(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef) #0

attributes #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 = { 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 #3 = { 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 #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 1036}
!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, !6, i64 1048}
!19 = !{!20, !22, i64 4}
!20 = !{!"_ZTS13aiUVTransform", !21, i64 0, !21, i64 8, !22, i64 16}
!21 = !{!"_ZTS10aiVector2tIfE", !22, i64 0, !22, i64 4}
!22 = !{!"float", !7, i64 0}
!23 = !{!20, !22, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"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.1 = external hidden unnamed_addr constant [127 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 x i8], align 1

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

declare noundef ptr @_ZN6Assimp13DefaultLogger3getEv() local_unnamed_addr #0

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

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

._crit_edge:                                      ; preds = %27, %2
  ret void

.lr.ph:                                           ; preds = %2, %27
  %indvars.iv = phi i64 [ %indvars.iv.next, %27 ], [ 0, %2 ]
  %5 = load ptr, ptr %1, align 8, !tbaa !11
  %6 = getelementptr inbounds ptr, ptr %5, i64 %indvars.iv
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %10

8:                                                ; preds = %.lr.ph
  %9 = tail call noundef ptr @_ZN6Assimp13DefaultLogger3getEv()
  tail call void @_ZN6Assimp6Logger12verboseDebugEPKc(ptr noundef nonnull align 8 dereferenceable(12) %9, ptr noundef nonnull @.str.10)
  br label %27

10:                                               ; preds = %.lr.ph
  %11 = getelementptr inbounds i8, ptr %7, i64 4
  %12 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %11, ptr noundef nonnull dereferenceable(1) @.str.11) #3
  %.not13 = icmp eq i32 %12, 0
  br i1 %.not13, label %13, label %27

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %7, i64 1036
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = icmp ugt i32 %15, 19
  br i1 %16, label %18, label %17

17:                                               ; preds = %13
  tail call void @_ZN6Assimp17aiAssertViolationEPKcS1_i(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i32 noundef 281)
  br label %18

18:                                               ; preds = %17, %13
  %19 = getelementptr inbounds i8, ptr %7, i64 1048
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %20, i64 4
  %22 = load float, ptr %21, align 4, !tbaa !18
  %23 = fneg float %22
  store float %23, ptr %21, align 4, !tbaa !18
  %24 = getelementptr inbounds i8, ptr %20, i64 16
  %25 = load float, ptr %24, align 4, !tbaa !22
  %26 = fneg float %25
  store float %26, ptr %24, align 4, !tbaa !22
  br label %27

27:                                               ; preds = %10, %18, %8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i32, ptr %3, align 8, !tbaa !5
  %29 = zext i32 %28 to i64
  %30 = icmp ult i64 %indvars.iv.next, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !23
}

declare void @_ZN6Assimp6Logger12verboseDebugEPKc(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef) local_unnamed_addr #0

attributes #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 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 #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 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 = !{!14, !10, i64 1036}
!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 = !{!19, !21, i64 4}
!19 = !{!"_ZTS13aiUVTransform", !20, i64 0, !20, i64 8, !21, i64 16}
!20 = !{!"_ZTS10aiVector2tIfE", !21, i64 0, !21, i64 4}
!21 = !{!"float", !8, i64 0}
!22 = !{!19, !21, i64 16}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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