; LLVM IR from aap/librw :: src/clump.ll (ZN2rw5Clump11streamWriteEPNS_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::FrameList_" = type { i32, ptr }
%"struct.rw::Clump" = type { %"struct.rw::Object", %"struct.rw::LinkList", %"struct.rw::LinkList", %"struct.rw::LinkList", ptr, %"struct.rw::LLLink" }
%"struct.rw::Object" = type { i8, i8, i8, i8, ptr }
%"struct.rw::Atomic" = type { %"struct.rw::ObjectWithFrame", ptr, %"struct.rw::Sphere", %"struct.rw::Sphere", ptr, %"struct.rw::LLLink", ptr, ptr, ptr, ptr }
%"struct.rw::ObjectWithFrame" = type { %"struct.rw::Object", %"struct.rw::LLLink", ptr }
%"struct.rw::Sphere" = type { %"struct.rw::V3d", float }
%"struct.rw::V3d" = type { float, float, float }

@_ZN2rw5Clump9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8
@_ZN2rw6Engine8memfuncsE = external global %"struct.rw::MemoryFunctions", align 8
@_ZN2rw7versionE = external global i32, align 4
@.str.20 = external hidden unnamed_addr constant [73 x i8], align 1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88)) #2 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2rw5Clump11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca [3 x i32], align 4
  %11 = alloca %"struct.rw::FrameList_", align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca ptr, align 8
  %26 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %28 = call noundef i32 @_ZN2rw5Clump13streamGetSizeEv(ptr noundef nonnull align 8 dereferenceable(88) %27)
  store i32 %28, ptr %6, align 4, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %29, i32 noundef 16, i32 noundef %30)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %32 = call noundef i32 @_ZN2rw5Clump12countAtomicsEv(ptr noundef nonnull align 8 dereferenceable(88) %27)
  store i32 %32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %33 = call noundef i32 @_ZN2rw5Clump11countLightsEv(ptr noundef nonnull align 8 dereferenceable(88) %27)
  store i32 %33, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %34 = call noundef i32 @_ZN2rw5Clump12countCamerasEv(ptr noundef nonnull align 8 dereferenceable(88) %27)
  store i32 %34, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #5
  %35 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %35, ptr %10, align 4, !tbaa !9
  %36 = getelementptr inbounds i32, ptr %10, i64 1
  %37 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %37, ptr %36, align 4, !tbaa !9
  %38 = getelementptr inbounds i32, ptr %10, i64 2
  %39 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %39, ptr %38, align 4, !tbaa !9
  %40 = load i32, ptr @_ZN2rw7versionE, align 4, !tbaa !9
  %41 = icmp sgt i32 %40, 208896
  %42 = zext i1 %41 to i64
  %43 = select i1 %41, i32 12, i32 4
  store i32 %43, ptr %6, align 4, !tbaa !9
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %44, i32 noundef 1, i32 noundef %45)
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds [3 x i32], ptr %10, i64 0, i64 0
  %49 = load i32, ptr %6, align 4, !tbaa !9
  %50 = call noundef i32 @_ZN2rw6Stream7write32EPKvj(ptr noundef nonnull align 8 dereferenceable(8) %47, ptr noundef %48, i32 noundef %49)
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #5
  %51 = call noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88) %27)
  %52 = call noundef i32 @_ZN2rw5Frame5countEv(ptr noundef nonnull align 8 dereferenceable(200) %51)
  %53 = getelementptr inbounds %"struct.rw::FrameList_", ptr %11, i32 0, i32 0
  store i32 %52, ptr %53, align 8, !tbaa !11
  %54 = getelementptr inbounds %"struct.rw::FrameList_", ptr %11, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !11
  %56 = sext i32 %55 to i64
  %57 = mul i64 %56, 8
  %58 = call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %57, i32 noundef 65552, ptr noundef @.str.20)
  %59 = getelementptr inbounds %"struct.rw::FrameList_", ptr %11, i32 0, i32 1
  store ptr %58, ptr %59, align 8, !tbaa !13
  %60 = call noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88) %27)
  %61 = getelementptr inbounds %"struct.rw::FrameList_", ptr %11, i32 0, i32 1
  %62 = load ptr, ptr %61, align 8, !tbaa !13
  %63 = call noundef ptr @_ZN2rw13makeFrameListEPNS_5FrameEPS1_(ptr noundef %60, ptr noundef %62)
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw10FrameList_11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef %64)
  %65 = load i32, ptr @_ZN2rw7versionE, align 4, !tbaa !9
  %66 = icmp sge i32 %65, 197632
  br i1 %66, label %67, label %124

