; LLVM IR from aap/librw :: src/image.ll (ZN2rw5Image11getFilenameEPKc)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"struct.rw::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"struct.rw::Error" = type { i32, i32 }
%"struct.rw::ImageGlobals" = type { ptr, i32, [10 x %"struct.rw::FileAssociation"], i32 }
%"struct.rw::FileAssociation" = type { ptr, ptr, ptr }
%"struct.rw::Engine" = type { ptr, ptr, %"struct.rw::LinkList", %"struct.rw::FileFunctions", [13 x ptr], %"struct.rw::Device", ptr }
%"struct.rw::LinkList" = type { %"struct.rw::LLLink" }
%"struct.rw::LLLink" = type { ptr, ptr }
%"struct.rw::FileFunctions" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%"struct.rw::Device" = type { float, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@_ZN2rw17imageModuleOffsetE = external dso_local global i32, align 4
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@_ZN2rw6Engine8memfuncsE = external global %"struct.rw::MemoryFunctions", align 8
@_ZN2rw6engineE = external global ptr, align 8
@.str.14 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [2 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) #3

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

declare noundef ptr @_ZN2rw10strdup_LOCEPKcjS1_(ptr noundef, i32 noundef, ptr noundef) #3

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw5Image11getFilenameEPKc(ptr noundef %0) #5 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %"struct.rw::Error", align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %12 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %13 = load i32, ptr @_ZN2rw17imageModuleOffsetE, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds i8, ptr %12, i64 %14
  store ptr %15, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.rw::ImageGlobals", ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  store ptr %18, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i64 @strlen(ptr noundef %19) #7
  %21 = add i64 %20, 1
  store i64 %21, ptr %8, align 8, !tbaa !13
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.rw::ImageGlobals", ptr %22, i32 0, i32 1
  %24 = load i32, ptr %23, align 8, !tbaa !15
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %51

26:                                               ; preds = %1
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = call noundef ptr @_ZN2rw10strdup_LOCEPKcjS1_(ptr noundef %27, i32 noundef 196608, ptr noundef @.str.14)
  store ptr %28, ptr %6, align 8, !tbaa !5
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN2rw8makePathEPc(ptr noundef %29)
  %30 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.rw::Engine", ptr %30, i32 0, i32 3
  %32 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !16
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = call noundef ptr %33(ptr noundef %34, ptr noundef @.str.15)
  store ptr %35, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %48

38:                                               ; preds = %26
  %39 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.rw::Engine", ptr %39, i32 0, i32 3
  %41 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !23
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = call noundef i32 %42(ptr noundef %43)
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.16, ptr noundef %45)
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %47, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %123

48:                                               ; preds = %26
  %49 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !24
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  call void %49(ptr noundef %50)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %123

51:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %116, %51
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.rw::ImageGlobals", ptr %54, i32 0, i32 1
  %56 = load i32, ptr %55, align 8, !tbaa !15
  %57 = icmp slt i32 %53, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %52
  store i32 2, ptr %9, align 4
  br label %119

59:                                               ; preds = %52
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = call i64 @strlen(ptr noundef %60) #7
  %62 = load i64, ptr %8, align 8, !tbaa !13
  %63 = add i64 %61, %62
  %64 = call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %63, i32 noundef 196632, ptr noundef @.str.17)
  store ptr %64, ptr %6, align 8, !tbaa !5
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %82

67:                                               ; preds = %59
  br label %68

68:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %69 = getelementptr inbounds %"struct.rw::Error", ptr %11, i32 0, i32 0
  store i32 24, ptr %69, align 4, !tbaa !26
  %70 = getelementptr inbounds %"struct.rw::Error", ptr %11, i32 0, i32 1
  store i32 -2147483646, ptr %70, align 4, !tbaa !28
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 952) #6
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = call i64 @strlen(ptr noundef %74) #7
  %76 = load i64, ptr %8, align 8, !tbaa !13
  %77 = add i64 %75, %76
  %78 = call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i64 noundef %77)
  %79 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %73, ptr noundef @.str.3, ptr noundef %78) #6
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %80

80:                                               ; preds = %68
  br label %81

81:                                               ; preds = %80
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %119

82:                                               ; preds = %59
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = call ptr @strcpy(ptr noundef %83, ptr noundef %84) #6
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = call ptr @strcat(ptr noundef %86, ptr noundef %87) #6
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN2rw8makePathEPc(ptr noundef %89)
  %90 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %91 = getelementptr inbounds %"struct.rw::Engine", ptr %90, i32 0, i32 3
  %92 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %91, i32 0, i32 0
  %93 = load ptr, ptr %92, align 8, !tbaa !16
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = call noundef ptr %93(ptr noundef %94, ptr noundef @.str.18)
  store ptr %95, ptr %5, align 8, !tbaa !5
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = icmp ne ptr %96, null
  br i1 %97, label %98, label %108

