; LLVM IR from wrnlb666/yet-another-string-library-in-c :: yasli (str_replaced)

; 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.string_t = type { i64, i64, [1 x i8] }

; 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: inlinehint nounwind uwtable
declare hidden zeroext i1 @str_resize(ptr noundef, i64 noundef) #1

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

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #4

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strstr(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #5

; Function Attrs: nounwind uwtable
define dso_local ptr @str_replaced(ptr noundef %0, ptr noundef %1, ptr noundef %2) #6 {
  %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 ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i32, align 4
  %23 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = call i64 @strlen(ptr noundef %24) #8
  store i64 %25, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.string_t, ptr %26, i32 0, i32 0
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = add i64 %28, 1
  %30 = mul i64 1, %29
  %31 = call noalias ptr @malloc(i64 noundef %30) #9
  store ptr %31, ptr %9, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.string_t, ptr %33, i32 0, i32 2
  %35 = getelementptr inbounds [1 x i8], ptr %34, i64 0, i64 0
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.string_t, ptr %36, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !11
  %39 = add i64 %38, 1
  %40 = call ptr @strncpy(ptr noundef %32, ptr noundef %35, i64 noundef %39) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %41, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store i64 16, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  %42 = load i64, ptr %11, align 8, !tbaa !9
  %43 = mul i64 8, %42
  %44 = call noalias ptr @malloc(i64 noundef %43) #9
  store ptr %44, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %45 = load i64, ptr %11, align 8, !tbaa !9
  %46 = mul i64 8, %45
  %47 = call noalias ptr @malloc(i64 noundef %46) #9
  store ptr %47, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  store i64 0, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  store i64 0, ptr %16, align 8, !tbaa !9
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call ptr @strstr(ptr noundef %48, ptr noundef %49) #8
  store ptr %50, ptr %14, align 8, !tbaa !5
  br label %51

51:                                               ; preds = %102, %3
  %52 = load ptr, ptr %14, align 8, !tbaa !5
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %103

54:                                               ; preds = %51
  %55 = load ptr, ptr %14, align 8, !tbaa !5
  store i8 0, ptr %55, align 1, !tbaa !13
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = call i64 @strlen(ptr noundef %56) #8
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = load i64, ptr %15, align 8, !tbaa !9
  %60 = getelementptr inbounds i64, ptr %58, i64 %59
  store i64 %57, ptr %60, align 8, !tbaa !9
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = load i64, ptr %15, align 8, !tbaa !9
  %63 = getelementptr inbounds i64, ptr %61, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !9
  %65 = add i64 %64, 1
  %66 = mul i64 1, %65
  %67 = call noalias ptr @malloc(i64 noundef %66) #9
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load i64, ptr %15, align 8, !tbaa !9
  %70 = getelementptr inbounds ptr, ptr %68, i64 %69
  store ptr %67, ptr %70, align 8, !tbaa !5
  %71 = load ptr, ptr %12, align 8, !tbaa !5
  %72 = load i64, ptr %15, align 8, !tbaa !9
  %73 = getelementptr inbounds ptr, ptr %71, i64 %72
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = call ptr @strcpy(ptr noundef %74, ptr noundef %75) #7
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  %78 = load i64, ptr %8, align 8, !tbaa !9
  %79 = getelementptr inbounds i8, ptr %77, i64 %78
  store ptr %79, ptr %9, align 8, !tbaa !5
  %80 = load i64, ptr %15, align 8, !tbaa !9
  %81 = add i64 %80, 1
  store i64 %81, ptr %15, align 8, !tbaa !9
  %82 = load i64, ptr %16, align 8, !tbaa !9
  %83 = add i64 %82, 1
  store i64 %83, ptr %16, align 8, !tbaa !9
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = call ptr @strstr(ptr noundef %84, ptr noundef %85) #8
  store ptr %86, ptr %14, align 8, !tbaa !5
  %87 = load i64, ptr %15, align 8, !tbaa !9
  %88 = add i64 %87, 2
  %89 = load i64, ptr %11, align 8, !tbaa !9
  %90 = icmp eq i64 %88, %89
  br i1 %90, label %91, label %102

91:                                               ; preds = %54
  %92 = load i64, ptr %11, align 8, !tbaa !9
  %93 = add i64 %92, 16
  store i64 %93, ptr %11, align 8, !tbaa !9
  %94 = load ptr, ptr %12, align 8, !tbaa !5
  %95 = load i64, ptr %11, align 8, !tbaa !9
  %96 = mul i64 8, %95
  %97 = call ptr @realloc(ptr noundef %94, i64 noundef %96) #10
  store ptr %97, ptr %12, align 8, !tbaa !5
  %98 = load ptr, ptr %13, align 8, !tbaa !5
  %99 = load i64, ptr %11, align 8, !tbaa !9
  %100 = mul i64 8, %99
  %101 = call ptr @realloc(ptr noundef %98, i64 noundef %100) #10
  store ptr %101, ptr %13, align 8, !tbaa !5
  br label %102

102:                                              ; preds = %91, %54
  br label %51, !llvm.loop !14

103:                                              ; preds = %51
  %104 = load ptr, ptr %9, align 8, !tbaa !5
  %105 = call i64 @strlen(ptr noundef %104) #8
  %106 = load ptr, ptr %13, align 8, !tbaa !5
  %107 = load i64, ptr %15, align 8, !tbaa !9
  %108 = getelementptr inbounds i64, ptr %106, i64 %107
  store i64 %105, ptr %108, align 8, !tbaa !9
  %109 = load ptr, ptr %13, align 8, !tbaa !5
  %110 = load i64, ptr %15, align 8, !tbaa !9
  %111 = getelementptr inbounds i64, ptr %109, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !9
  %113 = add i64 %112, 1
  %114 = mul i64 1, %113
  %115 = call noalias ptr @malloc(i64 noundef %114) #9
  %116 = load ptr, ptr %12, align 8, !tbaa !5
  %117 = load i64, ptr %15, align 8, !tbaa !9
  %118 = getelementptr inbounds ptr, ptr %116, i64 %117
  store ptr %115, ptr %118, align 8, !tbaa !5
  %119 = load ptr, ptr %12, align 8, !tbaa !5
  %120 = load i64, ptr %15, align 8, !tbaa !9
  %121 = getelementptr inbounds ptr, ptr %119, i64 %120
  %122 = load ptr, ptr %121, align 8, !tbaa !5
  %123 = load ptr, ptr %9, align 8, !tbaa !5
  %124 = call ptr @strcpy(ptr noundef %122, ptr noundef %123) #7
  %125 = load i64, ptr %15, align 8, !tbaa !9
  %126 = add i64 %125, 1
  store i64 %126, ptr %15, align 8, !tbaa !9
  %127 = load ptr, ptr %12, align 8, !tbaa !5
  %128 = load i64, ptr %15, align 8, !tbaa !9
  %129 = getelementptr inbounds ptr, ptr %127, i64 %128
  store ptr null, ptr %129, align 8, !tbaa !5
  %130 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %130) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  store i64 0, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %131 = load ptr, ptr %7, align 8, !tbaa !5
  %132 = call i64 @strlen(ptr noundef %131) #8
  store i64 %132, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %133