67:                                               ; preds = %2
  store i32 16, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  store ptr null, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %68 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 1
  %69 = getelementptr inbounds %"struct.rw::LinkList", ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds %"struct.rw::LLLink", ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !14
  store ptr %71, ptr %13, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %90, %67
  %73 = load ptr, ptr %13, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.rw::LLLink", ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !19
  store ptr %75, ptr %12, align 8, !tbaa !5
  %76 = load ptr, ptr %13, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 1
  %78 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %77)
  %79 = icmp ne ptr %76, %78
  br i1 %79, label %81, label %80

80:                                               ; preds = %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %92

81:                                               ; preds = %72
  %82 = load ptr, ptr %13, align 8, !tbaa !5
  %83 = call noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef %82)
  %84 = getelementptr inbounds %"struct.rw::Atomic", ptr %83, i32 0, i32 1
  %85 = load ptr, ptr %84, align 8, !tbaa !20
  %86 = call noundef i32 @_ZN2rw8Geometry13streamGetSizeEv(ptr noundef nonnull align 8 dereferenceable(168) %85)
  %87 = add i32 12, %86
  %88 = load i32, ptr %6, align 4, !tbaa !9
  %89 = add i32 %88, %87
  store i32 %89, ptr %6, align 4, !tbaa !9
  br label %90

90:                                               ; preds = %81
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %91, ptr %13, align 8, !tbaa !5
  br label %72, !llvm.loop !26

92:                                               ; preds = %80
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = load i32, ptr %6, align 4, !tbaa !9
  %95 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %93, i32 noundef 26, i32 noundef %94)
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %96, i32 noundef 1, i32 noundef 4)
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = load i32, ptr %7, align 4, !tbaa !9
  %100 = call noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8) %98, i32 noundef %99)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store ptr null, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %101 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 1
  %102 = getelementptr inbounds %"struct.rw::LinkList", ptr %101, i32 0, i32 0
  %103 = getelementptr inbounds %"struct.rw::LLLink", ptr %102, i32 0, i32 0
  %104 = load ptr, ptr %103, align 8, !tbaa !14
  store ptr %104, ptr %15, align 8, !tbaa !5
  br label %105

105:                                              ; preds = %121, %92
  %106 = load ptr, ptr %15, align 8, !tbaa !5
  %107 = getelementptr inbounds %"struct.rw::LLLink", ptr %106, i32 0, i32 0
  %108 = load ptr, ptr %107, align 8, !tbaa !19
  store ptr %108, ptr %14, align 8, !tbaa !5
  %109 = load ptr, ptr %15, align 8, !tbaa !5
  %110 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 1
  %111 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %110)
  %112 = icmp ne ptr %109, %111
  br i1 %112, label %114, label %113

113:                                              ; preds = %105
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %123

114:                                              ; preds = %105
  %115 = load ptr, ptr %15, align 8, !tbaa !5
  %116 = call noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef %115)
  %117 = getelementptr inbounds %"struct.rw::Atomic", ptr %116, i32 0, i32 1
  %118 = load ptr, ptr %117, align 8, !tbaa !20
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = call noundef zeroext i1 @_ZN2rw8Geometry11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(168) %118, ptr noundef %119)
  br label %121

121:                                              ; preds = %114
  %122 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %122, ptr %15, align 8, !tbaa !5
  br label %105, !llvm.loop !28

123:                                              ; preds = %113
  br label %124

124:                                              ; preds = %123, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  store ptr null, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %125 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 1
  %126 = getelementptr inbounds %"struct.rw::LinkList", ptr %125, i32 0, i32 0
  %127 = getelementptr inbounds %"struct.rw::LLLink", ptr %126, i32 0, i32 0
  %128 = load ptr, ptr %127, align 8, !tbaa !14
  store ptr %128, ptr %17, align 8, !tbaa !5
  br label %129

