; LLVM IR from aap/librw :: tools/ska2anm (ska2anm)

; 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"

%"class.rw::StreamFile" = type { %"class.rw::Stream", ptr }
%"class.rw::Stream" = type { ptr }

@argv0 = external dso_local global ptr, align 8
@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZN2rw7versionE = external global i32, align 4
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5usagev() #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca %"class.rw::StreamFile", align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %16 = call noundef i32 @_ZN2rw6Engine4initEPNS_15MemoryFunctionsE(ptr noundef null)
  call void @_ZN2rw19registerHAnimPluginEv()
  %17 = call noundef i32 @_ZN2rw6Engine4openEPNS_16EngineOpenParamsE(ptr noundef null)
  %18 = call noundef i32 @_ZN2rw6Engine5startEv()
  %19 = load ptr, ptr @argv0, align 8, !tbaa !9
  %20 = icmp ne ptr %19, null
  br i1 %20, label %25, label %21

21:                                               ; preds = %2
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  store ptr %23, ptr @argv0, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br label %25

25:                                               ; preds = %21, %2
  %26 = phi i1 [ true, %2 ], [ %24, %21 ]
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = getelementptr inbounds ptr, ptr %27, i32 1
  store ptr %28, ptr %5, align 8, !tbaa !9
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = add nsw i32 %29, -1
  store i32 %30, ptr %4, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %120, %25
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = getelementptr inbounds ptr, ptr %32, i64 0
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %51

36:                                               ; preds = %31
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = getelementptr inbounds ptr, ptr %37, i64 0
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %39, i64 0
  %41 = load i8, ptr %40, align 1, !tbaa !11
  %42 = sext i8 %41 to i32
  %43 = icmp eq i32 %42, 45
  br i1 %43, label %44, label %51

44:                                               ; preds = %36
  %45 = load ptr, ptr %5, align 8, !tbaa !9
  %46 = getelementptr inbounds ptr, ptr %45, i64 0
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = getelementptr inbounds i8, ptr %47, i64 1
  %49 = load i8, ptr %48, align 1, !tbaa !11
  %50 = icmp ne i8 %49, 0
  br label %51

51:                                               ; preds = %44, %36, %31
  %52 = phi i1 [ false, %36 ], [ false, %31 ], [ %50, %44 ]
  br i1 %52, label %53, label %125

53:                                               ; preds = %51
  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 1, ptr %8) #6
  %54 = load ptr, ptr %5, align 8, !tbaa !9
  %55 = getelementptr inbounds ptr, ptr %54, i64 0
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds i8, ptr %56, i64 1
  store ptr %57, ptr %6, align 8, !tbaa !9
  %58 = load ptr, ptr %6, align 8, !tbaa !9
  %59 = getelementptr inbounds i8, ptr %58, i64 0
  %60 = load i8, ptr %59, align 1, !tbaa !11
  %61 = sext i8 %60 to i32
  %62 = icmp eq i32 %61, 45
  br i1 %62, label %63, label %74

63:                                               ; preds = %53
  %64 = load ptr, ptr %6, align 8, !tbaa !9
  %65 = getelementptr inbounds i8, ptr %64, i64 1
  %66 = load i8, ptr %65, align 1, !tbaa !11
  %67 = sext i8 %66 to i32
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %74

69:                                               ; preds = %63
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = add nsw i32 %70, -1
  store i32 %71, ptr %4, align 4, !tbaa !5
  %72 = load ptr, ptr %5, align 8, !tbaa !9
  %73 = getelementptr inbounds ptr, ptr %72, i32 1
  store ptr %73, ptr %5, align 8, !tbaa !9
  store i32 2, ptr %9, align 4
  br label %117

74:                                               ; preds = %63, %53
  store i8 0, ptr %8, align 1, !tbaa !11
  br label %75

75:                                               ; preds = %115, %74
  %76 = load ptr, ptr %6, align 8, !tbaa !9
  %77 = load i8, ptr %76, align 1, !tbaa !11
  %78 = icmp ne i8 %77, 0
  br i1 %78, label %79, label %84

79:                                               ; preds = %75
  %80 = load ptr, ptr %6, align 8, !tbaa !9
  %81 = getelementptr inbounds i8, ptr %80, i32 1
  store ptr %81, ptr %6, align 8, !tbaa !9
  %82 = load i8, ptr %80, align 1, !tbaa !11
  store i8 %82, ptr %8, align 1, !tbaa !11
  %83 = icmp ne i8 %82, 0
  br label %84

