; LLVM IR from aap/librw :: src/frame.ll (ZN2rw10FrameList_10streamReadEPNS_6StreamE)

; 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::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"struct.rw::FrameStreamData" = type { %"struct.rw::V3d", %"struct.rw::V3d", %"struct.rw::V3d", %"struct.rw::V3d", i32, i32 }
%"struct.rw::V3d" = type { float, float, float }
%"struct.rw::Error" = type { i32, i32 }
%"struct.rw::FrameList_" = type { i32, ptr }
%"struct.rw::Frame" = type { %"struct.rw::Object", %"struct.rw::LLLink", %"struct.rw::LinkList", %"struct.rw::Matrix", %"struct.rw::Matrix", ptr, ptr, ptr }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::Matrix" = type { %"struct.rw::V3d", i32, %"struct.rw::V3d", i32, %"struct.rw::V3d", i32, %"struct.rw::V3d", i32 }

@_ZN2rw5Frame9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@_ZN2rw6Engine8memfuncsE = external global %"struct.rw::MemoryFunctions", align 8
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [73 x i8], align 1
@_ZN2rw18streamAppendFramesE = external global i32, align 4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw5Frame6createEv() #0 align 2

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) #4

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #4

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw5Frame8addChildEPS0_i(ptr noundef nonnull align 8 dereferenceable(200), ptr noundef, i32 noundef) #0 align 2

; 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
define dso_local noundef ptr @_ZN2rw10FrameList_10streamReadEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %"struct.rw::FrameStreamData", align 4
  %7 = alloca %"struct.rw::Error", align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.rw::Error", align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr %6) #6
  %14 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 0
  store i32 0, ptr %14, align 8, !tbaa !9
  %15 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 1
  store ptr null, ptr %15, align 8, !tbaa !12
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %16, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %17, label %29, label %18

18:                                               ; preds = %2
  br label %19

19:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %20 = getelementptr inbounds %"struct.rw::Error", ptr %7, i32 0, i32 0
  store i32 14, ptr %20, align 4, !tbaa !13
  %21 = getelementptr inbounds %"struct.rw::Error", ptr %7, i32 0, i32 1
  store i32 -2147483644, ptr %21, align 4, !tbaa !15
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 373) #6
  %24 = load ptr, ptr @stderr, align 8, !tbaa !5
  %25 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef @.str.5)
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %24, ptr noundef @.str.3, ptr noundef %25) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %27

27:                                               ; preds = %19
  br label %28

28:                                               ; preds = %27
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %146

29:                                               ; preds = %2
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8) %30)
  %32 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 0
  store i32 %31, ptr %32, align 8, !tbaa !9
  %33 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = mul i64 %35, 8
  %37 = call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %36, i32 noundef 196622, ptr noundef @.str.6)
  %38 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 1
  store ptr %37, ptr %38, align 8, !tbaa !12
  %39 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 1
  %40 = load ptr, ptr %39, align 8, !tbaa !12
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %57

42:                                               ; preds = %29
  br label %43

43:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %44 = getelementptr inbounds %"struct.rw::Error", ptr %9, i32 0, i32 0
  store i32 14, ptr %44, align 4, !tbaa !13
  %45 = getelementptr inbounds %"struct.rw::Error", ptr %9, i32 0, i32 1
  store i32 -2147483646, ptr %45, align 4, !tbaa !15
  %46 = load ptr, ptr @stderr, align 8, !tbaa !5
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 379) #6
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = mul i64 %51, 8
  %53 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i64 noundef %52)
  %54 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.3, ptr noundef %53) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  br label %55

55:                                               ; preds = %43
  br label %56

56:                                               ; preds = %55
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %146

57:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !16
  br label %58

58:                                               ; preds = %121, %57
  %59 = load i32, ptr %10, align 4, !tbaa !16
  %60 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !9
  %62 = icmp slt i32 %59, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %58
  store i32 6, ptr %8, align 4
  br label %124

64:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = call noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef %6, i32 noundef 56)
  %67 = call noundef ptr @_ZN2rw5Frame6createEv()
  store ptr %67, ptr %11, align 8, !tbaa !5
  %68 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 1
  %69 = load ptr, ptr %68, align 8, !tbaa !12
  %70 = load i32, ptr %10, align 4, !tbaa !16
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  store ptr %67, ptr %72, align 8, !tbaa !5
  %73 = load ptr, ptr %11, align 8, !tbaa !5
  %74 = icmp eq ptr %73, null
  br i1 %74, label %75, label %79

