; LLVM IR from marcobambini/gravity :: src/utils (gravity_utils)

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

; 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

declare ptr @gravity_calloc(ptr noundef, i64 noundef, i64 noundef) #1

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

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

; 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) #4

; Function Attrs: nounwind uwtable
define dso_local ptr @string_replace(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #5 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = 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
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 16, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  store i64 3, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store i64 1048576, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %26, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  store i64 0, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  store ptr null, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  store i64 0, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  store i64 0, ptr %23, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #6
  store i64 0, ptr %24, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #6
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call i64 @strlen(ptr noundef %27) #7
  store i64 %28, ptr %25, align 8, !tbaa !9
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = icmp ne ptr %29, null
  br i1 %30, label %31, label %33

31:                                               ; preds = %4
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 0, ptr %32, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %31, %4
  br label %34

34:                                               ; preds = %65, %33
  %35 = load ptr, ptr %15, align 8, !tbaa !5
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = call ptr @strstr(ptr noundef %35, ptr noundef %36) #7
  store ptr %37, ptr %14, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %78

39:                                               ; preds = %34
  %40 = load i64, ptr %17, align 8, !tbaa !9
  %41 = add i64 %40, 1
  store i64 %41, ptr %17, align 8, !tbaa !9
  %42 = load i64, ptr %20, align 8, !tbaa !9
  %43 = load i64, ptr %17, align 8, !tbaa !9
  %44 = icmp ult i64 %42, %43
  br i1 %44, label %45, label %65

45:                                               ; preds = %39
  %46 = load i64, ptr %9, align 8, !tbaa !9
  %47 = load i64, ptr %20, align 8, !tbaa !9
  %48 = add i64 %47, %46
  store i64 %48, ptr %20, align 8, !tbaa !9
  %49 = load ptr, ptr %19, align 8, !tbaa !5
  %50 = load i64, ptr %20, align 8, !tbaa !9
  %51 = mul i64 8, %50
  %52 = call ptr @gravity_realloc(ptr noundef null, ptr noundef %49, i64 noundef %51)
  store ptr %52, ptr %18, align 8, !tbaa !5
  %53 = load ptr, ptr %18, align 8, !tbaa !5
  %54 = icmp eq ptr %53, null
  br i1 %54, label %55, label %56

55:                                               ; preds = %45
  br label %181

56:                                               ; preds = %45
  %57 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %57, ptr %19, align 8, !tbaa !5
  br label %58

58:                                               ; preds = %56
  %59 = load i64, ptr %9, align 8, !tbaa !9
  %60 = mul i64 %59, 3
  store i64 %60, ptr %9, align 8, !tbaa !9
  %61 = load i64, ptr %9, align 8, !tbaa !9
  %62 = icmp ugt i64 %61, 1048576
  br i1 %62, label %63, label %64

63:                                               ; preds = %58
  store i64 1048576, ptr %9, align 8, !tbaa !9
  br label %64

64:                                               ; preds = %63, %58
  br label %65

65:                                               ; preds = %64, %39
  %66 = load ptr, ptr %14, align 8, !tbaa !5
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = ptrtoint ptr %66 to i64
  %69 = ptrtoint ptr %67 to i64
  %70 = sub i64 %68, %69
  %71 = load ptr, ptr %19, align 8, !tbaa !5
  %72 = load i64, ptr %17, align 8, !tbaa !9
  %73 = sub i64 %72, 1
  %74 = getelementptr inbounds i64, ptr %71, i64 %73
  store i64 %70, ptr %74, align 8, !tbaa !9
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = load i64, ptr %25, align 8, !tbaa !9
  %77 = getelementptr inbounds i8, ptr %75, i64 %76
  store ptr %77, ptr %15, align 8, !tbaa !5
  br label %34, !llvm.loop !11

78:                                               ; preds = %34
  %79 = load ptr, ptr %15, align 8, !tbaa !5
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = ptrtoint ptr %79 to i64
  %82 = ptrtoint ptr %80 to i64
  %83 = sub i64 %81, %82
  %84 = load ptr, ptr %15, align 8, !tbaa !5
  %85 = call i64 @strlen(ptr noundef %84) #7
  %86 = add i64 %83, %85
  store i64 %86, ptr %22, align 8, !tbaa !9
  %87 = load i64, ptr %17, align 8, !tbaa !9
  %88 = icmp ugt i64 %87, 0
  br i1 %88, label %89, label %99

89:                                               ; preds = %78
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = call i64 @strlen(ptr noundef %90) #7
  store i64 %91, ptr %24, align 8, !tbaa !9
  %92 = load i64, ptr %22, align 8, !tbaa !9
  %93 = load i64, ptr %24, align 8, !tbaa !9
  %94 = load i64, ptr %25, align 8, !tbaa !9
  %95 = sub i64 %93, %94
  %96 = load i64, ptr %17, align 8, !tbaa !9
  %97 = mul i64 %95, %96
  %98 = add i64 %92, %97
  store i64 %98, ptr %23, align 8, !tbaa !9
  br label %101

99:                                               ; preds = %78
  %100 = load i64, ptr %22, align 8, !tbaa !9
  store i64 %100, ptr %23, align 8, !tbaa !9
  br label %101

101:                                              ; preds = %99, %89
  %102 = load i64, ptr %23, align 8, !tbaa !9
  %103 = add i64 %102, 1
  %104 = call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef %103)
  store ptr %104, ptr %13, align 8, !tbaa !5
  %105 = load ptr, ptr %13, align 8, !tbaa !5
  %106 = icmp eq ptr %105, null
  br i1 %106, label %107, label %108