84:                                               ; preds = %79, %75
  %85 = phi i1 [ false, %75 ], [ %83, %79 ]
  br i1 %85, label %86, label %116

86:                                               ; preds = %84
  %87 = load i8, ptr %8, align 1, !tbaa !11
  %88 = sext i8 %87 to i32
  switch i32 %88, label %114 [
    i32 118, label %89
  ]

89:                                               ; preds = %86
  %90 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %90, ptr %7, align 8, !tbaa !9
  store ptr @.str.2, ptr %6, align 8, !tbaa !9
  %91 = load ptr, ptr %7, align 8, !tbaa !9
  %92 = load i8, ptr %91, align 1, !tbaa !11
  %93 = icmp ne i8 %92, 0
  br i1 %93, label %94, label %96

94:                                               ; preds = %89
  %95 = load ptr, ptr %7, align 8, !tbaa !9
  br label %111

96:                                               ; preds = %89
  %97 = load ptr, ptr %5, align 8, !tbaa !9
  %98 = getelementptr inbounds ptr, ptr %97, i64 1
  %99 = load ptr, ptr %98, align 8, !tbaa !9
  %100 = icmp ne ptr %99, null
  br i1 %100, label %101, label %107

101:                                              ; preds = %96
  %102 = load i32, ptr %4, align 4, !tbaa !5
  %103 = add nsw i32 %102, -1
  store i32 %103, ptr %4, align 4, !tbaa !5
  %104 = load ptr, ptr %5, align 8, !tbaa !9
  %105 = getelementptr inbounds ptr, ptr %104, i32 1
  store ptr %105, ptr %5, align 8, !tbaa !9
  %106 = load ptr, ptr %105, align 8, !tbaa !9
  br label %109

107:                                              ; preds = %96
  call void @_Z5usagev()
  call void @abort() #7
  unreachable

108:                                              ; No predecessors!
  br label %109

109:                                              ; preds = %108, %101
  %110 = phi ptr [ %106, %101 ], [ null, %108 ]
  br label %111

111:                                              ; preds = %109, %94
  %112 = phi ptr [ %95, %94 ], [ %110, %109 ]
  %113 = call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef %112, ptr noundef @.str.3, ptr noundef @_ZN2rw7versionE) #6
  br label %115

114:                                              ; preds = %86
  call void @_Z5usagev()
  br label %115

115:                                              ; preds = %114, %111
  br label %75, !llvm.loop !12

116:                                              ; preds = %84
  store ptr null, ptr %7, align 8, !tbaa !9
  store i32 0, ptr %9, align 4
  br label %117

117:                                              ; preds = %116, %69
  call void @llvm.lifetime.end.p0(i64 1, 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
  %118 = load i32, ptr %9, align 4
  switch i32 %118, label %229 [
    i32 0, label %119
    i32 2, label %125
  ]

119:                                              ; preds = %117
  br label %120

120:                                              ; preds = %119
  %121 = load i32, ptr %4, align 4, !tbaa !5
  %122 = add nsw i32 %121, -1
  store i32 %122, ptr %4, align 4, !tbaa !5
  %123 = load ptr, ptr %5, align 8, !tbaa !9
  %124 = getelementptr inbounds ptr, ptr %123, i32 1
  store ptr %124, ptr %5, align 8, !tbaa !9
  br label %31, !llvm.loop !14

125:                                              ; preds = %117, %51
  %126 = load i32, ptr %4, align 4, !tbaa !5
  %127 = icmp slt i32 %126, 1
  br i1 %127, label %128, label %129

128:                                              ; preds = %125
  call void @_Z5usagev()
  br label %129

129:                                              ; preds = %128, %125
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  call void @_ZN2rw10StreamFileC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10)
  %130 = load ptr, ptr %5, align 8, !tbaa !9
  %131 = getelementptr inbounds ptr, ptr %130, i64 0
  %132 = load ptr, ptr %131, align 8, !tbaa !9
  %133 = invoke noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef %132, ptr noundef @.str.4)
          to label %134 unwind label %142

134:                                              ; preds = %129
  %135 = icmp ne ptr %133, null
  br i1 %135, label %146, label %136