75:                                               ; preds = %64
  %76 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !17
  %77 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !12
  call void %76(ptr noundef %78)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %118

79:                                               ; preds = %64
  %80 = getelementptr inbounds %"struct.rw::FrameStreamData", ptr %6, i32 0, i32 0
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.rw::Frame", ptr %81, i32 0, i32 3
  %83 = getelementptr inbounds %"struct.rw::Matrix", ptr %82, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %83, ptr align 4 %80, i64 12, i1 false), !tbaa.struct !19
  %84 = getelementptr inbounds %"struct.rw::FrameStreamData", ptr %6, i32 0, i32 1
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = getelementptr inbounds %"struct.rw::Frame", ptr %85, i32 0, i32 3
  %87 = getelementptr inbounds %"struct.rw::Matrix", ptr %86, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %87, ptr align 4 %84, i64 12, i1 false), !tbaa.struct !19
  %88 = getelementptr inbounds %"struct.rw::FrameStreamData", ptr %6, i32 0, i32 2
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = getelementptr inbounds %"struct.rw::Frame", ptr %89, i32 0, i32 3
  %91 = getelementptr inbounds %"struct.rw::Matrix", ptr %90, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %91, ptr align 4 %88, i64 12, i1 false), !tbaa.struct !19
  %92 = getelementptr inbounds %"struct.rw::FrameStreamData", ptr %6, i32 0, i32 3
  %93 = load ptr, ptr %11, align 8, !tbaa !5
  %94 = getelementptr inbounds %"struct.rw::Frame", ptr %93, i32 0, i32 3
  %95 = getelementptr inbounds %"struct.rw::Matrix", ptr %94, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %95, ptr align 4 %92, i64 12, i1 false), !tbaa.struct !19
  %96 = load ptr, ptr %11, align 8, !tbaa !5
  %97 = getelementptr inbounds %"struct.rw::Frame", ptr %96, i32 0, i32 3
  call void @_ZN2rw6Matrix8optimizeEPNS0_9ToleranceE(ptr noundef nonnull align 4 dereferenceable(64) %97, ptr noundef null)
  %98 = load ptr, ptr %11, align 8, !tbaa !5
  %99 = getelementptr inbounds %"struct.rw::Frame", ptr %98, i32 0, i32 3
  %100 = getelementptr inbounds %"struct.rw::Matrix", ptr %99, i32 0, i32 1
  %101 = load i32, ptr %100, align 4, !tbaa !22
  %102 = and i32 %101, -131073
  store i32 %102, ptr %100, align 4, !tbaa !22
  %103 = getelementptr inbounds %"struct.rw::FrameStreamData", ptr %6, i32 0, i32 4
  %104 = load i32, ptr %103, align 4, !tbaa !29
  %105 = icmp sge i32 %104, 0
  br i1 %105, label %106, label %117

106:                                              ; preds = %79
  %107 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 1
  %108 = load ptr, ptr %107, align 8, !tbaa !12
  %109 = getelementptr inbounds %"struct.rw::FrameStreamData", ptr %6, i32 0, i32 4
  %110 = load i32, ptr %109, align 4, !tbaa !29
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds ptr, ptr %108, i64 %111
  %113 = load ptr, ptr %112, align 8, !tbaa !5
  %114 = load ptr, ptr %11, align 8, !tbaa !5
  %115 = load i32, ptr @_ZN2rw18streamAppendFramesE, align 4, !tbaa !16
  %116 = call noundef ptr @_ZN2rw5Frame8addChildEPS0_i(ptr noundef nonnull align 8 dereferenceable(200) %113, ptr noundef %114, i32 noundef %115)
  br label %117

117:                                              ; preds = %106, %79
  store i32 0, ptr %8, align 4
  br label %118

118:                                              ; preds = %117, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %119 = load i32, ptr %8, align 4
  switch i32 %119, label %124 [
    i32 0, label %120
  ]

120:                                              ; preds = %118
  br label %121

121:                                              ; preds = %120
  %122 = load i32, ptr %10, align 4, !tbaa !16
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %10, align 4, !tbaa !16
  br label %58, !llvm.loop !31

124:                                              ; preds = %118, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %125 = load i32, ptr %8, align 4
  switch i32 %125, label %146 [
    i32 6, label %126
  ]

126:                                              ; preds = %124
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !16
  br label %127

127:                                              ; preds = %142, %126
  %128 = load i32, ptr %12, align 4, !tbaa !16
  %129 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 0
  %130 = load i32, ptr %129, align 8, !tbaa !9
  %131 = icmp slt i32 %128, %130
  br i1 %131, label %133, label %132

132:                                              ; preds = %127
  store i32 9, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %145

133:                                              ; preds = %127
  %134 = load ptr, ptr %5, align 8, !tbaa !5
  %135 = getelementptr inbounds %"struct.rw::FrameList_", ptr %13, i32 0, i32 1
  %136 = load ptr, ptr %135, align 8, !tbaa !12
  %137 = load i32, ptr %12, align 4, !tbaa !16
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds ptr, ptr %136, i64 %138
  %140 = load ptr, ptr %139, align 8, !tbaa !5
  %141 = call noundef zeroext i1 @_ZN2rw10PluginList10streamReadEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw5Frame9s_plglistE, ptr noundef %134, ptr noundef %140)
  br label %142

142:                                              ; preds = %133
  %143 = load i32, ptr %12, align 4, !tbaa !16
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %12, align 4, !tbaa !16
  br label %127, !llvm.loop !33

145:                                              ; preds = %132
  store ptr %13, ptr %3, align 8
  store i32 1, ptr %8, align 4
  br label %146

146:                                              ; preds = %145, %124, %56, %28
  call void @llvm.lifetime.end.p0(i64 56, ptr %6) #6
  %147 = load ptr, ptr %3, align 8
  ret ptr %147
}

declare noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #4

declare noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8)) #4

declare noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i32 noundef) #4

declare void @_ZN2rw6Matrix8optimizeEPNS0_9ToleranceE(ptr noundef nonnull align 4 dereferenceable(64), ptr noundef) #4

declare noundef zeroext i1 @_ZN2rw10PluginList10streamReadEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) #4

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 = { 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 #3 = { nounwind "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 = { "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, !11, i64 0}
!10 = !{!"_ZTSN2rw10FrameList_E", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!14, !11, i64 0}
!14 = !{!"_ZTSN2rw5ErrorE", !11, i64 0, !11, i64 4}
!15 = !{!14, !11, i64 4}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !6, i64 16}
!18 = !{!"_ZTSN2rw15MemoryFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!19 = !{i64 0, i64 4, !20, i64 4, i64 4, !20, i64 8, i64 4, !20}
!20 = !{!21, !21, i64 0}
!21 = !{!"float", !7, i64 0}
!22 = !{!23, !11, i64 60}
!23 = !{!"_ZTSN2rw5FrameE", !24, i64 0, !25, i64 16, !26, i64 32, !27, i64 48, !27, i64 112, !6, i64 176, !6, i64 184, !6, i64 192}
!24 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!25 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!26 = !{!"_ZTSN2rw8LinkListE", !25, i64 0}
!27 = !{!"_ZTSN2rw6MatrixE", !28, i64 0, !11, i64 12, !28, i64 16, !11, i64 28, !28, i64 32, !11, i64 44, !28, i64 48, !11, i64 60}
!28 = !{!"_ZTSN2rw3V3dE", !21, i64 0, !21, i64 4, !21, i64 8}
!29 = !{!30, !11, i64 48}
!30 = !{!"_ZTSN2rw15FrameStreamDataE", !28, i64 0, !28, i64 12, !28, i64 24, !28, i64 36, !11, i64 48, !11, i64 52}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}
!33 = distinct !{!33, !32}


; 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::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"struct.rw::FrameStreamData" = type { %"struct.rw::V3d", %"struct.rw::V3d", %"struct.rw::V3d", %"struct.rw::V3d", i32, i32 }
%"struct.rw::V3d" = type { float, float, float }
%"struct.rw::Error" = type { i32, i32 }

@_ZN2rw5Frame9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@_ZN2rw6Engine8memfuncsE = external local_unnamed_addr global %"struct.rw::MemoryFunctions", align 8
@.str.5 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [73 x i8], align 1
@_ZN2rw18streamAppendFramesE = external local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN2rw5Frame6createEv() local_unnamed_addr #0 align 2

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare noundef ptr @_ZN2rw9dbgsprintEjz(i32 noundef, ...) local_unnamed_addr #4

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #4

; 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 uwtable
declare dso_local noundef ptr @_ZN2rw5Frame8addChildEPS0_i(ptr noundef nonnull align 8 dereferenceable(200), ptr noundef, i32 noundef) local_unnamed_addr #0 align 2

; 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
define dso_local noundef ptr @_ZN2rw10FrameList_10streamReadEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1) local_unnamed_addr #0 align 2 {
  %3 = alloca %"struct.rw::FrameStreamData", align 4
  %4 = alloca %"struct.rw::Error", align 4
  %5 = alloca %"struct.rw::Error", align 4
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %3) #6
  store i32 0, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr null, ptr %6, align 8, !tbaa !11
  %7 = tail call noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %1, i32 noundef 1, ptr noundef null, ptr noundef null)
  br i1 %7, label %15, label %8

8:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  store i32 14, ptr %4, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 -2147483644, ptr %9, align 4, !tbaa !14
  %10 = load ptr, ptr @stderr, align 8, !tbaa !15
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 373) #7
  %12 = load ptr, ptr @stderr, align 8, !tbaa !15
  %13 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483644, ptr noundef nonnull @.str.5)
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.3, ptr noundef %13) #7
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  br label %.loopexit

15:                                               ; preds = %2
  %16 = tail call noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8) %1)
  store i32 %16, ptr %0, align 8, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = shl nsw i64 %17, 3
  %19 = tail call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %18, i32 noundef 196622, ptr noundef nonnull @.str.6)
  store ptr %19, ptr %6, align 8, !tbaa !11
  %20 = icmp eq ptr %19, null
  br i1 %20, label %26, label %.preheader

.preheader:                                       ; preds = %15
  %21 = load i32, ptr %0, align 8, !tbaa !5
  %.not2829 = icmp sgt i32 %21, 0
  br i1 %.not2829, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %22 = getelementptr inbounds i8, ptr %3, i64 12
  %23 = getelementptr inbounds i8, ptr %3, i64 24
  %24 = getelementptr inbounds i8, ptr %3, i64 36
  %25 = getelementptr inbounds i8, ptr %3, i64 48
  br label %37

26:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  store i32 14, ptr %5, align 4, !tbaa !12
  %27 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 -2147483646, ptr %27, align 4, !tbaa !14
  %28 = load ptr, ptr @stderr, align 8, !tbaa !15
  %29 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 379) #7
  %30 = load ptr, ptr @stderr, align 8, !tbaa !15
  %31 = load i32, ptr %0, align 8, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = shl nsw i64 %32, 3
  %34 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i64 noundef %33)
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef nonnull @.str.3, ptr noundef %34) #7
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %5)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  br label %.loopexit

.critedge.preheader:                              ; preds = %59
  %36 = icmp sgt i32 %60, 0
  br i1 %36, label %.critedge, label %.loopexit

37:                                               ; preds = %.lr.ph, %59
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %59 ]
  %38 = call noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %3, i32 noundef 56)
  %39 = call noundef ptr @_ZN2rw5Frame6createEv()
  %40 = load ptr, ptr %6, align 8, !tbaa !11
  %41 = getelementptr inbounds ptr, ptr %40, i64 %indvars.iv
  store ptr %39, ptr %41, align 8, !tbaa !15
  %.not = icmp eq ptr %39, null
  br i1 %.not, label %62, label %42

42:                                               ; preds = %37
  %43 = getelementptr inbounds i8, ptr %39, i64 48
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %43, ptr noundef nonnull align 4 dereferenceable(12) %3, i64 12, i1 false), !tbaa.struct !16
  %44 = getelementptr inbounds i8, ptr %39, i64 64
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %44, ptr noundef nonnull align 4 dereferenceable(12) %22, i64 12, i1 false), !tbaa.struct !16
  %45 = getelementptr inbounds i8, ptr %39, i64 80
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %45, ptr noundef nonnull align 4 dereferenceable(12) %23, i64 12, i1 false), !tbaa.struct !16
  %46 = getelementptr inbounds i8, ptr %39, i64 96
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %46, ptr noundef nonnull align 4 dereferenceable(12) %24, i64 12, i1 false), !tbaa.struct !16
  call void @_ZN2rw6Matrix8optimizeEPNS0_9ToleranceE(ptr noundef nonnull align 4 dereferenceable(64) %43, ptr noundef null)
  %47 = getelementptr inbounds i8, ptr %39, i64 60
  %48 = load i32, ptr %47, align 4, !tbaa !19
  %49 = and i32 %48, -131073
  store i32 %49, ptr %47, align 4, !tbaa !19
  %50 = load i32, ptr %25, align 4, !tbaa !26
  %51 = icmp sgt i32 %50, -1
  br i1 %51, label %52, label %59

