; LLVM IR from aap/librw :: src/engine.ll (ZN2rw6Engine4openEPNS_16EngineOpenParamsE)

; 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::Device" = type { float, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.rw::Error" = type { i32, i32 }
%"struct.rw::Engine" = type { ptr, ptr, %"struct.rw::LinkList", %"struct.rw::FileFunctions", [13 x ptr], %"struct.rw::Device", ptr }
%"struct.rw::FileFunctions" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.rw::Driver" = type { ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@_ZN2rw6engineE = external dso_local global ptr, align 8
@_ZN2rw6Engine9s_plglistE = external dso_local global %"struct.rw::PluginList", align 8
@_ZN2rw6Engine5stateE = external dso_local global i32, align 4
@_ZN2rw6Driver9s_plglistE = external dso_local global [13 x %"struct.rw::PluginList"], align 16
@stderr = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [74 x i8], align 1
@_ZN2rw4null12renderdeviceE = external dso_local global %"struct.rw::Device", align 8
@.str.7 = external hidden unnamed_addr constant [74 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN2rw6Engine4openEPNS_16EngineOpenParamsE(ptr noundef %0) #4 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca %"struct.rw::Error", align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %11, label %8

8:                                                ; preds = %1
  %9 = load i32, ptr @_ZN2rw6Engine5stateE, align 4, !tbaa !9
  %10 = icmp ne i32 %9, 1
  br i1 %10, label %11, label %21

11:                                               ; preds = %8, %1
  br label %12

12:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %13 = getelementptr inbounds %"struct.rw::Error", ptr %4, i32 0, i32 0
  store i32 0, ptr %13, align 4, !tbaa !11
  %14 = getelementptr inbounds %"struct.rw::Error", ptr %4, i32 0, i32 1
  store i32 -2147483640, ptr %14, align 4, !tbaa !14
  %15 = load ptr, ptr @stderr, align 8, !tbaa !5
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef 249) #7
  %17 = load ptr, ptr @stderr, align 8, !tbaa !5
  %18 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483640)
  %19 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %17, ptr noundef @.str.5, ptr noundef %18) #7
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  br label %20

20:                                               ; preds = %12
  store i32 0, ptr %2, align 4
  br label %155

21:                                               ; preds = %8
  %22 = load i32, ptr @_ZN2rw6Engine9s_plglistE, align 8, !tbaa !15
  %23 = sext i32 %22 to i64
  %24 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %23, i32 noundef 262144, ptr noundef @.str.6)
  store ptr %24, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %25 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.rw::Engine", ptr %25, i32 0, i32 0
  store ptr null, ptr %26, align 8, !tbaa !19
  %27 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.rw::Engine", ptr %27, i32 0, i32 1
  store ptr null, ptr %28, align 8, !tbaa !24
  %29 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.rw::Engine", ptr %29, i32 0, i32 3
  %31 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %30, i32 0, i32 0
  store ptr @fopen, ptr %31, align 8, !tbaa !25
  %32 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.rw::Engine", ptr %32, i32 0, i32 3
  %34 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %33, i32 0, i32 1
  store ptr @fclose, ptr %34, align 8, !tbaa !26
  %35 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.rw::Engine", ptr %35, i32 0, i32 3
  %37 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %36, i32 0, i32 2
  store ptr @fseek, ptr %37, align 8, !tbaa !27
  %38 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.rw::Engine", ptr %38, i32 0, i32 3
  %40 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %39, i32 0, i32 3
  store ptr @ftell, ptr %40, align 8, !tbaa !28
  %41 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.rw::Engine", ptr %41, i32 0, i32 3
  %43 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %42, i32 0, i32 4
  store ptr @fread, ptr %43, align 8, !tbaa !29
  %44 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %45 = getelementptr inbounds %"struct.rw::Engine", ptr %44, i32 0, i32 3
  %46 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %45, i32 0, i32 5
  store ptr @fwrite, ptr %46, align 8, !tbaa !30
  %47 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.rw::Engine", ptr %47, i32 0, i32 3
  %49 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %48, i32 0, i32 6
  store ptr @feof, ptr %49, align 8, !tbaa !31
  %50 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %51 = getelementptr inbounds %"struct.rw::Engine", ptr %50, i32 0, i32 5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %51, ptr align 8 @_ZN2rw4null12renderdeviceE, i64 136, i1 false), !tbaa.struct !32
  %52 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.rw::Engine", ptr %52, i32 0, i32 5
  %54 = getelementptr inbounds %"struct.rw::Device", ptr %53, i32 0, i32 17
  %55 = load ptr, ptr %54, align 8, !tbaa !34
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = call noundef i32 %55(i32 noundef 2, ptr noundef %56, i32 noundef 0)
  %58 = call noundef ptr @_ZN2rw11ObjPipeline6createEv()
  %59 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.rw::Engine", ptr %59, i32 0, i32 6
  store ptr %58, ptr %60, align 8, !tbaa !35
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  store i32 0, ptr %5, align 4, !tbaa !36
  br label %61

