; LLVM IR from aap/librw :: src/tristrip.ll (ZN2rw8Geometry14buildTristripsEv)

; 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.rw::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"struct.rw::StripMesh" = type { i32, ptr, %"struct.rw::LinkList", %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Geometry" = type { %"struct.rw::Object", i32, i16, i32, i32, i32, i32, ptr, ptr, [8 x ptr], ptr, %"struct.rw::MaterialList", ptr, ptr, i32 }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::MaterialList" = type { ptr, i32, i32 }
%"struct.rw::Mesh" = type { ptr, i32, ptr }
%"struct.rw::MeshHeader" = type { i32, i16, i16, i32, i32 }

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@_ZN2rw6Engine8memfuncsE = external global %"struct.rw::MemoryFunctions", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw8Geometry14buildTristripsEv(ptr noundef nonnull align 8 dereferenceable(168) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"struct.rw::StripMesh", align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 48, ptr %8) #6
  %11 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 11
  %12 = getelementptr inbounds %"struct.rw::MaterialList", ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = call noundef ptr @_ZN2rw8Geometry14allocateMeshesEiji(ptr noundef nonnull align 8 dereferenceable(168) %10, i32 noundef %13, i32 noundef 0, i32 noundef 1)
  %15 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 3
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = sext i32 %16 to i64
  %18 = mul i64 %17, 56
  %19 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %18, i32 noundef 65551, ptr noundef @.str)
  %20 = getelementptr inbounds %"struct.rw::StripMesh", ptr %8, i32 0, i32 1
  store ptr %19, ptr %20, align 8, !tbaa !16
  %21 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 12
  %22 = load ptr, ptr %21, align 8, !tbaa !20
  %23 = call noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16) %22)
  store ptr %23, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !21
  br label %24

24:                                               ; preds = %63, %1
  %25 = load i32, ptr %9, align 4, !tbaa !21
  %26 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 11
  %27 = getelementptr inbounds %"struct.rw::MaterialList", ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 8, !tbaa !9
  %29 = icmp slt i32 %25, %28
  br i1 %29, label %31, label %30

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

31:                                               ; preds = %24
  %32 = getelementptr inbounds %"struct.rw::StripMesh", ptr %8, i32 0, i32 2
  call void @_ZN2rw8LinkList4initEv(ptr noundef nonnull align 8 dereferenceable(16) %32)
  %33 = getelementptr inbounds %"struct.rw::StripMesh", ptr %8, i32 0, i32 3
  call void @_ZN2rw8LinkList4initEv(ptr noundef nonnull align 8 dereferenceable(16) %33)
  %34 = load i32, ptr %9, align 4, !tbaa !21
  %35 = trunc i32 %34 to i16
  call void @_ZN2rwL12collectFacesEPNS_8GeometryEPNS_9StripMeshEt(ptr noundef %10, ptr noundef %8, i16 noundef zeroext %35)
  call void @_ZN2rwL20connectNodesPreserveEPNS_9StripMeshE(ptr noundef %8)
  call void @_ZN2rwL11buildStripsEPNS_9StripMeshE(ptr noundef %8)
  call void @_ZN2rwL10printSmeshEPNS_9StripMeshE(ptr noundef %8)
  %36 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 11
  %37 = getelementptr inbounds %"struct.rw::MaterialList", ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !22
  %39 = load i32, ptr %9, align 4, !tbaa !21
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds ptr, ptr %38, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load i32, ptr %9, align 4, !tbaa !21
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds %"struct.rw::Mesh", ptr %43, i64 %45
  %47 = getelementptr inbounds %"struct.rw::Mesh", ptr %46, i32 0, i32 2
  store ptr %42, ptr %47, align 8, !tbaa !23
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load i32, ptr %9, align 4, !tbaa !21
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %"struct.rw::Mesh", ptr %48, i64 %50
  call void @_ZN2rwL8makeMeshEPNS_9StripMeshEPNS_4MeshE(ptr noundef %8, ptr noundef %51)
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load i32, ptr %9, align 4, !tbaa !21
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %"struct.rw::Mesh", ptr %52, i64 %54
  %56 = getelementptr inbounds %"struct.rw::Mesh", ptr %55, i32 0, i32 1
  %57 = load i32, ptr %56, align 8, !tbaa !25
  %58 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 12
  %59 = load ptr, ptr %58, align 8, !tbaa !20
  %60 = getelementptr inbounds %"struct.rw::MeshHeader", ptr %59, i32 0, i32 3
  %61 = load i32, ptr %60, align 4, !tbaa !26
  %62 = add i32 %61, %57
  store i32 %62, ptr %60, align 4, !tbaa !26
  br label %63