52:                                               ; preds = %42
  %53 = load ptr, ptr %6, align 8, !tbaa !11
  %54 = zext nneg i32 %50 to i64
  %55 = getelementptr inbounds ptr, ptr %53, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = load i32, ptr @_ZN2rw18streamAppendFramesE, align 4, !tbaa !28
  %58 = call noundef ptr @_ZN2rw5Frame8addChildEPS0_i(ptr noundef nonnull align 8 dereferenceable(200) %56, ptr noundef nonnull %39, i32 noundef %57)
  br label %59

59:                                               ; preds = %42, %52
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %60 = load i32, ptr %0, align 8, !tbaa !5
  %61 = sext i32 %60 to i64
  %.not28 = icmp slt i64 %indvars.iv.next, %61
  br i1 %.not28, label %37, label %.critedge.preheader, !llvm.loop !29

62:                                               ; preds = %37
  %63 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !31
  %64 = load ptr, ptr %6, align 8, !tbaa !11
  call void %63(ptr noundef %64)
  br label %.loopexit

.critedge:                                        ; preds = %.critedge.preheader, %.critedge
  %indvars.iv35 = phi i64 [ %indvars.iv.next36, %.critedge ], [ 0, %.critedge.preheader ]
  %65 = load ptr, ptr %6, align 8, !tbaa !11
  %66 = getelementptr inbounds ptr, ptr %65, i64 %indvars.iv35
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  %68 = call noundef zeroext i1 @_ZN2rw10PluginList10streamReadEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw5Frame9s_plglistE, ptr noundef nonnull %1, ptr noundef %67)
  %indvars.iv.next36 = add nuw nsw i64 %indvars.iv35, 1
  %69 = load i32, ptr %0, align 8, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = icmp slt i64 %indvars.iv.next36, %70
  br i1 %71, label %.critedge, label %.loopexit, !llvm.loop !33

.loopexit:                                        ; preds = %.critedge, %.preheader, %.critedge.preheader, %62, %26, %8
  %.3 = phi ptr [ null, %26 ], [ null, %62 ], [ null, %8 ], [ %0, %.critedge.preheader ], [ %0, %.preheader ], [ %0, %.critedge ]
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %3) #6
  ret ptr %.3
}

declare noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare noundef i32 @_ZN2rw6Stream7readI32Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4

declare noundef i32 @_ZN2rw6Stream6read32EPvj(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i32 noundef) local_unnamed_addr #4

declare void @_ZN2rw6Matrix8optimizeEPNS0_9ToleranceE(ptr noundef nonnull align 4 dereferenceable(64), ptr noundef) local_unnamed_addr #4

declare noundef zeroext i1 @_ZN2rw10PluginList10streamReadEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) local_unnamed_addr #4

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 = { 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 #3 = { nofree nounwind "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 = { "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 }
attributes #7 = { cold 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, !7, i64 0}
!6 = !{!"_ZTSN2rw10FrameList_E", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTSN2rw5ErrorE", !7, i64 0, !7, i64 4}
!14 = !{!13, !7, i64 4}
!15 = !{!10, !10, i64 0}
!16 = !{i64 0, i64 4, !17, i64 4, i64 4, !17, i64 8, i64 4, !17}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !8, i64 0}
!19 = !{!20, !7, i64 60}
!20 = !{!"_ZTSN2rw5FrameE", !21, i64 0, !22, i64 16, !23, i64 32, !24, i64 48, !24, i64 112, !10, i64 176, !10, i64 184, !10, i64 192}
!21 = !{!"_ZTSN2rw6ObjectE", !8, i64 0, !8, i64 1, !8, i64 2, !8, i64 3, !10, i64 8}
!22 = !{!"_ZTSN2rw6LLLinkE", !10, i64 0, !10, i64 8}
!23 = !{!"_ZTSN2rw8LinkListE", !22, i64 0}
!24 = !{!"_ZTSN2rw6MatrixE", !25, i64 0, !7, i64 12, !25, i64 16, !7, i64 28, !25, i64 32, !7, i64 44, !25, i64 48, !7, i64 60}
!25 = !{!"_ZTSN2rw3V3dE", !18, i64 0, !18, i64 4, !18, i64 8}
!26 = !{!27, !7, i64 48}
!27 = !{!"_ZTSN2rw15FrameStreamDataE", !25, i64 0, !25, i64 12, !25, i64 24, !25, i64 36, !7, i64 48, !7, i64 52}
!28 = !{!7, !7, i64 0}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!32, !10, i64 16}
!32 = !{!"_ZTSN2rw15MemoryFunctionsE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!33 = distinct !{!33, !30}


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