129:                                              ; preds = %143, %124
  %130 = load ptr, ptr %17, align 8, !tbaa !5
  %131 = getelementptr inbounds %"struct.rw::LLLink", ptr %130, i32 0, i32 0
  %132 = load ptr, ptr %131, align 8, !tbaa !19
  store ptr %132, ptr %16, align 8, !tbaa !5
  %133 = load ptr, ptr %17, align 8, !tbaa !5
  %134 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 1
  %135 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %134)
  %136 = icmp ne ptr %133, %135
  br i1 %136, label %138, label %137

137:                                              ; preds = %129
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  br label %145

138:                                              ; preds = %129
  %139 = load ptr, ptr %17, align 8, !tbaa !5
  %140 = call noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef %139)
  %141 = load ptr, ptr %5, align 8, !tbaa !5
  %142 = call noundef zeroext i1 @_ZN2rw6Atomic16streamWriteClumpEPNS_6StreamEPNS_10FrameList_E(ptr noundef nonnull align 8 dereferenceable(136) %140, ptr noundef %141, ptr noundef %11)
  br label %143

143:                                              ; preds = %138
  %144 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %144, ptr %17, align 8, !tbaa !5
  br label %129, !llvm.loop !29

145:                                              ; preds = %137
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  store ptr null, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %146 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 2
  %147 = getelementptr inbounds %"struct.rw::LinkList", ptr %146, i32 0, i32 0
  %148 = getelementptr inbounds %"struct.rw::LLLink", ptr %147, i32 0, i32 0
  %149 = load ptr, ptr %148, align 8, !tbaa !30
  store ptr %149, ptr %19, align 8, !tbaa !5
  br label %150

150:                                              ; preds = %184, %145
  %151 = load ptr, ptr %19, align 8, !tbaa !5
  %152 = getelementptr inbounds %"struct.rw::LLLink", ptr %151, i32 0, i32 0
  %153 = load ptr, ptr %152, align 8, !tbaa !19
  store ptr %153, ptr %18, align 8, !tbaa !5
  %154 = load ptr, ptr %19, align 8, !tbaa !5
  %155 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 2
  %156 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %155)
  %157 = icmp ne ptr %154, %156
  br i1 %157, label %159, label %158

158:                                              ; preds = %150
  store i32 11, ptr %20, align 4
  br label %186

159:                                              ; preds = %150
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  %160 = load ptr, ptr %19, align 8, !tbaa !5
  %161 = call noundef ptr @_ZN2rw5Light9fromClumpEPNS_6LLLinkE(ptr noundef %160)
  store ptr %161, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  %162 = load ptr, ptr %21, align 8, !tbaa !5
  %163 = call noundef ptr @_ZNK2rw5Light8getFrameEv(ptr noundef nonnull align 8 dereferenceable(120) %162)
  %164 = getelementptr inbounds %"struct.rw::FrameList_", ptr %11, i32 0, i32 1
  %165 = load ptr, ptr %164, align 8, !tbaa !13
  %166 = getelementptr inbounds %"struct.rw::FrameList_", ptr %11, i32 0, i32 0
  %167 = load i32, ptr %166, align 8, !tbaa !11
  %168 = call noundef i32 @_ZN2rw11findPointerEPvPS0_i(ptr noundef %163, ptr noundef %165, i32 noundef %167)
  store i32 %168, ptr %22, align 4, !tbaa !9
  %169 = load i32, ptr %22, align 4, !tbaa !9
  %170 = icmp slt i32 %169, 0
  br i1 %170, label %171, label %172

171:                                              ; preds = %159
  store i1 false, ptr %3, align 1
  store i32 1, ptr %20, align 4
  br label %181

172:                                              ; preds = %159
  %173 = load ptr, ptr %5, align 8, !tbaa !5
  %174 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %173, i32 noundef 1, i32 noundef 4)
  %175 = load ptr, ptr %5, align 8, !tbaa !5
  %176 = load i32, ptr %22, align 4, !tbaa !9
  %177 = call noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8) %175, i32 noundef %176)
  %178 = load ptr, ptr %21, align 8, !tbaa !5
  %179 = load ptr, ptr %5, align 8, !tbaa !5
  %180 = call noundef zeroext i1 @_ZN2rw5Light11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(120) %178, ptr noundef %179)
  store i32 0, ptr %20, align 4
  br label %181