107:                                              ; preds = %101
  br label %181

108:                                              ; preds = %101
  %109 = load i64, ptr %17, align 8, !tbaa !9
  %110 = icmp eq i64 %109, 0
  br i1 %110, label %111, label %115

111:                                              ; preds = %108
  %112 = load ptr, ptr %13, align 8, !tbaa !5
  %113 = load ptr, ptr %5, align 8, !tbaa !5
  %114 = call ptr @strcpy(ptr noundef %112, ptr noundef %113) #6
  br label %180

115:                                              ; preds = %108
  %116 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %116, ptr %12, align 8, !tbaa !5
  %117 = load ptr, ptr %12, align 8, !tbaa !5
  %118 = load ptr, ptr %5, align 8, !tbaa !5
  %119 = load ptr, ptr %19, align 8, !tbaa !5
  %120 = getelementptr inbounds i64, ptr %119, i64 0
  %121 = load i64, ptr %120, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %117, ptr align 1 %118, i64 %121, i1 false)
  %122 = load ptr, ptr %19, align 8, !tbaa !5
  %123 = getelementptr inbounds i64, ptr %122, i64 0
  %124 = load i64, ptr %123, align 8, !tbaa !9
  %125 = load ptr, ptr %12, align 8, !tbaa !5
  %126 = getelementptr inbounds i8, ptr %125, i64 %124
  store ptr %126, ptr %12, align 8, !tbaa !5
  store i64 0, ptr %16, align 8, !tbaa !9
  br label %127

127:                                              ; preds = %173, %115
  %128 = load i64, ptr %16, align 8, !tbaa !9
  %129 = load i64, ptr %17, align 8, !tbaa !9
  %130 = icmp ult i64 %128, %129
  br i1 %130, label %131, label %176

131:                                              ; preds = %127
  %132 = load ptr, ptr %12, align 8, !tbaa !5
  %133 = load ptr, ptr %7, align 8, !tbaa !5
  %134 = load i64, ptr %24, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %132, ptr align 1 %133, i64 %134, i1 false)
  %135 = load i64, ptr %24, align 8, !tbaa !9
  %136 = load ptr, ptr %12, align 8, !tbaa !5
  %137 = getelementptr inbounds i8, ptr %136, i64 %135
  store ptr %137, ptr %12, align 8, !tbaa !5
  %138 = load ptr, ptr %5, align 8, !tbaa !5
  %139 = load ptr, ptr %19, align 8, !tbaa !5
  %140 = load i64, ptr %16, align 8, !tbaa !9
  %141 = getelementptr inbounds i64, ptr %139, i64 %140
  %142 = load i64, ptr %141, align 8, !tbaa !9
  %143 = getelementptr inbounds i8, ptr %138, i64 %142
  %144 = load i64, ptr %25, align 8, !tbaa !9
  %145 = getelementptr inbounds i8, ptr %143, i64 %144
  store ptr %145, ptr %15, align 8, !tbaa !5
  %146 = load i64, ptr %16, align 8, !tbaa !9
  %147 = load i64, ptr %17, align 8, !tbaa !9
  %148 = sub i64 %147, 1
  %149 = icmp eq i64 %146, %148
  br i1 %149, label %150, label %152

150:                                              ; preds = %131
  %151 = load i64, ptr %22, align 8, !tbaa !9
  br label %158

152:                                              ; preds = %131
  %153 = load ptr, ptr %19, align 8, !tbaa !5
  %154 = load i64, ptr %16, align 8, !tbaa !9
  %155 = add i64 %154, 1
  %156 = getelementptr inbounds i64, ptr %153, i64 %155
  %157 = load i64, ptr %156, align 8, !tbaa !9
  br label %158