133:                                              ; preds = %156, %103
  %134 = load ptr, ptr %12, align 8, !tbaa !5
  %135 = load i64, ptr %19, align 8, !tbaa !9
  %136 = getelementptr inbounds ptr, ptr %134, i64 %135
  %137 = load ptr, ptr %136, align 8, !tbaa !5
  %138 = icmp ne ptr %137, null
  br i1 %138, label %140, label %139

139:                                              ; preds = %133
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %159

140:                                              ; preds = %133
  %141 = load ptr, ptr %12, align 8, !tbaa !5
  %142 = load i64, ptr %19, align 8, !tbaa !9
  %143 = getelementptr inbounds ptr, ptr %141, i64 %142
  %144 = load ptr, ptr %143, align 8, !tbaa !5
  %145 = call i64 @strlen(ptr noundef %144) #8
  %146 = load i64, ptr %17, align 8, !tbaa !9
  %147 = add i64 %146, %145
  store i64 %147, ptr %17, align 8, !tbaa !9
  %148 = load i64, ptr %16, align 8, !tbaa !9
  %149 = load i64, ptr %19, align 8, !tbaa !9
  %150 = icmp ne i64 %148, %149
  br i1 %150, label %151, label %155

151:                                              ; preds = %140
  %152 = load i64, ptr %18, align 8, !tbaa !9
  %153 = load i64, ptr %17, align 8, !tbaa !9
  %154 = add i64 %153, %152
  store i64 %154, ptr %17, align 8, !tbaa !9
  br label %155