136:                                              ; preds = %134
  %137 = load ptr, ptr @stderr, align 8, !tbaa !9
  %138 = load ptr, ptr %5, align 8, !tbaa !9
  %139 = getelementptr inbounds ptr, ptr %138, i64 0
  %140 = load ptr, ptr %139, align 8, !tbaa !9
  %141 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %137, ptr noundef @.str.5, ptr noundef %140) #6
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %221

142:                                              ; preds = %129
  %143 = landingpad { ptr, i32 }
          cleanup
  %144 = extractvalue { ptr, i32 } %143, 0
  store ptr %144, ptr %11, align 8
  %145 = extractvalue { ptr, i32 } %143, 1
  store i32 %145, ptr %12, align 4
  br label %223

146:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %147 = invoke noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %10)
          to label %148 unwind label %158

148:                                              ; preds = %146
  store i32 %147, ptr %13, align 4, !tbaa !5
  invoke void @_ZN2rw10StreamFile4seekEii(ptr noundef nonnull align 8 dereferenceable(16) %10, i32 noundef 0, i32 noundef 0)
          to label %149 unwind label %158

149:                                              ; preds = %148
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  store ptr null, ptr %14, align 8, !tbaa !9
  %150 = load i32, ptr %13, align 4, !tbaa !5
  %151 = icmp eq i32 %150, 27
  br i1 %151, label %152, label %167

152:                                              ; preds = %149
  %153 = invoke noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef %10, i32 noundef 27, ptr noundef null, ptr noundef null)
          to label %154 unwind label %162

154:                                              ; preds = %152
  br i1 %153, label %155, label %166

155:                                              ; preds = %154
  %156 = invoke noundef ptr @_ZN2rw9Animation10streamReadEPNS_6StreamE(ptr noundef %10)
          to label %157 unwind label %162

157:                                              ; preds = %155
  store ptr %156, ptr %14, align 8, !tbaa !9
  br label %166

158:                                              ; preds = %148, %146
  %159 = landingpad { ptr, i32 }
          cleanup
  %160 = extractvalue { ptr, i32 } %159, 0
  store ptr %160, ptr %11, align 8
  %161 = extractvalue { ptr, i32 } %159, 1
  store i32 %161, ptr %12, align 4
  br label %220

162:                                              ; preds = %170, %167, %155, %152
  %163 = landingpad { ptr, i32 }
          cleanup
  %164 = extractvalue { ptr, i32 } %163, 0
  store ptr %164, ptr %11, align 8
  %165 = extractvalue { ptr, i32 } %163, 1
  store i32 %165, ptr %12, align 4
  br label %219

166:                                              ; preds = %157, %154
  br label %170

167:                                              ; preds = %149
  %168 = invoke noundef ptr @_ZN2rw9Animation16streamReadLegacyEPNS_6StreamE(ptr noundef %10)
          to label %169 unwind label %162

169:                                              ; preds = %167
  store ptr %168, ptr %14, align 8, !tbaa !9
  br label %170

170:                                              ; preds = %169, %166
  invoke void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
          to label %171 unwind label %162

171:                                              ; preds = %170
  %172 = load ptr, ptr %14, align 8, !tbaa !9
  %173 = icmp eq ptr %172, null
  br i1 %173, label %174, label %177

174:                                              ; preds = %171
  %175 = load ptr, ptr @stderr, align 8, !tbaa !9
  %176 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %175, ptr noundef @.str.6) #6
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %218

177:                                              ; preds = %171
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %178 = load i32, ptr %4, align 4, !tbaa !5
  %179 = icmp sgt i32 %178, 1
  br i1 %179, label %180, label %184

180:                                              ; preds = %177
  %181 = load ptr, ptr %5, align 8, !tbaa !9
  %182 = getelementptr inbounds ptr, ptr %181, i64 1
  %183 = load ptr, ptr %182, align 8, !tbaa !9
  store ptr %183, ptr %15, align 8, !tbaa !9
  br label %190

184:                                              ; preds = %177
  %185 = load i32, ptr %13, align 4, !tbaa !5
  %186 = icmp eq i32 %185, 27
  br i1 %186, label %187, label %188

187:                                              ; preds = %184
  store ptr @.str.7, ptr %15, align 8, !tbaa !9
  br label %189