63:                                               ; preds = %31
  %64 = load i32, ptr %9, align 4, !tbaa !21
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %9, align 4, !tbaa !21
  br label %24, !llvm.loop !28

66:                                               ; preds = %30
  %67 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !30
  %68 = getelementptr inbounds %"struct.rw::StripMesh", ptr %8, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  call void %67(ptr noundef %69)
  %70 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 12
  %71 = load ptr, ptr %70, align 8, !tbaa !20
  store ptr %71, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 12
  store ptr null, ptr %72, align 8, !tbaa !20
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.rw::MeshHeader", ptr %73, i32 0, i32 1
  %75 = load i16, ptr %74, align 4, !tbaa !32
  %76 = zext i16 %75 to i32
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %"struct.rw::MeshHeader", ptr %77, i32 0, i32 3
  %79 = load i32, ptr %78, align 4, !tbaa !26
  %80 = call noundef ptr @_ZN2rw8Geometry14allocateMeshesEiji(ptr noundef nonnull align 8 dereferenceable(168) %10, i32 noundef %76, i32 noundef %79, i32 noundef 0)
  %81 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 12
  %82 = load ptr, ptr %81, align 8, !tbaa !20
  %83 = getelementptr inbounds %"struct.rw::MeshHeader", ptr %82, i32 0, i32 0
  store i32 1, ptr %83, align 4, !tbaa !33
  %84 = getelementptr inbounds %"struct.rw::Geometry", ptr %10, i32 0, i32 12
  %85 = load ptr, ptr %84, align 8, !tbaa !20
  %86 = call noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16) %85)
  store ptr %86, ptr %7, align 8, !tbaa !5
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = getelementptr inbounds %"struct.rw::Mesh", ptr %87, i32 0, i32 0
  %89 = load ptr, ptr %88, align 8, !tbaa !34
  store ptr %89, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !21
  br label %90

90:                                               ; preds = %162, %66
  %91 = load i32, ptr %3, align 4, !tbaa !21
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  %93 = getelementptr inbounds %"struct.rw::MeshHeader", ptr %92, i32 0, i32 1
  %94 = load i16, ptr %93, align 4, !tbaa !32
  %95 = zext i16 %94 to i32
  %96 = icmp slt i32 %91, %95
  br i1 %96, label %97, label %165