61:                                               ; preds = %151, %21
  %62 = load i32, ptr %5, align 4, !tbaa !36
  %63 = icmp ult i32 %62, 13
  br i1 %63, label %65, label %64

64:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %154

65:                                               ; preds = %61
  %66 = load i32, ptr %5, align 4, !tbaa !36
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds [13 x %"struct.rw::PluginList"], ptr @_ZN2rw6Driver9s_plglistE, i64 0, i64 %67
  %69 = getelementptr inbounds %"struct.rw::PluginList", ptr %68, i32 0, i32 0
  %70 = load i32, ptr %69, align 8, !tbaa !15
  %71 = sext i32 %70 to i64
  %72 = call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %71, i32 noundef 262144, ptr noundef @.str.7)
  %73 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %74 = getelementptr inbounds %"struct.rw::Engine", ptr %73, i32 0, i32 4
  %75 = load i32, ptr %5, align 4, !tbaa !36
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds [13 x ptr], ptr %74, i64 0, i64 %76
  store ptr %72, ptr %77, align 8, !tbaa !5
  %78 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %79 = getelementptr inbounds %"struct.rw::Engine", ptr %78, i32 0, i32 6
  %80 = load ptr, ptr %79, align 8, !tbaa !35
  %81 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %82 = getelementptr inbounds %"struct.rw::Engine", ptr %81, i32 0, i32 4
  %83 = load i32, ptr %5, align 4, !tbaa !36
  %84 = zext i32 %83 to i64
  %85 = getelementptr inbounds [13 x ptr], ptr %82, i64 0, i64 %84
  %86 = load ptr, ptr %85, align 8, !tbaa !5
  %87 = getelementptr inbounds %"struct.rw::Driver", ptr %86, i32 0, i32 0
  store ptr %80, ptr %87, align 8, !tbaa !37
  %88 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %89 = getelementptr inbounds %"struct.rw::Engine", ptr %88, i32 0, i32 4
  %90 = load i32, ptr %5, align 4, !tbaa !36
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds [13 x ptr], ptr %89, i64 0, i64 %91
  %93 = load ptr, ptr %92, align 8, !tbaa !5
  %94 = getelementptr inbounds %"struct.rw::Driver", ptr %93, i32 0, i32 2
  store ptr @_ZN2rw4null12rasterCreateEPNS_6RasterE, ptr %94, align 8, !tbaa !39
  %95 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %96 = getelementptr inbounds %"struct.rw::Engine", ptr %95, i32 0, i32 4
  %97 = load i32, ptr %5, align 4, !tbaa !36
  %98 = zext i32 %97 to i64
  %99 = getelementptr inbounds [13 x ptr], ptr %96, i64 0, i64 %98
  %100 = load ptr, ptr %99, align 8, !tbaa !5
  %101 = getelementptr inbounds %"struct.rw::Driver", ptr %100, i32 0, i32 3
  store ptr @_ZN2rw4null10rasterLockEPNS_6RasterEii, ptr %101, align 8, !tbaa !40
  %102 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %103 = getelementptr inbounds %"struct.rw::Engine", ptr %102, i32 0, i32 4
  %104 = load i32, ptr %5, align 4, !tbaa !36
  %105 = zext i32 %104 to i64
  %106 = getelementptr inbounds [13 x ptr], ptr %103, i64 0, i64 %105
  %107 = load ptr, ptr %106, align 8, !tbaa !5
  %108 = getelementptr inbounds %"struct.rw::Driver", ptr %107, i32 0, i32 4
  store ptr @_ZN2rw4null12rasterUnlockEPNS_6RasterEi, ptr %108, align 8, !tbaa !41
  %109 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %110 = getelementptr inbounds %"struct.rw::Engine", ptr %109, i32 0, i32 4
  %111 = load i32, ptr %5, align 4, !tbaa !36
  %112 = zext i32 %111 to i64
  %113 = getelementptr inbounds [13 x ptr], ptr %110, i64 0, i64 %112
  %114 = load ptr, ptr %113, align 8, !tbaa !5
  %115 = getelementptr inbounds %"struct.rw::Driver", ptr %114, i32 0, i32 5
  store ptr @_ZN2rw4null17rasterLockPaletteEPNS_6RasterEi, ptr %115, align 8, !tbaa !42
  %116 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %117 = getelementptr inbounds %"struct.rw::Engine", ptr %116, i32 0, i32 4
  %118 = load i32, ptr %5, align 4, !tbaa !36
  %119 = zext i32 %118 to i64
  %120 = getelementptr inbounds [13 x ptr], ptr %117, i64 0, i64 %119
  %121 = load ptr, ptr %120, align 8, !tbaa !5
  %122 = getelementptr inbounds %"struct.rw::Driver", ptr %121, i32 0, i32 6
  store ptr @_ZN2rw4null19rasterUnlockPaletteEPNS_6RasterE, ptr %122, align 8, !tbaa !43
  %123 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %124 = getelementptr inbounds %"struct.rw::Engine", ptr %123, i32 0, i32 4
  %125 = load i32, ptr %5, align 4, !tbaa !36
  %126 = zext i32 %125 to i64
  %127 = getelementptr inbounds [13 x ptr], ptr %124, i64 0, i64 %126
  %128 = load ptr, ptr %127, align 8, !tbaa !5
  %129 = getelementptr inbounds %"struct.rw::Driver", ptr %128, i32 0, i32 7
  store ptr @_ZN2rw4null15rasterNumLevelsEPNS_6RasterE, ptr %129, align 8, !tbaa !44
  %130 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %131 = getelementptr inbounds %"struct.rw::Engine", ptr %130, i32 0, i32 4
  %132 = load i32, ptr %5, align 4, !tbaa !36
  %133 = zext i32 %132 to i64
  %134 = getelementptr inbounds [13 x ptr], ptr %131, i64 0, i64 %133
  %135 = load ptr, ptr %134, align 8, !tbaa !5
  %136 = getelementptr inbounds %"struct.rw::Driver", ptr %135, i32 0, i32 8
  store ptr @_ZN2rw4null21imageFindRasterFormatEPNS_5ImageEiPiS3_S3_S3_, ptr %136, align 8, !tbaa !45
  %137 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %138 = getelementptr inbounds %"struct.rw::Engine", ptr %137, i32 0, i32 4
  %139 = load i32, ptr %5, align 4, !tbaa !36
  %140 = zext i32 %139 to i64
  %141 = getelementptr inbounds [13 x ptr], ptr %138, i64 0, i64 %140
  %142 = load ptr, ptr %141, align 8, !tbaa !5
  %143 = getelementptr inbounds %"struct.rw::Driver", ptr %142, i32 0, i32 9
  store ptr @_ZN2rw4null15rasterFromImageEPNS_6RasterEPNS_5ImageE, ptr %143, align 8, !tbaa !46
  %144 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %145 = getelementptr inbounds %"struct.rw::Engine", ptr %144, i32 0, i32 4
  %146 = load i32, ptr %5, align 4, !tbaa !36
  %147 = zext i32 %146 to i64
  %148 = getelementptr inbounds [13 x ptr], ptr %145, i64 0, i64 %147
  %149 = load ptr, ptr %148, align 8, !tbaa !5
  %150 = getelementptr inbounds %"struct.rw::Driver", ptr %149, i32 0, i32 10
  store ptr @_ZN2rw4null13rasterToImageEPNS_6RasterE, ptr %150, align 8, !tbaa !47
  br label %151