188:                                              ; preds = %184
  store ptr @.str.8, ptr %15, align 8, !tbaa !9
  br label %189

189:                                              ; preds = %188, %187
  br label %190

190:                                              ; preds = %189, %180
  %191 = load ptr, ptr %15, align 8, !tbaa !9
  %192 = invoke noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef %191, ptr noundef @.str.9)
          to label %193 unwind label %199

193:                                              ; preds = %190
  %194 = icmp ne ptr %192, null
  br i1 %194, label %203, label %195

195:                                              ; preds = %193
  %196 = load ptr, ptr @stderr, align 8, !tbaa !9
  %197 = load ptr, ptr %15, align 8, !tbaa !9
  %198 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %196, ptr noundef @.str.5, ptr noundef %197) #6
  store i32 1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %217

199:                                              ; preds = %214, %210, %206, %190
  %200 = landingpad { ptr, i32 }
          cleanup
  %201 = extractvalue { ptr, i32 } %200, 0
  store ptr %201, ptr %11, align 8
  %202 = extractvalue { ptr, i32 } %200, 1
  store i32 %202, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %219

203:                                              ; preds = %193
  %204 = load i32, ptr %13, align 4, !tbaa !5
  %205 = icmp eq i32 %204, 27
  br i1 %205, label %206, label %210

206:                                              ; preds = %203
  %207 = load ptr, ptr %14, align 8, !tbaa !9
  %208 = invoke noundef zeroext i1 @_ZN2rw9Animation17streamWriteLegacyEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(40) %207, ptr noundef %10)
          to label %209 unwind label %199

209:                                              ; preds = %206
  br label %214

210:                                              ; preds = %203
  %211 = load ptr, ptr %14, align 8, !tbaa !9
  %212 = invoke noundef zeroext i1 @_ZN2rw9Animation11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(40) %211, ptr noundef %10)
          to label %213 unwind label %199

213:                                              ; preds = %210
  br label %214

214:                                              ; preds = %213, %209
  %215 = load ptr, ptr %14, align 8, !tbaa !9
  invoke void @_ZN2rw9Animation7destroyEv(ptr noundef nonnull align 8 dereferenceable(40) %215)
          to label %216 unwind label %199

216:                                              ; preds = %214
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %217

217:                                              ; preds = %216, %195
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %218

218:                                              ; preds = %217, %174
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %221

219:                                              ; preds = %199, %162
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %220

220:                                              ; preds = %219, %158
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %223

221:                                              ; preds = %218, %136
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  %222 = load i32, ptr %3, align 4
  ret i32 %222

223:                                              ; preds = %220, %142
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  br label %224

224:                                              ; preds = %223
  %225 = load ptr, ptr %11, align 8
  %226 = load i32, ptr %12, align 4
  %227 = insertvalue { ptr, i32 } poison, ptr %225, 0
  %228 = insertvalue { ptr, i32 } %227, i32 %226, 1
  resume { ptr, i32 } %228

229:                                              ; preds = %117
  unreachable
}

declare noundef i32 @_ZN2rw6Engine4initEPNS_15MemoryFunctionsE(ptr noundef) #3

declare void @_ZN2rw19registerHAnimPluginEv() #3

declare noundef i32 @_ZN2rw6Engine4openEPNS_16EngineOpenParamsE(ptr noundef) #3

declare noundef i32 @_ZN2rw6Engine5startEv() #3

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

; Function Attrs: nounwind
declare i32 @__isoc99_sscanf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: noreturn nounwind
declare void @abort() #5

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

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

declare noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) #3

declare i32 @__gxx_personality_v0(...)

declare noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8)) #3

declare void @_ZN2rw10StreamFile4seekEii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) unnamed_addr #3

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

declare noundef ptr @_ZN2rw9Animation10streamReadEPNS_6StreamE(ptr noundef) #3

declare noundef ptr @_ZN2rw9Animation16streamReadLegacyEPNS_6StreamE(ptr noundef) #3

declare void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

declare noundef zeroext i1 @_ZN2rw9Animation17streamWriteLegacyEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) #3

declare noundef zeroext i1 @_ZN2rw9Animation11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) #3