97:                                               ; preds = %90
  %98 = load ptr, ptr %6, align 8, !tbaa !5
  %99 = load i32, ptr %3, align 4, !tbaa !21
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds %"struct.rw::Mesh", ptr %98, i64 %100
  %102 = getelementptr inbounds %"struct.rw::Mesh", ptr %101, i32 0, i32 2
  %103 = load ptr, ptr %102, align 8, !tbaa !23
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = load i32, ptr %3, align 4, !tbaa !21
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds %"struct.rw::Mesh", ptr %104, i64 %106
  %108 = getelementptr inbounds %"struct.rw::Mesh", ptr %107, i32 0, i32 2
  store ptr %103, ptr %108, align 8, !tbaa !23
  %109 = load ptr, ptr %6, align 8, !tbaa !5
  %110 = load i32, ptr %3, align 4, !tbaa !21
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds %"struct.rw::Mesh", ptr %109, i64 %111
  %113 = getelementptr inbounds %"struct.rw::Mesh", ptr %112, i32 0, i32 1
  %114 = load i32, ptr %113, align 8, !tbaa !25
  %115 = load ptr, ptr %7, align 8, !tbaa !5
  %116 = load i32, ptr %3, align 4, !tbaa !21
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds %"struct.rw::Mesh", ptr %115, i64 %117
  %119 = getelementptr inbounds %"struct.rw::Mesh", ptr %118, i32 0, i32 1
  store i32 %114, ptr %119, align 8, !tbaa !25
  %120 = load ptr, ptr %4, align 8, !tbaa !5
  %121 = load ptr, ptr %7, align 8, !tbaa !5
  %122 = load i32, ptr %3, align 4, !tbaa !21
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds %"struct.rw::Mesh", ptr %121, i64 %123
  %125 = getelementptr inbounds %"struct.rw::Mesh", ptr %124, i32 0, i32 0
  store ptr %120, ptr %125, align 8, !tbaa !34
  %126 = load ptr, ptr %7, align 8, !tbaa !5
  %127 = load i32, ptr %3, align 4, !tbaa !21
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds %"struct.rw::Mesh", ptr %126, i64 %128
  %130 = getelementptr inbounds %"struct.rw::Mesh", ptr %129, i32 0, i32 1
  %131 = load i32, ptr %130, align 8, !tbaa !25
  %132 = load ptr, ptr %4, align 8, !tbaa !5
  %133 = zext i32 %131 to i64
  %134 = getelementptr inbounds i16, ptr %132, i64 %133
  store ptr %134, ptr %4, align 8, !tbaa !5
  %135 = load ptr, ptr %7, align 8, !tbaa !5
  %136 = load i32, ptr %3, align 4, !tbaa !21
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds %"struct.rw::Mesh", ptr %135, i64 %137
  %139 = getelementptr inbounds %"struct.rw::Mesh", ptr %138, i32 0, i32 0
  %140 = load ptr, ptr %139, align 8, !tbaa !34
  %141 = load ptr, ptr %6, align 8, !tbaa !5
  %142 = load i32, ptr %3, align 4, !tbaa !21
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds %"struct.rw::Mesh", ptr %141, i64 %143
  %145 = getelementptr inbounds %"struct.rw::Mesh", ptr %144, i32 0, i32 0
  %146 = load ptr, ptr %145, align 8, !tbaa !34
  %147 = load ptr, ptr %7, align 8, !tbaa !5
  %148 = load i32, ptr %3, align 4, !tbaa !21
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds %"struct.rw::Mesh", ptr %147, i64 %149
  %151 = getelementptr inbounds %"struct.rw::Mesh", ptr %150, i32 0, i32 1
  %152 = load i32, ptr %151, align 8, !tbaa !25
  %153 = zext i32 %152 to i64
  %154 = mul i64 %153, 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %140, ptr align 2 %146, i64 %154, i1 false)
  %155 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !30
  %156 = load ptr, ptr %6, align 8, !tbaa !5
  %157 = load i32, ptr %3, align 4, !tbaa !21
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds %"struct.rw::Mesh", ptr %156, i64 %158
  %160 = getelementptr inbounds %"struct.rw::Mesh", ptr %159, i32 0, i32 0
  %161 = load ptr, ptr %160, align 8, !tbaa !34
  call void %155(ptr noundef %161)
  br label %162

162:                                              ; preds = %97
  %163 = load i32, ptr %3, align 4, !tbaa !21
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %3, align 4, !tbaa !21
  br label %90, !llvm.loop !35

165:                                              ; preds = %90
  %166 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !30
  %167 = load ptr, ptr %5, align 8, !tbaa !5
  call void %166(ptr noundef %167)
  call void @_ZN2rwL10verifyMeshEPNS_8GeometryE(ptr noundef %10)
  call void @llvm.lifetime.end.p0(i64 48, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  ret void
}

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

declare noundef ptr @_ZN2rw8Geometry14allocateMeshesEiji(ptr noundef nonnull align 8 dereferenceable(168), i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw8LinkList4initEv(ptr noundef nonnull align 8 dereferenceable(16)) #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL12collectFacesEPNS_8GeometryEPNS_9StripMeshEt(ptr noundef, ptr noundef, i16 noundef zeroext) #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL20connectNodesPreserveEPNS_9StripMeshE(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL11buildStripsEPNS_9StripMeshE(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL10printSmeshEPNS_9StripMeshE(ptr noundef) #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL8makeMeshEPNS_9StripMeshEPNS_4MeshE(ptr noundef, ptr noundef) #0

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL10verifyMeshEPNS_8GeometryE(ptr noundef) #0

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { inlinehint 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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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, !12, i64 136}
!10 = !{!"_ZTSN2rw8GeometryE", !11, i64 0, !12, i64 16, !13, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !6, i64 40, !6, i64 48, !7, i64 56, !6, i64 120, !14, i64 128, !6, i64 144, !6, i64 152, !12, i64 160}
!11 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"_ZTSN2rw12MaterialListE", !6, i64 0, !12, i64 8, !12, i64 12}
!15 = !{!10, !12, i64 24}
!16 = !{!17, !6, i64 8}
!17 = !{!"_ZTSN2rw9StripMeshE", !12, i64 0, !6, i64 8, !18, i64 16, !18, i64 32}
!18 = !{!"_ZTSN2rw8LinkListE", !19, i64 0}
!19 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!20 = !{!10, !6, i64 144}
!21 = !{!12, !12, i64 0}
!22 = !{!10, !6, i64 128}
!23 = !{!24, !6, i64 16}
!24 = !{!"_ZTSN2rw4MeshE", !6, i64 0, !12, i64 8, !6, i64 16}
!25 = !{!24, !12, i64 8}
!26 = !{!27, !12, i64 8}
!27 = !{!"_ZTSN2rw10MeshHeaderE", !12, i64 0, !13, i64 4, !13, i64 6, !12, i64 8, !12, i64 12}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!31, !6, i64 16}
!31 = !{!"_ZTSN2rw15MemoryFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!32 = !{!27, !13, i64 4}
!33 = !{!27, !12, i64 0}
!34 = !{!24, !6, i64 0}
!35 = distinct !{!35, !29}


; 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.rw::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"struct.rw::StripMesh" = type { i32, ptr, %"struct.rw::LinkList", %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Mesh" = type { ptr, i32, ptr }

@.str = external hidden unnamed_addr constant [76 x i8], align 1
@_ZN2rw6Engine8memfuncsE = external local_unnamed_addr global %"struct.rw::MemoryFunctions", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2rw8Geometry14buildTristripsEv(ptr noundef nonnull align 8 dereferenceable(168) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %"struct.rw::StripMesh", align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %2) #6
  %3 = getelementptr inbounds i8, ptr %0, i64 128
  %4 = getelementptr inbounds i8, ptr %0, i64 136
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = tail call noundef ptr @_ZN2rw8Geometry14allocateMeshesEiji(ptr noundef nonnull align 8 dereferenceable(168) %0, i32 noundef %5, i32 noundef 0, i32 noundef 1)
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load i32, ptr %7, align 8, !tbaa !14
  %9 = sext i32 %8 to i64
  %10 = mul nsw i64 %9, 56
  %11 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %10, i32 noundef 65551, ptr noundef nonnull @.str)
  %12 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %11, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 144
  %14 = load ptr, ptr %13, align 8, !tbaa !19
  %15 = tail call noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16) %14)
  %16 = load i32, ptr %4, align 8, !tbaa !5
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %1
  %18 = getelementptr inbounds i8, ptr %2, i64 16
  %19 = getelementptr inbounds i8, ptr %2, i64 32
  br label %33

._crit_edge.loopexit:                             ; preds = %33
  %.pre = load ptr, ptr %12, align 8, !tbaa !15
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  %20 = phi ptr [ %.pre, %._crit_edge.loopexit ], [ %11, %1 ]
  %21 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !20
  call void %21(ptr noundef %20)
  %22 = load ptr, ptr %13, align 8, !tbaa !19
  store ptr null, ptr %13, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %22, i64 4
  %24 = load i16, ptr %23, align 4, !tbaa !22
  %25 = zext i16 %24 to i32
  %26 = getelementptr inbounds i8, ptr %22, i64 8
  %27 = load i32, ptr %26, align 4, !tbaa !24
  %28 = call noundef ptr @_ZN2rw8Geometry14allocateMeshesEiji(ptr noundef nonnull align 8 dereferenceable(168) %0, i32 noundef %25, i32 noundef %27, i32 noundef 0)
  %29 = load ptr, ptr %13, align 8, !tbaa !19
  store i32 1, ptr %29, align 4, !tbaa !25
  %30 = call noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16) %29)
  %31 = load i16, ptr %23, align 4, !tbaa !22
  %.not = icmp eq i16 %31, 0
  br i1 %.not, label %._crit_edge46, label %.lr.ph45.preheader

.lr.ph45.preheader:                               ; preds = %._crit_edge
  %32 = load ptr, ptr %30, align 8, !tbaa !26
  br label %.lr.ph45

33:                                               ; preds = %.lr.ph, %33
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %33 ]
  call void @_ZN2rw8LinkList4initEv(ptr noundef nonnull align 8 dereferenceable(16) %18)
  call void @_ZN2rw8LinkList4initEv(ptr noundef nonnull align 8 dereferenceable(16) %19)
  %34 = trunc i64 %indvars.iv to i16
  call void @_ZN2rwL12collectFacesEPNS_8GeometryEPNS_9StripMeshEt(ptr noundef nonnull %0, ptr noundef nonnull %2, i16 noundef zeroext %34)
  call void @_ZN2rwL20connectNodesPreserveEPNS_9StripMeshE(ptr noundef nonnull %2)
  call void @_ZN2rwL11buildStripsEPNS_9StripMeshE(ptr noundef nonnull %2)
  call void @_ZN2rwL10printSmeshEPNS_9StripMeshE(ptr noundef nonnull %2)
  %35 = load ptr, ptr %3, align 8, !tbaa !28
  %36 = getelementptr inbounds ptr, ptr %35, i64 %indvars.iv
  %37 = load ptr, ptr %36, align 8, !tbaa !29
  %38 = getelementptr inbounds %"struct.rw::Mesh", ptr %15, i64 %indvars.iv
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  store ptr %37, ptr %39, align 8, !tbaa !30
  call void @_ZN2rwL8makeMeshEPNS_9StripMeshEPNS_4MeshE(ptr noundef nonnull %2, ptr noundef %38)
  %40 = getelementptr inbounds i8, ptr %38, i64 8
  %41 = load i32, ptr %40, align 8, !tbaa !31
  %42 = load ptr, ptr %13, align 8, !tbaa !19
  %43 = getelementptr inbounds i8, ptr %42, i64 8
  %44 = load i32, ptr %43, align 4, !tbaa !24
  %45 = add i32 %44, %41
  store i32 %45, ptr %43, align 4, !tbaa !24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %46 = load i32, ptr %4, align 8, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = icmp slt i64 %indvars.iv.next, %47
  br i1 %48, label %33, label %._crit_edge.loopexit, !llvm.loop !32