181:                                              ; preds = %172, %171
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  %182 = load i32, ptr %20, align 4
  switch i32 %182, label %186 [
    i32 0, label %183
  ]

183:                                              ; preds = %181
  br label %184

184:                                              ; preds = %183
  %185 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %185, ptr %19, align 8, !tbaa !5
  br label %150, !llvm.loop !31

186:                                              ; preds = %181, %158
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %187 = load i32, ptr %20, align 4
  switch i32 %187, label %236 [
    i32 11, label %188
  ]

188:                                              ; preds = %186
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  store ptr null, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  %189 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 3
  %190 = getelementptr inbounds %"struct.rw::LinkList", ptr %189, i32 0, i32 0
  %191 = getelementptr inbounds %"struct.rw::LLLink", ptr %190, i32 0, i32 0
  %192 = load ptr, ptr %191, align 8, !tbaa !32
  store ptr %192, ptr %24, align 8, !tbaa !5
  br label %193

193:                                              ; preds = %227, %188
  %194 = load ptr, ptr %24, align 8, !tbaa !5
  %195 = getelementptr inbounds %"struct.rw::LLLink", ptr %194, i32 0, i32 0
  %196 = load ptr, ptr %195, align 8, !tbaa !19
  store ptr %196, ptr %23, align 8, !tbaa !5
  %197 = load ptr, ptr %24, align 8, !tbaa !5
  %198 = getelementptr inbounds %"struct.rw::Clump", ptr %27, i32 0, i32 3
  %199 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %198)
  %200 = icmp ne ptr %197, %199
  br i1 %200, label %202, label %201

201:                                              ; preds = %193
  store i32 14, ptr %20, align 4
  br label %229

202:                                              ; preds = %193
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #5
  %203 = load ptr, ptr %24, align 8, !tbaa !5
  %204 = call noundef ptr @_ZN2rw6Camera9fromClumpEPNS_6LLLinkE(ptr noundef %203)
  store ptr %204, ptr %25, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #5
  %205 = load ptr, ptr %25, align 8, !tbaa !5
  %206 = call noundef ptr @_ZNK2rw6Camera8getFrameEv(ptr noundef nonnull align 8 dereferenceable(600) %205)
  %207 = getelementptr inbounds %"struct.rw::FrameList_", ptr %11, i32 0, i32 1
  %208 = load ptr, ptr %207, align 8, !tbaa !13
  %209 = getelementptr inbounds %"struct.rw::FrameList_", ptr %11, i32 0, i32 0
  %210 = load i32, ptr %209, align 8, !tbaa !11
  %211 = call noundef i32 @_ZN2rw11findPointerEPvPS0_i(ptr noundef %206, ptr noundef %208, i32 noundef %210)
  store i32 %211, ptr %26, align 4, !tbaa !9
  %212 = load i32, ptr %26, align 4, !tbaa !9
  %213 = icmp slt i32 %212, 0
  br i1 %213, label %214, label %215

214:                                              ; preds = %202
  store i1 false, ptr %3, align 1
  store i32 1, ptr %20, align 4
  br label %224

215:                                              ; preds = %202
  %216 = load ptr, ptr %5, align 8, !tbaa !5
  %217 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %216, i32 noundef 1, i32 noundef 4)
  %218 = load ptr, ptr %5, align 8, !tbaa !5
  %219 = load i32, ptr %26, align 4, !tbaa !9
  %220 = call noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8) %218, i32 noundef %219)
  %221 = load ptr, ptr %25, align 8, !tbaa !5
  %222 = load ptr, ptr %5, align 8, !tbaa !5
  %223 = call noundef zeroext i1 @_ZN2rw6Camera11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(600) %221, ptr noundef %222)
  store i32 0, ptr %20, align 4
  br label %224

224:                                              ; preds = %215, %214
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #5
  %225 = load i32, ptr %20, align 4
  switch i32 %225, label %229 [
    i32 0, label %226
  ]

226:                                              ; preds = %224
  br label %227

227:                                              ; preds = %226
  %228 = load ptr, ptr %23, align 8, !tbaa !5
  store ptr %228, ptr %24, align 8, !tbaa !5
  br label %193, !llvm.loop !33

229:                                              ; preds = %224, %201
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  %230 = load i32, ptr %20, align 4
  switch i32 %230, label %236 [
    i32 14, label %231
  ]