declare void @_ZN2rw9Animation7destroyEv(ptr noundef nonnull align 8 dereferenceable(40)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress norecurse 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { noreturn 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 #6 = { nounwind }
attributes #7 = { noreturn 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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"

%"class.rw::StreamFile" = type { %"class.rw::Stream", ptr }
%"class.rw::Stream" = type { ptr }

@argv0 = external dso_local local_unnamed_addr global ptr, align 8
@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZN2rw7versionE = external global i32, align 4
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5usagev() local_unnamed_addr #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.rw::StreamFile", align 8
  %4 = tail call noundef i32 @_ZN2rw6Engine4initEPNS_15MemoryFunctionsE(ptr noundef null)
  tail call void @_ZN2rw19registerHAnimPluginEv()
  %5 = tail call noundef i32 @_ZN2rw6Engine4openEPNS_16EngineOpenParamsE(ptr noundef null)
  %6 = tail call noundef i32 @_ZN2rw6Engine5startEv()
  %7 = load ptr, ptr @argv0, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %8, label %10

8:                                                ; preds = %2
  %9 = load ptr, ptr %1, align 8, !tbaa !5
  store ptr %9, ptr @argv0, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %8, %2
  %.05295 = getelementptr inbounds i8, ptr %1, i64 8
  %.05596 = add nsw i32 %0, -1
  %11 = load ptr, ptr %.05295, align 8, !tbaa !5
  %.not6597 = icmp eq ptr %11, null
  br i1 %.not6597, label %.critedge, label %.lr.ph102

.critedge2.loopexit:                              ; preds = %39
  %.052 = getelementptr inbounds i8, ptr %.3, i64 8
  %.055 = add nsw i32 %.358, -1
  %12 = load ptr, ptr %.052, align 8, !tbaa !5
  %.not65 = icmp eq ptr %12, null
  br i1 %.not65, label %.critedge, label %.lr.ph102, !llvm.loop !9

.lr.ph102:                                        ; preds = %10, %.critedge2.loopexit
  %13 = phi ptr [ %12, %.critedge2.loopexit ], [ %11, %10 ]
  %.055101 = phi i32 [ %.055, %.critedge2.loopexit ], [ %.05596, %10 ]
  %.052100 = phi ptr [ %.052, %.critedge2.loopexit ], [ %.05295, %10 ]
  %.pn7599 = phi ptr [ %.3, %.critedge2.loopexit ], [ %1, %10 ]
  %.055.in98 = phi i32 [ %.358, %.critedge2.loopexit ], [ %0, %10 ]
  %14 = load i8, ptr %13, align 1, !tbaa !11
  %15 = icmp eq i8 %14, 45
  br i1 %15, label %16, label %.critedge

16:                                               ; preds = %.lr.ph102
  %17 = getelementptr inbounds i8, ptr %13, i64 1
  %18 = load i8, ptr %17, align 1, !tbaa !11
  switch i8 %18, label %.lr.ph.preheader [
    i8 0, label %.critedge
    i8 45, label %19
  ]

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %13, i64 2
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = icmp eq i8 %21, 0
  br i1 %22, label %.critedge2.thread, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %16, %19
  br label %.lr.ph

.critedge2.thread:                                ; preds = %19
  %23 = add nsw i32 %.055.in98, -2
  %24 = getelementptr inbounds i8, ptr %.pn7599, i64 16
  br label %.critedge

.lr.ph:                                           ; preds = %.lr.ph.preheader, %39
  %25 = phi i8 [ %40, %39 ], [ %18, %.lr.ph.preheader ]
  %.05093 = phi ptr [ %.151, %39 ], [ %17, %.lr.ph.preheader ]
  %.15392 = phi ptr [ %.3, %39 ], [ %.052100, %.lr.ph.preheader ]
  %.15691 = phi i32 [ %.358, %39 ], [ %.055101, %.lr.ph.preheader ]
  %26 = getelementptr inbounds i8, ptr %.05093, i64 1
  %cond = icmp eq i8 %25, 118
  br i1 %cond, label %27, label %38

27:                                               ; preds = %.lr.ph
  %28 = load i8, ptr %26, align 1, !tbaa !11
  %.not68 = icmp eq i8 %28, 0
  br i1 %.not68, label %29, label %35

29:                                               ; preds = %27
  %30 = getelementptr inbounds i8, ptr %.15392, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !5
  %.not69 = icmp eq ptr %31, null
  br i1 %.not69, label %34, label %32

32:                                               ; preds = %29
  %33 = add nsw i32 %.15691, -1
  br label %35

34:                                               ; preds = %29
  tail call void @_Z5usagev()
  tail call void @abort() #6
  unreachable

35:                                               ; preds = %27, %32
  %.257 = phi i32 [ %33, %32 ], [ %.15691, %27 ]
  %.254 = phi ptr [ %30, %32 ], [ %.15392, %27 ]
  %36 = phi ptr [ %31, %32 ], [ %26, %27 ]
  %37 = tail call i32 (ptr, ptr, ...) @__isoc99_sscanf(ptr noundef nonnull %36, ptr noundef nonnull @.str.3, ptr noundef nonnull @_ZN2rw7versionE) #7
  br label %39

38:                                               ; preds = %.lr.ph
  tail call void @_Z5usagev()
  br label %39

39:                                               ; preds = %38, %35
  %.358 = phi i32 [ %.257, %35 ], [ %.15691, %38 ]
  %.3 = phi ptr [ %.254, %35 ], [ %.15392, %38 ]
  %.151 = phi ptr [ @.str.2, %35 ], [ %26, %38 ]
  %40 = load i8, ptr %.151, align 1, !tbaa !11
  %.not67 = icmp eq i8 %40, 0
  br i1 %.not67, label %.critedge2.loopexit, label %.lr.ph, !llvm.loop !12

.critedge:                                        ; preds = %.critedge2.loopexit, %.lr.ph102, %16, %10, %.critedge2.thread
  %.560 = phi i32 [ %23, %.critedge2.thread ], [ %.05596, %10 ], [ %.055, %.critedge2.loopexit ], [ %.055101, %.lr.ph102 ], [ %.055101, %16 ]
  %.5 = phi ptr [ %24, %.critedge2.thread ], [ %.05295, %10 ], [ %.052, %.critedge2.loopexit ], [ %.052100, %.lr.ph102 ], [ %.052100, %16 ]
  %41 = icmp slt i32 %.560, 1
  br i1 %41, label %42, label %43

42:                                               ; preds = %.critedge
  tail call void @_Z5usagev()
  br label %43

43:                                               ; preds = %42, %.critedge
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  call void @_ZN2rw10StreamFileC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3)
  %44 = load ptr, ptr %.5, align 8, !tbaa !5
  %45 = invoke noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef %44, ptr noundef nonnull @.str.4)
          to label %46 unwind label %51