98:                                               ; preds = %82
  %99 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %100 = getelementptr inbounds %"struct.rw::Engine", ptr %99, i32 0, i32 3
  %101 = getelementptr inbounds %"struct.rw::FileFunctions", ptr %100, i32 0, i32 1
  %102 = load ptr, ptr %101, align 8, !tbaa !23
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = call noundef i32 %102(ptr noundef %103)
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = call i32 (ptr, ...) @printf(ptr noundef @.str.16, ptr noundef %105)
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %107, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %119

108:                                              ; preds = %82
  %109 = load ptr, ptr getelementptr inbounds (%"struct.rw::MemoryFunctions", ptr @_ZN2rw6Engine8memfuncsE, i32 0, i32 2), align 8, !tbaa !24
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  call void %109(ptr noundef %110)
  %111 = load ptr, ptr %7, align 8, !tbaa !5
  %112 = call i64 @strlen(ptr noundef %111) #7
  %113 = add i64 %112, 1
  %114 = load ptr, ptr %7, align 8, !tbaa !5
  %115 = getelementptr inbounds i8, ptr %114, i64 %113
  store ptr %115, ptr %7, align 8, !tbaa !5
  br label %116

116:                                              ; preds = %108
  %117 = load i32, ptr %10, align 4, !tbaa !9
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %10, align 4, !tbaa !9
  br label %52, !llvm.loop !29

119:                                              ; preds = %98, %81, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %120 = load i32, ptr %9, align 4
  switch i32 %120, label %123 [
    i32 2, label %121
  ]

121:                                              ; preds = %119
  br label %122

122:                                              ; preds = %121
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %123

123:                                              ; preds = %122, %119, %48, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  %124 = load ptr, ptr %2, align 8
  ret ptr %124
}

declare void @_ZN2rw8makePathEPc(ptr noundef) #3

; Function Attrs: nounwind
declare ptr @strcpy(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare ptr @strcat(ptr noundef, ptr noundef) #2

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 = { 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 #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 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress 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 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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, !6, i64 0}
!12 = !{!"_ZTSN2rw12ImageGlobalsE", !6, i64 0, !10, i64 8, !7, i64 16, !10, i64 256}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!12, !10, i64 8}
!16 = !{!17, !6, i64 32}
!17 = !{!"_ZTSN2rw6EngineE", !6, i64 0, !6, i64 8, !18, i64 16, !20, i64 32, !7, i64 88, !21, i64 192, !6, i64 328}
!18 = !{!"_ZTSN2rw8LinkListE", !19, i64 0}
!19 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!20 = !{!"_ZTSN2rw13FileFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!21 = !{!"_ZTSN2rw6DeviceE", !22, i64 0, !22, 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}
!22 = !{!"float", !7, i64 0}
!23 = !{!17, !6, i64 40}
!24 = !{!25, !6, i64 16}
!25 = !{!"_ZTSN2rw15MemoryFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!26 = !{!27, !10, i64 0}
!27 = !{!"_ZTSN2rw5ErrorE", !10, i64 0, !10, i64 4}
!28 = !{!27, !10, i64 4}
!29 = distinct !{!29, !30}
!30 = !{!"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::MemoryFunctions" = type { ptr, ptr, ptr, ptr, ptr }
%"struct.rw::Error" = type { i32, i32 }

@_ZN2rw17imageModuleOffsetE = external dso_local local_unnamed_addr global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@_ZN2rw6Engine8memfuncsE = external local_unnamed_addr global %"struct.rw::MemoryFunctions", align 8
@_ZN2rw6engineE = external local_unnamed_addr global ptr, align 8
@.str.14 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [2 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

declare void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef) local_unnamed_addr #3

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

declare noundef ptr @_ZN2rw10strdup_LOCEPKcjS1_(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN2rw5Image11getFilenameEPKc(ptr noundef %0) local_unnamed_addr #5 align 2 {
  %2 = alloca %"struct.rw::Error", align 4
  %3 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %4 = load i32, ptr @_ZN2rw17imageModuleOffsetE, align 4, !tbaa !9
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds i8, ptr %3, i64 %5
  %7 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #7
  %8 = add i64 %7, 1
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  %10 = load i32, ptr %9, align 8, !tbaa !11
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %26

12:                                               ; preds = %1
  %13 = tail call noundef ptr @_ZN2rw10strdup_LOCEPKcjS1_(ptr noundef %0, i32 noundef 196608, ptr noundef nonnull @.str.14)
  tail call void @_ZN2rw8makePathEPc(ptr noundef %13)
  %14 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 32
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = tail call noundef ptr %16(ptr noundef %13, ptr noundef nonnull @.str.15)
  %.not40 = icmp eq ptr %17, null
  br i1 %.not40, label %24, label %18

18:                                               ; preds = %12
  %19 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %19, i64 40
  %21 = load ptr, ptr %20, align 8, !tbaa !20
  %22 = tail call noundef i32 %21(ptr noundef nonnull %17)
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16, ptr noundef %13)
  br label %.loopexit

24:                                               ; preds = %12
  %25 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !21
  tail call void %25(ptr noundef %13)
  br label %.loopexit

26:                                               ; preds = %1
  %.not3945 = icmp sgt i32 %10, 0
  br i1 %.not3945, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %26
  %27 = load ptr, ptr %6, align 8, !tbaa !23
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %54
  %.047 = phi i32 [ %59, %54 ], [ 0, %.lr.ph.preheader ]
  %.03546 = phi ptr [ %58, %54 ], [ %27, %.lr.ph.preheader ]
  %28 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.03546) #7
  %29 = add i64 %28, %8
  %30 = tail call noundef ptr @_ZN2rw10malloc_LOCEmjPKc(i64 noundef %29, i32 noundef 196632, ptr noundef nonnull @.str.17)
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %41

32:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  store i32 24, ptr %2, align 4, !tbaa !24
  %33 = getelementptr inbounds i8, ptr %2, i64 4
  store i32 -2147483646, ptr %33, align 4, !tbaa !26
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  %35 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 952) #9
  %36 = load ptr, ptr @stderr, align 8, !tbaa !5
  %37 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.03546) #7
  %38 = add i64 %37, %8
  %39 = tail call noundef ptr (i32, ...) @_ZN2rw9dbgsprintEjz(i32 noundef -2147483646, i64 noundef %38)
  %40 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.3, ptr noundef %39) #9
  call void @_ZN2rw8setErrorEPNS_5ErrorE(ptr noundef nonnull %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  br label %.loopexit

41:                                               ; preds = %.lr.ph
  %42 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %30, ptr noundef nonnull dereferenceable(1) %.03546) #8
  %43 = tail call ptr @strcat(ptr noundef nonnull dereferenceable(1) %30, ptr noundef nonnull dereferenceable(1) %0) #8
  tail call void @_ZN2rw8makePathEPc(ptr noundef nonnull %30)
  %44 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i64 32
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = tail call noundef ptr %46(ptr noundef nonnull %30, ptr noundef nonnull @.str.18)
  %.not = icmp eq ptr %47, null
  br i1 %.not, label %54, label %48

48:                                               ; preds = %41
  %49 = load ptr, ptr @_ZN2rw6engineE, align 8, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %49, i64 40
  %51 = load ptr, ptr %50, align 8, !tbaa !20
  %52 = tail call noundef i32 %51(ptr noundef nonnull %47)
  %53 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16, ptr noundef %0)
  br label %.loopexit

54:                                               ; preds = %41
  %55 = load ptr, ptr getelementptr inbounds (i8, ptr @_ZN2rw6Engine8memfuncsE, i64 16), align 8, !tbaa !21
  tail call void %55(ptr noundef nonnull %30)
  %56 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.03546) #7
  %57 = add i64 %56, 1
  %58 = getelementptr inbounds i8, ptr %.03546, i64 %57
  %59 = add nuw nsw i32 %.047, 1
  %60 = load i32, ptr %9, align 8, !tbaa !11
  %.not39 = icmp slt i32 %59, %60
  br i1 %.not39, label %.lr.ph, label %.loopexit, !llvm.loop !27

.loopexit:                                        ; preds = %54, %26, %32, %48, %24, %18
  %.1 = phi ptr [ %13, %18 ], [ null, %24 ], [ null, %32 ], [ %30, %48 ], [ null, %26 ], [ null, %54 ]
  ret ptr %.1
}

declare void @_ZN2rw8makePathEPc(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) local_unnamed_addr #6

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcat(ptr noalias noundef returned, ptr noalias nocapture noundef readonly) local_unnamed_addr #6

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 = { 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 #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 nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { mustprogress 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 nofree nounwind willreturn memory(argmem: readwrite) "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 willreturn memory(read) }
attributes #8 = { nounwind }
attributes #9 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTSN2rw12ImageGlobalsE", !6, i64 0, !10, i64 8, !7, i64 16, !10, i64 256}
!13 = !{!14, !6, i64 32}
!14 = !{!"_ZTSN2rw6EngineE", !6, i64 0, !6, i64 8, !15, i64 16, !17, i64 32, !7, i64 88, !18, i64 192, !6, i64 328}
!15 = !{!"_ZTSN2rw8LinkListE", !16, i64 0}
!16 = !{!"_ZTSN2rw6LLLinkE", !6, i64 0, !6, i64 8}
!17 = !{!"_ZTSN2rw13FileFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!18 = !{!"_ZTSN2rw6DeviceE", !19, i64 0, !19, 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}
!19 = !{!"float", !7, i64 0}
!20 = !{!14, !6, i64 40}
!21 = !{!22, !6, i64 16}
!22 = !{!"_ZTSN2rw15MemoryFunctionsE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!23 = !{!12, !6, i64 0}
!24 = !{!25, !10, i64 0}
!25 = !{!"_ZTSN2rw5ErrorE", !10, i64 0, !10, i64 4}
!26 = !{!25, !10, i64 4}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


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