155:                                              ; preds = %151, %140
  br label %156

156:                                              ; preds = %155
  %157 = load i64, ptr %19, align 8, !tbaa !9
  %158 = add i64 %157, 1
  store i64 %158, ptr %19, align 8, !tbaa !9
  br label %133, !llvm.loop !16

159:                                              ; preds = %139
  store i64 0, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  store ptr null, ptr %20, align 8, !tbaa !5
  %160 = load i64, ptr %17, align 8, !tbaa !9
  %161 = call zeroext i1 @str_resize(ptr noundef %20, i64 noundef %160)
  br i1 %161, label %162, label %213

162:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  store i64 0, ptr %21, align 8, !tbaa !9
  br label %163

163:                                              ; preds = %206, %162
  %164 = load ptr, ptr %12, align 8, !tbaa !5
  %165 = load i64, ptr %21, align 8, !tbaa !9
  %166 = getelementptr inbounds ptr, ptr %164, i64 %165
  %167 = load ptr, ptr %166, align 8, !tbaa !5
  %168 = icmp ne ptr %167, null
  br i1 %168, label %170, label %169

169:                                              ; preds = %163
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  br label %209

170:                                              ; preds = %163
  %171 = load ptr, ptr %20, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.string_t, ptr %171, i32 0, i32 2
  %173 = getelementptr inbounds [1 x i8], ptr %172, i64 0, i64 0
  %174 = load i64, ptr %15, align 8, !tbaa !9
  %175 = getelementptr inbounds i8, ptr %173, i64 %174
  %176 = load ptr, ptr %12, align 8, !tbaa !5
  %177 = load i64, ptr %21, align 8, !tbaa !9
  %178 = getelementptr inbounds ptr, ptr %176, i64 %177
  %179 = load ptr, ptr %178, align 8, !tbaa !5
  %180 = call ptr @strcpy(ptr noundef %175, ptr noundef %179) #7
  %181 = load ptr, ptr %13, align 8, !tbaa !5
  %182 = load i64, ptr %21, align 8, !tbaa !9
  %183 = getelementptr inbounds i64, ptr %181, i64 %182
  %184 = load i64, ptr %183, align 8, !tbaa !9
  %185 = load i64, ptr %15, align 8, !tbaa !9
  %186 = add i64 %185, %184
  store i64 %186, ptr %15, align 8, !tbaa !9
  %187 = load i64, ptr %16, align 8, !tbaa !9
  %188 = load i64, ptr %21, align 8, !tbaa !9
  %189 = icmp ne i64 %187, %188
  br i1 %189, label %190, label %201

190:                                              ; preds = %170
  %191 = load ptr, ptr %20, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.string_t, ptr %191, i32 0, i32 2
  %193 = getelementptr inbounds [1 x i8], ptr %192, i64 0, i64 0
  %194 = load i64, ptr %15, align 8, !tbaa !9
  %195 = getelementptr inbounds i8, ptr %193, i64 %194
  %196 = load ptr, ptr %7, align 8, !tbaa !5
  %197 = call ptr @strcpy(ptr noundef %195, ptr noundef %196) #7
  %198 = load i64, ptr %18, align 8, !tbaa !9
  %199 = load i64, ptr %15, align 8, !tbaa !9
  %200 = add i64 %199, %198
  store i64 %200, ptr %15, align 8, !tbaa !9
  br label %201

201:                                              ; preds = %190, %170
  %202 = load ptr, ptr %12, align 8, !tbaa !5
  %203 = load i64, ptr %21, align 8, !tbaa !9
  %204 = getelementptr inbounds ptr, ptr %202, i64 %203
  %205 = load ptr, ptr %204, align 8, !tbaa !5
  call void @free(ptr noundef %205) #7
  br label %206

206:                                              ; preds = %201
  %207 = load i64, ptr %21, align 8, !tbaa !9
  %208 = add i64 %207, 1
  store i64 %208, ptr %21, align 8, !tbaa !9
  br label %163, !llvm.loop !17

209:                                              ; preds = %169
  %210 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %210) #7
  %211 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %211) #7
  %212 = load ptr, ptr %20, align 8, !tbaa !5
  store ptr %212, ptr %4, align 8
  store i32 1, ptr %22, align 4
  br label %232

213:                                              ; preds = %159
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  store i64 0, ptr %23, align 8, !tbaa !9
  br label %214

214:                                              ; preds = %226, %213
  %215 = load ptr, ptr %12, align 8, !tbaa !5
  %216 = load i64, ptr %23, align 8, !tbaa !9
  %217 = getelementptr inbounds ptr, ptr %215, i64 %216
  %218 = load ptr, ptr %217, align 8, !tbaa !5
  %219 = icmp ne ptr %218, null
  br i1 %219, label %221, label %220

220:                                              ; preds = %214
  store i32 10, ptr %22, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  br label %229

221:                                              ; preds = %214
  %222 = load ptr, ptr %12, align 8, !tbaa !5
  %223 = load i64, ptr %23, align 8, !tbaa !9
  %224 = getelementptr inbounds ptr, ptr %222, i64 %223
  %225 = load ptr, ptr %224, align 8, !tbaa !5
  call void @free(ptr noundef %225) #7
  br label %226

226:                                              ; preds = %221
  %227 = load i64, ptr %23, align 8, !tbaa !9
  %228 = add i64 %227, 1
  store i64 %228, ptr %23, align 8, !tbaa !9
  br label %214, !llvm.loop !18

229:                                              ; preds = %220
  %230 = load ptr, ptr %12, align 8, !tbaa !5
  call void @free(ptr noundef %230) #7
  %231 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %231) #7
  store ptr null, ptr %4, align 8
  store i32 1, ptr %22, align 4
  br label %232

232:                                              ; preds = %229, %209
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  %233 = load ptr, ptr %4, align 8
  ret ptr %233
}

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

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"string_t", !10, i64 0, !10, i64 8, !7, i64 16}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}


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

; 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: inlinehint nounwind uwtable
declare hidden zeroext i1 @str_resize(ptr noundef, i64 noundef) local_unnamed_addr #1

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

; 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 #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #5

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strstr(ptr noundef, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
define dso_local ptr @str_replaced(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #7 {
  %4 = alloca ptr, align 8
  %5 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #8
  %6 = load i64, ptr %0, align 8, !tbaa !5
  %7 = add i64 %6, 1
  %8 = tail call noalias ptr @malloc(i64 noundef %7) #9
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = tail call ptr @strncpy(ptr noundef %8, ptr noundef nonnull %9, i64 noundef %7) #10
  %11 = tail call noalias dereferenceable_or_null(128) ptr @malloc(i64 noundef 128) #9
  %12 = tail call noalias dereferenceable_or_null(128) ptr @malloc(i64 noundef 128) #9
  %13 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %1) #8
  %.not111 = icmp eq ptr %13, null
  br i1 %.not111, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %30
  %.091118 = phi i64 [ %21, %30 ], [ 0, %3 ]
  %.094116 = phi ptr [ %22, %30 ], [ %13, %3 ]
  %.095115 = phi ptr [ %.196, %30 ], [ %12, %3 ]
  %.097114 = phi ptr [ %.198, %30 ], [ %11, %3 ]
  %.099113 = phi i64 [ %.1100, %30 ], [ 16, %3 ]
  %.0101112 = phi ptr [ %20, %30 ], [ %8, %3 ]
  store i8 0, ptr %.094116, align 1, !tbaa !10
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.0101112) #8
  %15 = getelementptr inbounds i64, ptr %.095115, i64 %.091118
  store i64 %14, ptr %15, align 8, !tbaa !11
  %16 = add i64 %14, 1
  %17 = tail call noalias ptr @malloc(i64 noundef %16) #9
  %18 = getelementptr inbounds ptr, ptr %.097114, i64 %.091118
  store ptr %17, ptr %18, align 8, !tbaa !12
  %19 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %17, ptr noundef nonnull dereferenceable(1) %.0101112) #10
  %20 = getelementptr inbounds i8, ptr %.094116, i64 %5
  %21 = add i64 %.091118, 1
  %22 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %20, ptr noundef nonnull dereferenceable(1) %1) #8
  %23 = add i64 %.091118, 3
  %24 = icmp eq i64 %23, %.099113
  br i1 %24, label %25, label %30

25:                                               ; preds = %.lr.ph
  %26 = add i64 %.099113, 16
  %27 = shl i64 %26, 3
  %28 = tail call ptr @realloc(ptr noundef nonnull %.097114, i64 noundef %27) #11
  %29 = tail call ptr @realloc(ptr noundef nonnull %.095115, i64 noundef %27) #11
  br label %30

30:                                               ; preds = %25, %.lr.ph
  %.1100 = phi i64 [ %26, %25 ], [ %.099113, %.lr.ph ]
  %.198 = phi ptr [ %28, %25 ], [ %.097114, %.lr.ph ]
  %.196 = phi ptr [ %29, %25 ], [ %.095115, %.lr.ph ]
  %.not = icmp eq ptr %22, null
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %30, %3
  %.0101.lcssa = phi ptr [ %8, %3 ], [ %20, %30 ]
  %.097.lcssa = phi ptr [ %11, %3 ], [ %.198, %30 ]
  %.095.lcssa = phi ptr [ %12, %3 ], [ %.196, %30 ]
  %.092.lcssa = phi i64 [ 0, %3 ], [ %21, %30 ]
  %31 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.0101.lcssa) #8
  %32 = getelementptr inbounds i64, ptr %.095.lcssa, i64 %.092.lcssa
  store i64 %31, ptr %32, align 8, !tbaa !11
  %33 = add i64 %31, 1
  %34 = tail call noalias ptr @malloc(i64 noundef %33) #9
  %35 = getelementptr inbounds ptr, ptr %.097.lcssa, i64 %.092.lcssa
  store ptr %34, ptr %35, align 8, !tbaa !12
  %36 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %34, ptr noundef nonnull dereferenceable(1) %.0101.lcssa) #10
  %37 = add i64 %.092.lcssa, 1
  %38 = getelementptr inbounds ptr, ptr %.097.lcssa, i64 %37
  store ptr null, ptr %38, align 8, !tbaa !12
  tail call void @free(ptr noundef %8) #10
  %39 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #8
  %40 = load ptr, ptr %.097.lcssa, align 8, !tbaa !12
  %.not105123 = icmp eq ptr %40, null
  br i1 %.not105123, label %._crit_edge128, label %.lr.ph127

._crit_edge128:                                   ; preds = %.lr.ph127, %._crit_edge
  %.090.lcssa = phi i64 [ 0, %._crit_edge ], [ %spec.select, %.lr.ph127 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #10
  store ptr null, ptr %4, align 8, !tbaa !12
  %41 = call zeroext i1 @str_resize(ptr noundef nonnull %4, i64 noundef %.090.lcssa)
  %42 = load ptr, ptr %.097.lcssa, align 8, !tbaa !12
  %.not107134 = icmp eq ptr %42, null
  br i1 %41, label %.preheader, label %.preheader110

.preheader110:                                    ; preds = %._crit_edge128
  br i1 %.not107134, label %._crit_edge133, label %.lr.ph132

.preheader:                                       ; preds = %._crit_edge128
  br i1 %.not107134, label %._crit_edge138, label %.lr.ph137

.lr.ph127:                                        ; preds = %._crit_edge, %.lr.ph127
  %43 = phi ptr [ %49, %.lr.ph127 ], [ %40, %._crit_edge ]
  %.088125 = phi i64 [ %47, %.lr.ph127 ], [ 0, %._crit_edge ]
  %.090124 = phi i64 [ %spec.select, %.lr.ph127 ], [ 0, %._crit_edge ]
  %44 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %43) #8
  %.not109 = icmp eq i64 %.092.lcssa, %.088125
  %45 = select i1 %.not109, i64 0, i64 %39
  %46 = add i64 %45, %.090124
  %spec.select = add i64 %46, %44
  %47 = add i64 %.088125, 1
  %48 = getelementptr inbounds ptr, ptr %.097.lcssa, i64 %47
  %49 = load ptr, ptr %48, align 8, !tbaa !12
  %.not105 = icmp eq ptr %49, null
  br i1 %.not105, label %._crit_edge128, label %.lr.ph127, !llvm.loop !16