46:                                               ; preds = %43
  %.not70 = icmp eq ptr %45, null
  br i1 %.not70, label %47, label %53

47:                                               ; preds = %46
  %48 = load ptr, ptr @stderr, align 8, !tbaa !5
  %49 = load ptr, ptr %.5, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef nonnull @.str.5, ptr noundef %49) #8
  br label %95

51:                                               ; preds = %43
  %52 = landingpad { ptr, i32 }
          cleanup
  br label %96

53:                                               ; preds = %46
  %54 = invoke noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %55 unwind label %63

55:                                               ; preds = %53
  invoke void @_ZN2rw10StreamFile4seekEii(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef 0, i32 noundef 0)
          to label %56 unwind label %63

56:                                               ; preds = %55
  %57 = icmp eq i32 %54, 27
  br i1 %57, label %58, label %67

58:                                               ; preds = %56
  %59 = invoke noundef zeroext i1 @_ZN2rw9findChunkEPNS_6StreamEjPjS2_(ptr noundef nonnull %3, i32 noundef 27, ptr noundef null, ptr noundef null)
          to label %60 unwind label %65

60:                                               ; preds = %58
  br i1 %59, label %61, label %69

61:                                               ; preds = %60
  %62 = invoke noundef ptr @_ZN2rw9Animation10streamReadEPNS_6StreamE(ptr noundef nonnull %3)
          to label %69 unwind label %65

63:                                               ; preds = %55, %53
  %64 = landingpad { ptr, i32 }
          cleanup
  br label %96

65:                                               ; preds = %69, %67, %61, %58
  %66 = landingpad { ptr, i32 }
          cleanup
  br label %96

67:                                               ; preds = %56
  %68 = invoke noundef ptr @_ZN2rw9Animation16streamReadLegacyEPNS_6StreamE(ptr noundef nonnull %3)
          to label %69 unwind label %65