231:                                              ; preds = %229
  %232 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !34
  %233 = getelementptr inbounds %"struct.rw::FrameList_", ptr %11, i32 0, i32 1
  %234 = load ptr, ptr %233, align 8, !tbaa !13
  call void %232(ptr noundef %234)
  %235 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN2rw10PluginList11streamWriteEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw5Clump9s_plglistE, ptr noundef %235, ptr noundef %27)
  store i1 true, ptr %3, align 1
  store i32 1, ptr %20, align 4
  br label %236

236:                                              ; preds = %231, %229, %186
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %237 = load i1, ptr %3, align 1
  ret i1 %237
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw5Clump13streamGetSizeEv(ptr noundef nonnull align 8 dereferenceable(88)) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw5Clump12countAtomicsEv(ptr noundef nonnull align 8 dereferenceable(88)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw5Clump11countLightsEv(ptr noundef nonnull align 8 dereferenceable(88)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw5Clump12countCamerasEv(ptr noundef nonnull align 8 dereferenceable(88)) #2 align 2

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

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

declare noundef ptr @_ZN2rw13makeFrameListEPNS_5FrameEPS1_(ptr noundef, ptr noundef) #4

declare void @_ZN2rw10FrameList_11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) #4

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

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

declare noundef zeroext i1 @_ZN2rw8Geometry11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2rw6Atomic16streamWriteClumpEPNS_6StreamEPNS_10FrameList_E(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef, ptr noundef) #3 align 2

declare noundef i32 @_ZN2rw11findPointerEPvPS0_i(ptr noundef, ptr noundef, i32 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw5Light8getFrameEv(ptr noundef nonnull align 8 dereferenceable(120)) #2 align 2

declare noundef zeroext i1 @_ZN2rw5Light11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(120), ptr noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw6Camera8getFrameEv(ptr noundef nonnull align 8 dereferenceable(600)) #2 align 2

declare noundef zeroext i1 @_ZN2rw6Camera11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(600), ptr noundef) #4

declare void @_ZN2rw10PluginList11streamWriteEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { "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 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN2rw10FrameList_E", !10, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !6, i64 16}
!15 = !{!"_ZTSN2rw5ClumpE", !16, i64 0, !17, i64 16, !17, i64 32, !17, i64 48, !6, i64 64, !18, i64 72}
!16 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !6, i64 8}
!17 = !{!"_ZTSN2rw8LinkListE", !18, i64 0}
!18 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!19 = !{!18, !6, i64 0}
!20 = !{!21, !6, i64 40}
!21 = !{!"_ZTSN2rw6AtomicE", !22, i64 0, !6, i64 40, !23, i64 48, !23, i64 64, !6, i64 80, !18, i64 88, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!22 = !{!"_ZTSN2rw15ObjectWithFrameE", !16, i64 0, !18, i64 16, !6, i64 32}
!23 = !{!"_ZTSN2rw6SphereE", !24, i64 0, !25, i64 12}
!24 = !{!"_ZTSN2rw3V3dE", !25, i64 0, !25, i64 4, !25, i64 8}
!25 = !{!"float", !7, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = distinct !{!28, !27}
!29 = distinct !{!29, !27}
!30 = !{!15, !6, i64 32}
!31 = distinct !{!31, !27}
!32 = !{!15, !6, i64 48}
!33 = distinct !{!33, !27}
!34 = !{!35, !6, i64 16}
!35 = !{!"_ZTSN2rw15MemoryFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 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::FrameList_" = type { i32, ptr }

@_ZN2rw5Clump9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8
@_ZN2rw6Engine8memfuncsE = external local_unnamed_addr global %"struct.rw::MemoryFunctions", align 8
@_ZN2rw7versionE = external local_unnamed_addr global i32, align 4
@.str.20 = external hidden unnamed_addr constant [73 x i8], align 1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2rw5Clump11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1) local_unnamed_addr #3 align 2 {
  %3 = alloca [3 x i32], align 4
  %4 = alloca %"struct.rw::FrameList_", align 8
  %5 = tail call noundef i32 @_ZN2rw5Clump13streamGetSizeEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %6 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %1, i32 noundef 16, i32 noundef %5)
  %7 = tail call noundef i32 @_ZN2rw5Clump12countAtomicsEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %8 = tail call noundef i32 @_ZN2rw5Clump11countLightsEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %9 = tail call noundef i32 @_ZN2rw5Clump12countCamerasEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #5
  store i32 %7, ptr %3, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %8, ptr %10, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %9, ptr %11, align 4, !tbaa !5
  %12 = load i32, ptr @_ZN2rw7versionE, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 208896
  %14 = select i1 %13, i32 12, i32 4
  %15 = tail call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef %1, i32 noundef 1, i32 noundef %14)
  %16 = call noundef i32 @_ZN2rw6Stream7write32EPKvj(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull %3, i32 noundef %14)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %17 = call noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %18 = call noundef i32 @_ZN2rw5Frame5countEv(ptr noundef nonnull align 8 dereferenceable(200) %17)
  store i32 %18, ptr %4, align 8, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = shl nsw i64 %19, 3
  %21 = call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %20, i32 noundef 65552, ptr noundef nonnull @.str.20)
  %22 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %21, ptr %22, align 8, !tbaa !12
  %23 = call noundef ptr @_ZNK2rw5Clump8getFrameEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %24 = call noundef ptr @_ZN2rw13makeFrameListEPNS_5FrameEPS1_(ptr noundef %23, ptr noundef %21)
  call void @_ZN2rw10FrameList_11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull %1)
  %25 = load i32, ptr @_ZN2rw7versionE, align 4, !tbaa !5
  %26 = icmp sgt i32 %25, 197631
  br i1 %26, label %27, label %.loopexit