.lr.ph45:                                         ; preds = %.lr.ph45.preheader, %.lr.ph45
  %indvars.iv48 = phi i64 [ 0, %.lr.ph45.preheader ], [ %indvars.iv.next49, %.lr.ph45 ]
  %.04042 = phi ptr [ %32, %.lr.ph45.preheader ], [ %58, %.lr.ph45 ]
  %49 = getelementptr inbounds %"struct.rw::Mesh", ptr %15, i64 %indvars.iv48
  %50 = getelementptr inbounds i8, ptr %49, i64 16
  %51 = load ptr, ptr %50, align 8, !tbaa !30
  %52 = getelementptr inbounds %"struct.rw::Mesh", ptr %30, i64 %indvars.iv48
  %53 = getelementptr inbounds i8, ptr %52, i64 16
  store ptr %51, ptr %53, align 8, !tbaa !30
  %54 = getelementptr inbounds i8, ptr %49, i64 8
  %55 = load i32, ptr %54, align 8, !tbaa !31
  %56 = getelementptr inbounds i8, ptr %52, i64 8
  store i32 %55, ptr %56, align 8, !tbaa !31
  store ptr %.04042, ptr %52, align 8, !tbaa !26
  %57 = zext i32 %55 to i64
  %58 = getelementptr inbounds i16, ptr %.04042, i64 %57
  %59 = load ptr, ptr %49, align 8, !tbaa !26
  %60 = shl nuw nsw i64 %57, 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %.04042, ptr align 2 %59, i64 %60, i1 false)
  %61 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !20
  %62 = load ptr, ptr %49, align 8, !tbaa !26
  call void %61(ptr noundef %62)
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %63 = load i16, ptr %23, align 4, !tbaa !22
  %64 = zext i16 %63 to i64
  %65 = icmp ult i64 %indvars.iv.next49, %64
  br i1 %65, label %.lr.ph45, label %._crit_edge46, !llvm.loop !34

._crit_edge46:                                    ; preds = %.lr.ph45, %._crit_edge
  %66 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !20
  call void %66(ptr noundef nonnull %22)
  call void @_ZN2rwL10verifyMeshEPNS_8GeometryE(ptr noundef nonnull %0)
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %2) #6
  ret void
}

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

declare noundef ptr @_ZN2rw8Geometry14allocateMeshesEiji(ptr noundef nonnull align 8 dereferenceable(168), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw10MeshHeader9getMeshesEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw8LinkList4initEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL12collectFacesEPNS_8GeometryEPNS_9StripMeshEt(ptr noundef, ptr noundef, i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL20connectNodesPreserveEPNS_9StripMeshE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL11buildStripsEPNS_9StripMeshE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL10printSmeshEPNS_9StripMeshE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL8makeMeshEPNS_9StripMeshEPNS_4MeshE(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN2rwL10verifyMeshEPNS_8GeometryE(ptr noundef) local_unnamed_addr #0

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { inlinehint 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 = { 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 #5 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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, !11, i64 136}
!6 = !{!"_ZTSN2rw8GeometryE", !7, i64 0, !11, i64 16, !12, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !10, i64 40, !10, i64 48, !8, i64 56, !10, i64 120, !13, i64 128, !10, i64 144, !10, i64 152, !11, i64 160}
!7 = !{!"_ZTSN2rw6ObjectE", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !10, i64 8}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!"_ZTSN2rw12MaterialListE", !10, i64 0, !11, i64 8, !11, i64 12}
!14 = !{!6, !11, i64 24}
!15 = !{!16, !10, i64 8}
!16 = !{!"_ZTSN2rw9StripMeshE", !11, i64 0, !10, i64 8, !17, i64 16, !17, i64 32}
!17 = !{!"_ZTSN2rw8LinkListE", !18, i64 0}
!18 = !{!"_ZTSN2rw6LLLinkE", !10, i64 0, !10, i64 8}
!19 = !{!6, !10, i64 144}
!20 = !{!21, !10, i64 16}
!21 = !{!"_ZTSN2rw15MemoryFunctionsE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!22 = !{!23, !12, i64 4}
!23 = !{!"_ZTSN2rw10MeshHeaderE", !11, i64 0, !12, i64 4, !12, i64 6, !11, i64 8, !11, i64 12}
!24 = !{!23, !11, i64 8}
!25 = !{!23, !11, i64 0}
!26 = !{!27, !10, i64 0}
!27 = !{!"_ZTSN2rw4MeshE", !10, i64 0, !11, i64 8, !10, i64 16}
!28 = !{!6, !10, i64 128}
!29 = !{!10, !10, i64 0}
!30 = !{!27, !10, i64 16}
!31 = !{!27, !11, i64 8}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}
!34 = distinct !{!34, !33}


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