._crit_edge138:                                   ; preds = %66, %.preheader
  call void @free(ptr noundef nonnull %.097.lcssa) #10
  call void @free(ptr noundef %.095.lcssa) #10
  %50 = load ptr, ptr %4, align 8, !tbaa !12
  br label %75

.lr.ph137:                                        ; preds = %.preheader, %66
  %51 = phi ptr [ %70, %66 ], [ %42, %.preheader ]
  %.087136 = phi i64 [ %68, %66 ], [ 0, %.preheader ]
  %.193135 = phi i64 [ %.2, %66 ], [ 0, %.preheader ]
  %52 = getelementptr inbounds ptr, ptr %.097.lcssa, i64 %.087136
  %53 = load ptr, ptr %4, align 8, !tbaa !12
  %54 = getelementptr inbounds i8, ptr %53, i64 16
  %55 = getelementptr inbounds i8, ptr %54, i64 %.193135
  %56 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %55, ptr noundef nonnull dereferenceable(1) %51) #10
  %57 = getelementptr inbounds i64, ptr %.095.lcssa, i64 %.087136
  %58 = load i64, ptr %57, align 8, !tbaa !11
  %59 = add i64 %58, %.193135
  %.not108 = icmp eq i64 %.092.lcssa, %.087136
  br i1 %.not108, label %66, label %60

60:                                               ; preds = %.lr.ph137
  %61 = load ptr, ptr %4, align 8, !tbaa !12
  %62 = getelementptr inbounds i8, ptr %61, i64 16
  %63 = getelementptr inbounds i8, ptr %62, i64 %59
  %64 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %63, ptr noundef nonnull dereferenceable(1) %2) #10
  %65 = add i64 %59, %39
  br label %66

66:                                               ; preds = %60, %.lr.ph137
  %.2 = phi i64 [ %65, %60 ], [ %59, %.lr.ph137 ]
  %67 = load ptr, ptr %52, align 8, !tbaa !12
  call void @free(ptr noundef %67) #10
  %68 = add i64 %.087136, 1
  %69 = getelementptr inbounds ptr, ptr %.097.lcssa, i64 %68
  %70 = load ptr, ptr %69, align 8, !tbaa !12
  %.not107 = icmp eq ptr %70, null
  br i1 %.not107, label %._crit_edge138, label %.lr.ph137, !llvm.loop !17

._crit_edge133:                                   ; preds = %.lr.ph132, %.preheader110
  call void @free(ptr noundef nonnull %.097.lcssa) #10
  call void @free(ptr noundef %.095.lcssa) #10
  br label %75

.lr.ph132:                                        ; preds = %.preheader110, %.lr.ph132
  %71 = phi ptr [ %74, %.lr.ph132 ], [ %42, %.preheader110 ]
  %.0131 = phi i64 [ %72, %.lr.ph132 ], [ 0, %.preheader110 ]
  call void @free(ptr noundef nonnull %71) #10
  %72 = add i64 %.0131, 1
  %73 = getelementptr inbounds ptr, ptr %.097.lcssa, i64 %72
  %74 = load ptr, ptr %73, align 8, !tbaa !12
  %.not106 = icmp eq ptr %74, null
  br i1 %.not106, label %._crit_edge133, label %.lr.ph132, !llvm.loop !18

75:                                               ; preds = %._crit_edge133, %._crit_edge138
  %.089 = phi ptr [ %50, %._crit_edge138 ], [ null, %._crit_edge133 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #10
  ret ptr %.089
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #2 = { 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 #3 = { 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 #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 #8 = { nounwind willreturn memory(read) }
attributes #9 = { nounwind allocsize(0) }
attributes #10 = { nounwind }
attributes #11 = { nounwind allocsize(1) }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"string_t", !7, i64 0, !7, i64 8, !8, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}


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