27:                                               ; preds = %2
  %28 = getelementptr inbounds i8, ptr %0, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %28)
  %.not82 = icmp eq ptr %29, %31
  br i1 %.not82, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %27
  %.061.lcssa = phi i32 [ 16, %27 ], [ %44, %.lr.ph ]
  %32 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef nonnull %1, i32 noundef 26, i32 noundef %.061.lcssa)
  %33 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef nonnull %1, i32 noundef 1, i32 noundef 4)
  %34 = call noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %7)
  %35 = load ptr, ptr %28, align 8, !tbaa !13
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %28)
  %.not7385 = icmp eq ptr %35, %37
  br i1 %.not7385, label %.loopexit, label %.lr.ph88

.lr.ph:                                           ; preds = %27, %.lr.ph
  %38 = phi ptr [ %45, %.lr.ph ], [ %30, %27 ]
  %.06184 = phi i32 [ %44, %.lr.ph ], [ 16, %27 ]
  %.06383 = phi ptr [ %38, %.lr.ph ], [ %29, %27 ]
  %39 = call noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef nonnull %.06383)
  %40 = getelementptr inbounds i8, ptr %39, i64 40
  %41 = load ptr, ptr %40, align 8, !tbaa !19
  %42 = call noundef i32 @_ZN2rw8Geometry13streamGetSizeEv(ptr noundef nonnull align 8 dereferenceable(168) %41)
  %43 = add i32 %.06184, 12
  %44 = add i32 %43, %42
  %45 = load ptr, ptr %38, align 8, !tbaa !18
  %46 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %28)
  %.not = icmp eq ptr %38, %46
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !25

.lr.ph88:                                         ; preds = %._crit_edge, %.lr.ph88
  %47 = phi ptr [ %52, %.lr.ph88 ], [ %36, %._crit_edge ]
  %.07086 = phi ptr [ %47, %.lr.ph88 ], [ %35, %._crit_edge ]
  %48 = call noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef nonnull %.07086)
  %49 = getelementptr inbounds i8, ptr %48, i64 40
  %50 = load ptr, ptr %49, align 8, !tbaa !19
  %51 = call noundef zeroext i1 @_ZN2rw8Geometry11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(168) %50, ptr noundef nonnull %1)
  %52 = load ptr, ptr %47, align 8, !tbaa !18
  %53 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %28)
  %.not73 = icmp eq ptr %47, %53
  br i1 %.not73, label %.loopexit, label %.lr.ph88, !llvm.loop !27

.loopexit:                                        ; preds = %.lr.ph88, %._crit_edge, %2
  %54 = getelementptr inbounds i8, ptr %0, i64 16
  %55 = load ptr, ptr %54, align 8, !tbaa !13
  %56 = load ptr, ptr %55, align 8, !tbaa !18
  %57 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %54)
  %.not7489 = icmp eq ptr %55, %57
  br i1 %.not7489, label %._crit_edge93, label %.lr.ph92