158:                                              ; preds = %152, %150
  %159 = phi i64 [ %151, %150 ], [ %157, %152 ]
  %160 = load ptr, ptr %19, align 8, !tbaa !5
  %161 = load i64, ptr %16, align 8, !tbaa !9
  %162 = getelementptr inbounds i64, ptr %160, i64 %161
  %163 = load i64, ptr %162, align 8, !tbaa !9
  %164 = sub i64 %159, %163
  %165 = load i64, ptr %25, align 8, !tbaa !9
  %166 = sub i64 %164, %165
  store i64 %166, ptr %21, align 8, !tbaa !9
  %167 = load ptr, ptr %12, align 8, !tbaa !5
  %168 = load ptr, ptr %15, align 8, !tbaa !5
  %169 = load i64, ptr %21, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %167, ptr align 1 %168, i64 %169, i1 false)
  %170 = load i64, ptr %21, align 8, !tbaa !9
  %171 = load ptr, ptr %12, align 8, !tbaa !5
  %172 = getelementptr inbounds i8, ptr %171, i64 %170
  store ptr %172, ptr %12, align 8, !tbaa !5
  br label %173

173:                                              ; preds = %158
  %174 = load i64, ptr %16, align 8, !tbaa !9
  %175 = add i64 %174, 1
  store i64 %175, ptr %16, align 8, !tbaa !9
  br label %127, !llvm.loop !13

176:                                              ; preds = %127
  %177 = load ptr, ptr %13, align 8, !tbaa !5
  %178 = load i64, ptr %23, align 8, !tbaa !9
  %179 = getelementptr inbounds i8, ptr %177, i64 %178
  store i8 0, ptr %179, align 1, !tbaa !14
  br label %180

180:                                              ; preds = %176, %111
  br label %181

181:                                              ; preds = %180, %107, %55
  %182 = load ptr, ptr %19, align 8, !tbaa !5
  call void @free(ptr noundef %182) #6
  %183 = load ptr, ptr %8, align 8, !tbaa !5
  %184 = icmp ne ptr %183, null
  br i1 %184, label %185, label %191

185:                                              ; preds = %181
  %186 = load ptr, ptr %13, align 8, !tbaa !5
  %187 = icmp ne ptr %186, null
  br i1 %187, label %188, label %191

188:                                              ; preds = %185
  %189 = load i64, ptr %23, align 8, !tbaa !9
  %190 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %189, ptr %190, align 8, !tbaa !9
  br label %191

191:                                              ; preds = %188, %185, %181
  %192 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  ret ptr %192
}

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

declare ptr @gravity_realloc(ptr noundef, ptr noundef, i64 noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #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 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!7, !7, i64 0}


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

declare ptr @gravity_calloc(ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture 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 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) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @string_replace(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr noundef writeonly %3) local_unnamed_addr #4 {
  %5 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #7
  %.not110 = icmp eq ptr %3, null
  br i1 %.not110, label %7, label %6

6:                                                ; preds = %4
  store i64 0, ptr %3, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %6, %4
  %8 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %0, ptr noundef nonnull dereferenceable(1) %1) #7
  %.not117 = icmp eq ptr %8, null
  %.pre = ptrtoint ptr %0 to i64
  br i1 %.not117, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %7, %19
  %9 = phi ptr [ %24, %19 ], [ %8, %7 ]
  %.0121 = phi i64 [ %.1, %19 ], [ 16, %7 ]
  %.082120 = phi i64 [ %.183, %19 ], [ 0, %7 ]
  %.084119 = phi ptr [ %.185, %19 ], [ null, %7 ]
  %.087118 = phi i64 [ %10, %19 ], [ 0, %7 ]
  %10 = add i64 %.087118, 1
  %11 = icmp ult i64 %.082120, %10
  br i1 %11, label %12, label %19

12:                                               ; preds = %.lr.ph
  %13 = add i64 %.0121, %.082120
  %14 = shl i64 %13, 3
  %15 = tail call ptr @gravity_realloc(ptr noundef null, ptr noundef %.084119, i64 noundef %14) #8
  %16 = icmp eq ptr %15, null
  br i1 %16, label %.thread105, label %17

17:                                               ; preds = %12
  %18 = mul i64 %.0121, 3
  %spec.store.select = tail call i64 @llvm.umin.i64(i64 %18, i64 1048576)
  br label %19

19:                                               ; preds = %17, %.lr.ph
  %.185 = phi ptr [ %15, %17 ], [ %.084119, %.lr.ph ]
  %.183 = phi i64 [ %13, %17 ], [ %.082120, %.lr.ph ]
  %.1 = phi i64 [ %spec.store.select, %17 ], [ %.0121, %.lr.ph ]
  %20 = ptrtoint ptr %9 to i64
  %21 = sub i64 %20, %.pre
  %22 = getelementptr inbounds i64, ptr %.185, i64 %.087118
  store i64 %21, ptr %22, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %9, i64 %5
  %24 = tail call ptr @strstr(ptr noundef nonnull dereferenceable(1) %23, ptr noundef nonnull dereferenceable(1) %1) #7
  %.not = icmp eq ptr %24, null
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %19
  %.pre132 = ptrtoint ptr %23 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %7, %._crit_edge.loopexit
  %.pre-phi133 = phi i64 [ %.pre132, %._crit_edge.loopexit ], [ %.pre, %7 ]
  %.087.lcssa = phi i64 [ %10, %._crit_edge.loopexit ], [ 0, %7 ]
  %.086.lcssa = phi ptr [ %23, %._crit_edge.loopexit ], [ %0, %7 ]
  %.084.lcssa = phi ptr [ %.185, %._crit_edge.loopexit ], [ null, %7 ]
  %25 = sub i64 %.pre-phi133, %.pre
  %26 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %.086.lcssa) #7
  %27 = add i64 %26, %25
  %.not95 = icmp eq i64 %.087.lcssa, 0
  br i1 %.not95, label %28, label %.thread

28:                                               ; preds = %._crit_edge
  %29 = add i64 %27, 1
  %30 = tail call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef %29) #8
  %31 = icmp eq ptr %30, null
  br i1 %31, label %.thread105, label %39

.thread:                                          ; preds = %._crit_edge
  %32 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %2) #7
  %33 = sub i64 %32, %5
  %34 = mul i64 %33, %.087.lcssa
  %35 = add i64 %34, %27
  %36 = add i64 %35, 1
  %37 = tail call ptr @gravity_calloc(ptr noundef null, i64 noundef 1, i64 noundef %36) #8
  %38 = icmp eq ptr %37, null
  br i1 %38, label %.thread105, label %41

39:                                               ; preds = %28
  %40 = tail call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %30, ptr noundef nonnull dereferenceable(1) %0) #8
  br label %60

41:                                               ; preds = %.thread
  %42 = load i64, ptr %.084.lcssa, align 8, !tbaa !5
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %37, ptr align 1 %0, i64 %42, i1 false)
  %43 = load i64, ptr %.084.lcssa, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %37, i64 %43
  %invariant.gep = getelementptr i8, ptr %0, i64 %5
  %45 = add i64 %.087.lcssa, -1
  br label %46

46:                                               ; preds = %41, %._crit_edge129
  %.080125 = phi ptr [ %44, %41 ], [ %57, %._crit_edge129 ]
  %.088124 = phi i64 [ 0, %41 ], [ %.pre130, %._crit_edge129 ]
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.080125, ptr align 1 %2, i64 %32, i1 false)
  %47 = getelementptr inbounds i8, ptr %.080125, i64 %32
  %48 = getelementptr inbounds i64, ptr %.084.lcssa, i64 %.088124
  %49 = load i64, ptr %48, align 8, !tbaa !5
  %gep = getelementptr i8, ptr %invariant.gep, i64 %49
  %50 = icmp eq i64 %.088124, %45
  %.pre130 = add nuw i64 %.088124, 1
  br i1 %50, label %._crit_edge129, label %51

51:                                               ; preds = %46
  %52 = getelementptr inbounds i64, ptr %.084.lcssa, i64 %.pre130
  %53 = load i64, ptr %52, align 8, !tbaa !5
  br label %._crit_edge129

._crit_edge129:                                   ; preds = %46, %51
  %54 = phi i64 [ %53, %51 ], [ %27, %46 ]
  %55 = add i64 %49, %5
  %56 = sub i64 %54, %55
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 1 %47, ptr align 1 %gep, i64 %56, i1 false)
  %57 = getelementptr inbounds i8, ptr %47, i64 %56
  %exitcond.not = icmp eq i64 %.pre130, %.087.lcssa
  br i1 %exitcond.not, label %58, label %46, !llvm.loop !11

58:                                               ; preds = %._crit_edge129
  %59 = getelementptr inbounds i8, ptr %37, i64 %35
  store i8 0, ptr %59, align 1, !tbaa !12
  br label %60

.thread105:                                       ; preds = %12, %28, %.thread
  %.084114 = phi ptr [ %.084.lcssa, %28 ], [ %.084.lcssa, %.thread ], [ %.084119, %12 ]
  tail call void @free(ptr noundef %.084114) #8
  br label %62

60:                                               ; preds = %39, %58
  %.081 = phi ptr [ %30, %39 ], [ %37, %58 ]
  %.179 = phi i64 [ %27, %39 ], [ %35, %58 ]
  tail call void @free(ptr noundef %.084.lcssa) #8
  br i1 %.not110, label %62, label %61

61:                                               ; preds = %60
  store i64 %.179, ptr %3, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %.thread105, %61, %60
  %.081109 = phi ptr [ null, %.thread105 ], [ %.081, %61 ], [ %.081, %60 ]
  ret ptr %.081109
}

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

declare ptr @gravity_realloc(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #6

attributes #0 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!7, !7, i64 0}


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