69:                                               ; preds = %67, %61, %60
  %.041 = phi ptr [ null, %60 ], [ %62, %61 ], [ %68, %67 ]
  invoke void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16) %3)
          to label %70 unwind label %65

70:                                               ; preds = %69
  %71 = icmp eq ptr %.041, null
  br i1 %71, label %72, label %75

72:                                               ; preds = %70
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef nonnull @.str.6) #8
  br label %95

75:                                               ; preds = %70
  %76 = icmp sgt i32 %.560, 1
  br i1 %76, label %77, label %80

77:                                               ; preds = %75
  %78 = getelementptr inbounds i8, ptr %.5, i64 8
  %79 = load ptr, ptr %78, align 8, !tbaa !5
  br label %81

80:                                               ; preds = %75
  %.str.7..str.8 = select i1 %57, ptr @.str.7, ptr @.str.8
  br label %81

81:                                               ; preds = %80, %77
  %.0 = phi ptr [ %79, %77 ], [ %.str.7..str.8, %80 ]
  %82 = invoke noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef %.0, ptr noundef nonnull @.str.9)
          to label %83 unwind label %87

83:                                               ; preds = %81
  %.not71 = icmp eq ptr %82, null
  br i1 %.not71, label %84, label %89

84:                                               ; preds = %83
  %85 = load ptr, ptr @stderr, align 8, !tbaa !5
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef nonnull @.str.5, ptr noundef %.0) #8
  br label %95

87:                                               ; preds = %94, %92, %90, %81
  %88 = landingpad { ptr, i32 }
          cleanup
  br label %96

89:                                               ; preds = %83
  br i1 %57, label %90, label %92

90:                                               ; preds = %89
  %91 = invoke noundef zeroext i1 @_ZN2rw9Animation17streamWriteLegacyEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(40) %.041, ptr noundef nonnull %3)
          to label %94 unwind label %87

92:                                               ; preds = %89
  %93 = invoke noundef zeroext i1 @_ZN2rw9Animation11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(40) %.041, ptr noundef nonnull %3)
          to label %94 unwind label %87

94:                                               ; preds = %92, %90
  invoke void @_ZN2rw9Animation7destroyEv(ptr noundef nonnull align 8 dereferenceable(40) %.041)
          to label %95 unwind label %87

95:                                               ; preds = %72, %94, %84, %47
  %.2 = phi i32 [ 1, %47 ], [ 1, %72 ], [ 1, %84 ], [ 0, %94 ]
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  ret i32 %.2

96:                                               ; preds = %63, %87, %65, %51
  %.pn.pn.pn = phi { ptr, i32 } [ %52, %51 ], [ %64, %63 ], [ %88, %87 ], [ %66, %65 ]
  call void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  resume { ptr, i32 } %.pn.pn.pn
}

declare noundef i32 @_ZN2rw6Engine4initEPNS_15MemoryFunctionsE(ptr noundef) local_unnamed_addr #3

declare void @_ZN2rw19registerHAnimPluginEv() local_unnamed_addr #3

declare noundef i32 @_ZN2rw6Engine4openEPNS_16EngineOpenParamsE(ptr noundef) local_unnamed_addr #3

declare noundef i32 @_ZN2rw6Engine5startEv() local_unnamed_addr #3

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

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

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #5

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

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

declare noundef ptr @_ZN2rw10StreamFile4openEPKcS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

declare noundef i32 @_ZN2rw6Stream7readU32Ev(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

declare void @_ZN2rw10StreamFile4seekEii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) unnamed_addr #3

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

declare noundef ptr @_ZN2rw9Animation10streamReadEPNS_6StreamE(ptr noundef) local_unnamed_addr #3

declare noundef ptr @_ZN2rw9Animation16streamReadLegacyEPNS_6StreamE(ptr noundef) local_unnamed_addr #3

declare void @_ZN2rw10StreamFile5closeEv(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

declare noundef zeroext i1 @_ZN2rw9Animation17streamWriteLegacyEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) local_unnamed_addr #3

declare noundef zeroext i1 @_ZN2rw9Animation11streamWriteEPNS_6StreamE(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef) local_unnamed_addr #3

declare void @_ZN2rw9Animation7destroyEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw6StreamD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress norecurse 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 = { "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { noreturn 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 #6 = { noreturn nounwind }
attributes #7 = { nounwind }
attributes #8 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}


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