151:                                              ; preds = %65
  %152 = load i32, ptr %5, align 4, !tbaa !36
  %153 = add i32 %152, 1
  store i32 %153, ptr %5, align 4, !tbaa !36
  br label %61, !llvm.loop !48

154:                                              ; preds = %64
  store i32 2, ptr @_ZN2rw6Engine5stateE, align 4, !tbaa !9
  store i32 1, ptr %2, align 4
  br label %155

155:                                              ; preds = %154, %20
  %156 = load i32, ptr %2, align 4
  ret i32 %156
}

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

declare i32 @fclose(ptr noundef) #3

declare i32 @fseek(ptr noundef, i64 noundef, i32 noundef) #3

declare i64 @ftell(ptr noundef) #3

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #3

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #3

; Function Attrs: nounwind
declare i32 @feof(ptr noundef) #1

declare noundef ptr @_ZN2rw11ObjPipeline6createEv() #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw4null12rasterCreateEPNS_6RasterE(ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw4null10rasterLockEPNS_6RasterEii(ptr noundef, i32 noundef, i32 noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw4null12rasterUnlockEPNS_6RasterEi(ptr noundef, i32 noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw4null17rasterLockPaletteEPNS_6RasterEi(ptr noundef, i32 noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw4null19rasterUnlockPaletteEPNS_6RasterE(ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw4null15rasterNumLevelsEPNS_6RasterE(ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw4null21imageFindRasterFormatEPNS_5ImageEiPiS3_S3_S3_(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw4null15rasterFromImageEPNS_6RasterEPNS_5ImageE(ptr noundef, ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw4null13rasterToImageEPNS_6RasterE(ptr noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { 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 #7 = { 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 = !{!"_ZTSN2rw6Engine5StateE", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN2rw5ErrorE", !13, i64 0, !13, i64 4}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = !{!16, !13, i64 0}
!16 = !{!"_ZTSN2rw10PluginListE", !13, i64 0, !13, i64 4, !17, i64 8}
!17 = !{!"_ZTSN2rw8LinkListE", !18, i64 0}
!18 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!19 = !{!20, !6, i64 0}
!20 = !{!"_ZTSN2rw6EngineE", !6, i64 0, !6, i64 8, !17, i64 16, !21, i64 32, !7, i64 88, !22, i64 192, !6, i64 328}
!21 = !{!"_ZTSN2rw13FileFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!22 = !{!"_ZTSN2rw6DeviceE", !23, i64 0, !23, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!23 = !{!"float", !7, i64 0}
!24 = !{!20, !6, i64 8}
!25 = !{!20, !6, i64 32}
!26 = !{!20, !6, i64 40}
!27 = !{!20, !6, i64 48}
!28 = !{!20, !6, i64 56}
!29 = !{!20, !6, i64 64}
!30 = !{!20, !6, i64 72}
!31 = !{!20, !6, i64 80}
!32 = !{i64 0, i64 4, !33, i64 4, i64 4, !33, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 8, !5, i64 48, i64 8, !5, i64 56, i64 8, !5, i64 64, i64 8, !5, i64 72, i64 8, !5, i64 80, i64 8, !5, i64 88, i64 8, !5, i64 96, i64 8, !5, i64 104, i64 8, !5, i64 112, i64 8, !5, i64 120, i64 8, !5, i64 128, i64 8, !5}
!33 = !{!23, !23, i64 0}
!34 = !{!20, !6, i64 320}
!35 = !{!20, !6, i64 328}
!36 = !{!13, !13, i64 0}
!37 = !{!38, !6, i64 0}
!38 = !{!"_ZTSN2rw6DriverE", !6, i64 0, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!39 = !{!38, !6, i64 16}
!40 = !{!38, !6, i64 24}
!41 = !{!38, !6, i64 32}
!42 = !{!38, !6, i64 40}
!43 = !{!38, !6, i64 48}
!44 = !{!38, !6, i64 56}
!45 = !{!38, !6, i64 64}
!46 = !{!38, !6, i64 72}
!47 = !{!38, !6, i64 80}
!48 = distinct !{!48, !49}
!49 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.rw::PluginList" = type { i32, i32, %"struct.rw::LinkList" }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::Device" = type { float, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.rw::Error" = type { i32, i32 }

@_ZN2rw6engineE = external dso_local local_unnamed_addr global ptr, align 8
@_ZN2rw6Engine9s_plglistE = external dso_local local_unnamed_addr global %"struct.rw::PluginList", align 8
@_ZN2rw6Engine5stateE = external dso_local local_unnamed_addr global i32, align 4
@_ZN2rw6Driver9s_plglistE = external dso_local local_unnamed_addr global [13 x %"struct.rw::PluginList"], align 16
@stderr = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [74 x i8], align 1
@_ZN2rw4null12renderdeviceE = external dso_local local_unnamed_addr global %"struct.rw::Device", align 8
@.str.7 = external hidden unnamed_addr constant [74 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN2rw6Engine4openEPNS_16EngineOpenParamsE(ptr noundef %0) local_unnamed_addr #4 align 2 {
  %2 = alloca %"struct.rw::Error", align 4
  %3 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %4 = icmp ne ptr %3, null
  %5 = load i32, ptr @_ZN2rw6Engine5stateE, align 4
  %6 = icmp ne i32 %5, 1
  %or.cond = select i1 %4, i1 true, i1 %6
  br i1 %or.cond, label %7, label %14

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

14:                                               ; preds = %1
  %15 = load i32, ptr @_ZN2rw6Engine9s_plglistE, align 8, !tbaa !13
  %16 = sext i32 %15 to i64
  %17 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %16, i32 noundef 262144, ptr noundef nonnull @.str.6)
  store ptr %17, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  store ptr null, ptr %17, align 8, !tbaa !17
  %18 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 8
  store ptr null, ptr %19, align 8, !tbaa !22
  %20 = getelementptr inbounds i8, ptr %18, i64 32
  store ptr @fopen, ptr %20, align 8, !tbaa !23
  %21 = getelementptr inbounds i8, ptr %18, i64 40
  store ptr @fclose, ptr %21, align 8, !tbaa !24
  %22 = getelementptr inbounds i8, ptr %18, i64 48
  store ptr @fseek, ptr %22, align 8, !tbaa !25
  %23 = getelementptr inbounds i8, ptr %18, i64 56
  store ptr @ftell, ptr %23, align 8, !tbaa !26
  %24 = getelementptr inbounds i8, ptr %18, i64 64
  store ptr @fread, ptr %24, align 8, !tbaa !27
  %25 = getelementptr inbounds i8, ptr %18, i64 72
  store ptr @fwrite, ptr %25, align 8, !tbaa !28
  %26 = getelementptr inbounds i8, ptr %18, i64 80
  store ptr @feof, ptr %26, align 8, !tbaa !29
  %27 = getelementptr inbounds i8, ptr %18, i64 192
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(136) %27, ptr noundef nonnull align 8 dereferenceable(136) @_ZN2rw4null12renderdeviceE, i64 136, i1 false), !tbaa.struct !30
  %28 = getelementptr inbounds i8, ptr %18, i64 320
  %29 = load ptr, ptr %28, align 8, !tbaa !32
  %30 = tail call noundef i32 %29(i32 noundef 2, ptr noundef %0, i32 noundef 0)
  %31 = tail call noundef ptr @_ZN2rw11ObjPipeline6createEv()
  %32 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %32, i64 328
  store ptr %31, ptr %33, align 8, !tbaa !33
  br label %35

34:                                               ; preds = %35
  store i32 2, ptr @_ZN2rw6Engine5stateE, align 4, !tbaa !34
  br label %70

35:                                               ; preds = %14, %35
  %indvars.iv = phi i64 [ 0, %14 ], [ %indvars.iv.next, %35 ]
  %36 = getelementptr inbounds [13 x %"struct.rw::PluginList"], ptr @_ZN2rw6Driver9s_plglistE, i64 0, i64 %indvars.iv
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = sext i32 %37 to i64
  %39 = tail call noundef ptr @_ZN2rw14mustmalloc_LOCEmjPKc(i64 noundef %38, i32 noundef 262144, ptr noundef nonnull @.str.7)
  %40 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %40, i64 88
  %42 = getelementptr inbounds [13 x ptr], ptr %41, i64 0, i64 %indvars.iv
  store ptr %39, ptr %42, align 8, !tbaa !5
  %43 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %43, i64 328
  %45 = load ptr, ptr %44, align 8, !tbaa !33
  %46 = getelementptr inbounds i8, ptr %43, i64 88
  %47 = getelementptr inbounds [13 x ptr], ptr %46, i64 0, i64 %indvars.iv
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  store ptr %45, ptr %48, align 8, !tbaa !36
  %49 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i64 88
  %51 = getelementptr inbounds [13 x ptr], ptr %50, i64 0, i64 %indvars.iv
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %52, i64 16
  store ptr @_ZN2rw4null12rasterCreateEPNS_6RasterE, ptr %53, align 8, !tbaa !38
  %54 = load ptr, ptr %51, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %54, i64 24
  store ptr @_ZN2rw4null10rasterLockEPNS_6RasterEii, ptr %55, align 8, !tbaa !39
  %56 = load ptr, ptr %51, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %56, i64 32
  store ptr @_ZN2rw4null12rasterUnlockEPNS_6RasterEi, ptr %57, align 8, !tbaa !40
  %58 = load ptr, ptr %51, align 8, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %58, i64 40
  store ptr @_ZN2rw4null17rasterLockPaletteEPNS_6RasterEi, ptr %59, align 8, !tbaa !41
  %60 = load ptr, ptr %51, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i64 48
  store ptr @_ZN2rw4null19rasterUnlockPaletteEPNS_6RasterE, ptr %61, align 8, !tbaa !42
  %62 = load ptr, ptr %51, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %62, i64 56
  store ptr @_ZN2rw4null15rasterNumLevelsEPNS_6RasterE, ptr %63, align 8, !tbaa !43
  %64 = load ptr, ptr %51, align 8, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %64, i64 64
  store ptr @_ZN2rw4null21imageFindRasterFormatEPNS_5ImageEiPiS3_S3_S3_, ptr %65, align 8, !tbaa !44
  %66 = load ptr, ptr %51, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i64 72
  store ptr @_ZN2rw4null15rasterFromImageEPNS_6RasterEPNS_5ImageE, ptr %67, align 8, !tbaa !45
  %68 = load ptr, ptr %51, align 8, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %68, i64 80
  store ptr @_ZN2rw4null13rasterToImageEPNS_6RasterE, ptr %69, align 8, !tbaa !46
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 13
  br i1 %exitcond.not, label %34, label %35, !llvm.loop !47

70:                                               ; preds = %34, %7
  %.016 = phi i32 [ 0, %7 ], [ 1, %34 ]
  ret i32 %.016
}

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

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) #1

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) #1