._crit_edge93:                                    ; preds = %.lr.ph92, %.loopexit
  %58 = getelementptr inbounds i8, ptr %0, i64 32
  %59 = load ptr, ptr %58, align 8, !tbaa !28
  %60 = load ptr, ptr %59, align 8, !tbaa !18
  %61 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %58)
  %.not7594 = icmp eq ptr %59, %61
  br i1 %.not7594, label %.critedge77, label %.lr.ph97

.lr.ph92:                                         ; preds = %.loopexit, %.lr.ph92
  %62 = phi ptr [ %65, %.lr.ph92 ], [ %56, %.loopexit ]
  %.06990 = phi ptr [ %62, %.lr.ph92 ], [ %55, %.loopexit ]
  %63 = call noundef ptr @_ZN2rw6Atomic9fromClumpEPNS_6LLLinkE(ptr noundef nonnull %.06990)
  %64 = call noundef zeroext i1 @_ZN2rw6Atomic16streamWriteClumpEPNS_6StreamEPNS_10FrameList_E(ptr noundef nonnull align 8 dereferenceable(136) %63, ptr noundef nonnull %1, ptr noundef nonnull %4)
  %65 = load ptr, ptr %62, align 8, !tbaa !18
  %66 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %54)
  %.not74 = icmp eq ptr %62, %66
  br i1 %.not74, label %._crit_edge93, label %.lr.ph92, !llvm.loop !29

.lr.ph97:                                         ; preds = %._crit_edge93, %74
  %67 = phi ptr [ %78, %74 ], [ %60, %._crit_edge93 ]
  %.06895 = phi ptr [ %67, %74 ], [ %59, %._crit_edge93 ]
  %68 = call noundef ptr @_ZN2rw5Light9fromClumpEPNS_6LLLinkE(ptr noundef nonnull %.06895)
  %69 = call noundef ptr @_ZNK2rw5Light8getFrameEv(ptr noundef nonnull align 8 dereferenceable(120) %68)
  %70 = load ptr, ptr %22, align 8, !tbaa !12
  %71 = load i32, ptr %4, align 8, !tbaa !9
  %72 = call noundef i32 @_ZN2rw11findPointerEPvPS0_i(ptr noundef %69, ptr noundef %70, i32 noundef %71)
  %73 = icmp sgt i32 %72, -1
  br i1 %73, label %74, label %.critedge

74:                                               ; preds = %.lr.ph97
  %75 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef nonnull %1, i32 noundef 1, i32 noundef 4)
  %76 = call noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %72)
  %77 = call noundef zeroext i1 @_ZN2rw5Light11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(120) %68, ptr noundef nonnull %1)
  %78 = load ptr, ptr %67, align 8, !tbaa !18
  %79 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %58)
  %.not75 = icmp eq ptr %67, %79
  br i1 %.not75, label %.critedge77, label %.lr.ph97, !llvm.loop !30

.critedge77:                                      ; preds = %74, %._crit_edge93
  %80 = getelementptr inbounds i8, ptr %0, i64 48
  %81 = load ptr, ptr %80, align 8, !tbaa !31
  %82 = load ptr, ptr %81, align 8, !tbaa !18
  %83 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %80)
  %.not7698 = icmp eq ptr %81, %83
  br i1 %.not7698, label %.critedge80, label %.lr.ph100

.lr.ph100:                                        ; preds = %.critedge77, %91
  %84 = phi ptr [ %95, %91 ], [ %82, %.critedge77 ]
  %.06299 = phi ptr [ %84, %91 ], [ %81, %.critedge77 ]
  %85 = call noundef ptr @_ZN2rw6Camera9fromClumpEPNS_6LLLinkE(ptr noundef nonnull %.06299)
  %86 = call noundef ptr @_ZNK2rw6Camera8getFrameEv(ptr noundef nonnull align 8 dereferenceable(600) %85)
  %87 = load ptr, ptr %22, align 8, !tbaa !12
  %88 = load i32, ptr %4, align 8, !tbaa !9
  %89 = call noundef i32 @_ZN2rw11findPointerEPvPS0_i(ptr noundef %86, ptr noundef %87, i32 noundef %88)
  %90 = icmp sgt i32 %89, -1
  br i1 %90, label %91, label %.critedge

91:                                               ; preds = %.lr.ph100
  %92 = call noundef zeroext i1 @_ZN2rw16writeChunkHeaderEPNS_6StreamEii(ptr noundef nonnull %1, i32 noundef 1, i32 noundef 4)
  %93 = call noundef i32 @_ZN2rw6Stream8writeI32Ei(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %89)
  %94 = call noundef zeroext i1 @_ZN2rw6Camera11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(600) %85, ptr noundef nonnull %1)
  %95 = load ptr, ptr %84, align 8, !tbaa !18
  %96 = call noundef ptr @_ZN2rw8LinkList3endEv(ptr noundef nonnull align 8 dereferenceable(16) %80)
  %.not76 = icmp eq ptr %84, %96
  br i1 %.not76, label %.critedge80, label %.lr.ph100, !llvm.loop !32

.critedge80:                                      ; preds = %91, %.critedge77
  %97 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !33
  %98 = load ptr, ptr %22, align 8, !tbaa !12
  call void %97(ptr noundef %98)
  call void @_ZN2rw10PluginList11streamWriteEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24) @_ZN2rw5Clump9s_plglistE, ptr noundef nonnull %1, ptr noundef nonnull %0)
  br label %.critedge

.critedge:                                        ; preds = %.lr.ph97, %.lr.ph100, %.critedge80
  %.6 = phi i1 [ true, %.critedge80 ], [ false, %.lr.ph100 ], [ false, %.lr.ph97 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #5
  ret i1 %.6
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw5Clump13streamGetSizeEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN2rw5Clump12countAtomicsEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw5Clump11countLightsEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw5Clump12countCamerasEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2 align 2

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

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

declare noundef ptr @_ZN2rw13makeFrameListEPNS_5FrameEPS1_(ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @_ZN2rw10FrameList_11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) local_unnamed_addr #4

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2rw6Atomic16streamWriteClumpEPNS_6StreamEPNS_10FrameList_E(ptr noundef nonnull align 8 dereferenceable(136), ptr noundef, ptr noundef) local_unnamed_addr #3 align 2

declare noundef i32 @_ZN2rw11findPointerEPvPS0_i(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw5Light8getFrameEv(ptr noundef nonnull align 8 dereferenceable(120)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK2rw6Camera8getFrameEv(ptr noundef nonnull align 8 dereferenceable(600)) local_unnamed_addr #2 align 2

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

declare void @_ZN2rw10PluginList11streamWriteEPNS_6StreamEPv(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { "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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN2rw10FrameList_E", !6, i64 0, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!14, !11, i64 16}
!14 = !{!"_ZTSN2rw5ClumpE", !15, i64 0, !16, i64 16, !16, i64 32, !16, i64 48, !11, i64 64, !17, i64 72}
!15 = !{!"_ZTSN2rw6ObjectE", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !11, i64 8}
!16 = !{!"_ZTSN2rw8LinkListE", !17, i64 0}
!17 = !{!"_ZTSN2rw6LLLinkE", !11, i64 0, !11, i64 8}
!18 = !{!17, !11, i64 0}
!19 = !{!20, !11, i64 40}
!20 = !{!"_ZTSN2rw6AtomicE", !21, i64 0, !11, i64 40, !22, i64 48, !22, i64 64, !11, i64 80, !17, i64 88, !11, i64 104, !11, i64 112, !11, i64 120, !11, i64 128}
!21 = !{!"_ZTSN2rw15ObjectWithFrameE", !15, i64 0, !17, i64 16, !11, i64 32}
!22 = !{!"_ZTSN2rw6SphereE", !23, i64 0, !24, i64 12}
!23 = !{!"_ZTSN2rw3V3dE", !24, i64 0, !24, i64 4, !24, i64 8}
!24 = !{!"float", !7, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = distinct !{!27, !26}
!28 = !{!14, !11, i64 32}
!29 = distinct !{!29, !26}
!30 = distinct !{!30, !26}
!31 = !{!14, !11, i64 48}
!32 = distinct !{!32, !26}
!33 = !{!34, !11, i64 16}
!34 = !{!"_ZTSN2rw15MemoryFunctionsE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}


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