; Function Attrs: nofree nounwind
declare noundef i32 @fseek(ptr nocapture noundef, i64 noundef, i32 noundef) #1

; Function Attrs: nofree nounwind
declare noundef i64 @ftell(ptr nocapture noundef) #1

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) #1

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) #1

; Function Attrs: nofree nounwind
declare noundef i32 @feof(ptr nocapture noundef) #1

declare noundef ptr @_ZN2rw11ObjPipeline6createEv() local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw4null12rasterCreateEPNS_6RasterE(ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw4null10rasterLockEPNS_6RasterEii(ptr noundef, i32 noundef, i32 noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw4null12rasterUnlockEPNS_6RasterEi(ptr noundef, i32 noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw4null17rasterLockPaletteEPNS_6RasterEi(ptr noundef, i32 noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2rw4null19rasterUnlockPaletteEPNS_6RasterE(ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw4null15rasterNumLevelsEPNS_6RasterE(ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw4null21imageFindRasterFormatEPNS_5ImageEiPiS3_S3_S3_(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2rw4null15rasterFromImageEPNS_6RasterEPNS_5ImageE(ptr noundef, ptr noundef) #6

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN2rw4null13rasterToImageEPNS_6RasterE(ptr noundef) #6

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { 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 #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 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN2rw5ErrorE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!14, !11, i64 0}
!14 = !{!"_ZTSN2rw10PluginListE", !11, i64 0, !11, i64 4, !15, i64 8}
!15 = !{!"_ZTSN2rw8LinkListE", !16, i64 0}
!16 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!17 = !{!18, !6, i64 0}
!18 = !{!"_ZTSN2rw6EngineE", !6, i64 0, !6, i64 8, !15, i64 16, !19, i64 32, !7, i64 88, !20, i64 192, !6, i64 328}
!19 = !{!"_ZTSN2rw13FileFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!20 = !{!"_ZTSN2rw6DeviceE", !21, i64 0, !21, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128}
!21 = !{!"float", !7, i64 0}
!22 = !{!18, !6, i64 8}
!23 = !{!18, !6, i64 32}
!24 = !{!18, !6, i64 40}
!25 = !{!18, !6, i64 48}
!26 = !{!18, !6, i64 56}
!27 = !{!18, !6, i64 64}
!28 = !{!18, !6, i64 72}
!29 = !{!18, !6, i64 80}
!30 = !{i64 0, i64 4, !31, i64 4, i64 4, !31, i64 8, i64 8, !5, i64 16, i64 8, !5, i64 24, i64 8, !5, i64 32, i64 8, !5, i64 40, i64 8, !5, i64 48, i64 8, !5, i64 56, i64 8, !5, i64 64, i64 8, !5, i64 72, i64 8, !5, i64 80, i64 8, !5, i64 88, i64 8, !5, i64 96, i64 8, !5, i64 104, i64 8, !5, i64 112, i64 8, !5, i64 120, i64 8, !5, i64 128, i64 8, !5}
!31 = !{!21, !21, i64 0}
!32 = !{!18, !6, i64 320}
!33 = !{!18, !6, i64 328}
!34 = !{!35, !35, i64 0}
!35 = !{!"_ZTSN2rw6Engine5StateE", !7, i64 0}
!36 = !{!37, !6, i64 0}
!37 = !{!"_ZTSN2rw6DriverE", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!38 = !{!37, !6, i64 16}
!39 = !{!37, !6, i64 24}
!40 = !{!37, !6, i64 32}
!41 = !{!37, !6, i64 40}
!42 = !{!37, !6, i64 48}
!43 = !{!37, !6, i64 56}
!44 = !{!37, !6, i64 64}
!45 = !{!37, !6, i64 72}
!46 = !{!37, !6, i64 80}
!47 = distinct !{!47, !48}
!48 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass