; LLVM IR from KishanBGajera/2024-366-Days-Of-DSA :: Data Structures/Linear/Stack/Applications of Stack (infixToPostfix)

; 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: nounwind uwtable
declare dso_local i32 @prec(i8 noundef signext) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @infixToPostfix(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca [1000 x i8], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = call i64 @strlen(ptr noundef %10) #6
  %12 = trunc i64 %11 to i32
  store i32 %12, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %13 = load i32, ptr %3, align 4, !tbaa !9
  %14 = add nsw i32 %13, 1
  %15 = sext i32 %14 to i64
  %16 = mul i64 1, %15
  %17 = call noalias ptr @malloc(i64 noundef %16) #7
  store ptr %17, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1000, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 -1, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %126, %1
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %129

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #5
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i8, ptr %24, i64 %26
  %28 = load i8, ptr %27, align 1, !tbaa !11
  store i8 %28, ptr %9, align 1, !tbaa !11
  %29 = call ptr @__ctype_b_loc() #8
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = load i8, ptr %9, align 1, !tbaa !11
  %32 = sext i8 %31 to i32
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i16, ptr %30, i64 %33
  %35 = load i16, ptr %34, align 2, !tbaa !12
  %36 = zext i16 %35 to i32
  %37 = and i32 %36, 8
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %46

39:                                               ; preds = %23
  %40 = load i8, ptr %9, align 1, !tbaa !11
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %5, align 4, !tbaa !9
  %44 = sext i32 %42 to i64
  %45 = getelementptr inbounds i8, ptr %41, i64 %44
  store i8 %40, ptr %45, align 1, !tbaa !11
  br label %125

46:                                               ; preds = %23
  %47 = load i8, ptr %9, align 1, !tbaa !11
  %48 = sext i8 %47 to i32
  %49 = icmp eq i32 %48, 40
  br i1 %49, label %50, label %56

50:                                               ; preds = %46
  %51 = load i8, ptr %9, align 1, !tbaa !11
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %7, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1000 x i8], ptr %6, i64 0, i64 %54
  store i8 %51, ptr %55, align 1, !tbaa !11
  br label %124

56:                                               ; preds = %46
  %57 = load i8, ptr %9, align 1, !tbaa !11
  %58 = sext i8 %57 to i32
  %59 = icmp eq i32 %58, 41
  br i1 %59, label %60, label %87

60:                                               ; preds = %56
  br label %61

61:                                               ; preds = %73, %60
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = icmp sge i32 %62, 0
  br i1 %63, label %64, label %71

64:                                               ; preds = %61
  %65 = load i32, ptr %7, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1000 x i8], ptr %6, i64 0, i64 %66
  %68 = load i8, ptr %67, align 1, !tbaa !11
  %69 = sext i8 %68 to i32
  %70 = icmp ne i32 %69, 40
  br label %71

71:                                               ; preds = %64, %61
  %72 = phi i1 [ false, %61 ], [ %70, %64 ]
  br i1 %72, label %73, label %84

73:                                               ; preds = %71
  %74 = load i32, ptr %7, align 4, !tbaa !9
  %75 = add nsw i32 %74, -1
  store i32 %75, ptr %7, align 4, !tbaa !9
  %76 = sext i32 %74 to i64
  %77 = getelementptr inbounds [1000 x i8], ptr %6, i64 0, i64 %76
  %78 = load i8, ptr %77, align 1, !tbaa !11
  %79 = load ptr, ptr %4, align 8, !tbaa !5
  %80 = load i32, ptr %5, align 4, !tbaa !9
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %5, align 4, !tbaa !9
  %82 = sext i32 %80 to i64
  %83 = getelementptr inbounds i8, ptr %79, i64 %82
  store i8 %78, ptr %83, align 1, !tbaa !11
  br label %61, !llvm.loop !14

84:                                               ; preds = %71
  %85 = load i32, ptr %7, align 4, !tbaa !9
  %86 = add nsw i32 %85, -1
  store i32 %86, ptr %7, align 4, !tbaa !9
  br label %123

87:                                               ; preds = %56
  br label %88

88:                                               ; preds = %106, %87
  %89 = load i32, ptr %7, align 4, !tbaa !9
  %90 = icmp sge i32 %89, 0
  br i1 %90, label %91, label %104

91:                                               ; preds = %88
  %92 = load ptr, ptr %2, align 8, !tbaa !5
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds i8, ptr %92, i64 %94
  %96 = load i8, ptr %95, align 1, !tbaa !11
  %97 = call i32 @prec(i8 noundef signext %96)
  %98 = load i32, ptr %7, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [1000 x i8], ptr %6, i64 0, i64 %99
  %101 = load i8, ptr %100, align 1, !tbaa !11
  %102 = call i32 @prec(i8 noundef signext %101)
  %103 = icmp sle i32 %97, %102
  br label %104

104:                                              ; preds = %91, %88
  %105 = phi i1 [ false, %88 ], [ %103, %91 ]
  br i1 %105, label %106, label %117

106:                                              ; preds = %104
  %107 = load i32, ptr %7, align 4, !tbaa !9
  %108 = add nsw i32 %107, -1
  store i32 %108, ptr %7, align 4, !tbaa !9
  %109 = sext i32 %107 to i64
  %110 = getelementptr inbounds [1000 x i8], ptr %6, i64 0, i64 %109
  %111 = load i8, ptr %110, align 1, !tbaa !11
  %112 = load ptr, ptr %4, align 8, !tbaa !5
  %113 = load i32, ptr %5, align 4, !tbaa !9
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %5, align 4, !tbaa !9
  %115 = sext i32 %113 to i64
  %116 = getelementptr inbounds i8, ptr %112, i64 %115
  store i8 %111, ptr %116, align 1, !tbaa !11
  br label %88, !llvm.loop !16

117:                                              ; preds = %104
  %118 = load i8, ptr %9, align 1, !tbaa !11
  %119 = load i32, ptr %7, align 4, !tbaa !9
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %7, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [1000 x i8], ptr %6, i64 0, i64 %121
  store i8 %118, ptr %122, align 1, !tbaa !11
  br label %123

123:                                              ; preds = %117, %84
  br label %124

124:                                              ; preds = %123, %50
  br label %125

125:                                              ; preds = %124, %39
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #5
  br label %126

126:                                              ; preds = %125
  %127 = load i32, ptr %8, align 4, !tbaa !9
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %8, align 4, !tbaa !9
  br label %18, !llvm.loop !17

129:                                              ; preds = %22
  br label %130

130:                                              ; preds = %133, %129
  %131 = load i32, ptr %7, align 4, !tbaa !9
  %132 = icmp sge i32 %131, 0
  br i1 %132, label %133, label %144

133:                                              ; preds = %130
  %134 = load i32, ptr %7, align 4, !tbaa !9
  %135 = add nsw i32 %134, -1
  store i32 %135, ptr %7, align 4, !tbaa !9
  %136 = sext i32 %134 to i64
  %137 = getelementptr inbounds [1000 x i8], ptr %6, i64 0, i64 %136
  %138 = load i8, ptr %137, align 1, !tbaa !11
  %139 = load ptr, ptr %4, align 8, !tbaa !5
  %140 = load i32, ptr %5, align 4, !tbaa !9
  %141 = add nsw i32 %140, 1
  store i32 %141, ptr %5, align 4, !tbaa !9
  %142 = sext i32 %140 to i64
  %143 = getelementptr inbounds i8, ptr %139, i64 %142
  store i8 %138, ptr %143, align 1, !tbaa !11
  br label %130, !llvm.loop !18

144:                                              ; preds = %130
  %145 = load ptr, ptr %4, align 8, !tbaa !5
  %146 = load i32, ptr %5, align 4, !tbaa !9
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds i8, ptr %145, i64 %147
  store i8 0, ptr %148, align 1, !tbaa !11
  %149 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 1000, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret ptr %149
}

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

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

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

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #4

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

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

!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 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !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: nounwind uwtable
declare dso_local i32 @prec(i8 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @infixToPostfix(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = alloca [1000 x i8], align 16
  %3 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #5
  %4 = trunc i64 %3 to i32
  %5 = shl i64 %3, 32
  %sext = add i64 %5, 4294967296
  %6 = ashr exact i64 %sext, 32
  %7 = tail call noalias ptr @malloc(i64 noundef %6) #6
  call void @llvm.lifetime.start.p0(i64 1000, ptr nonnull %2) #7
  %8 = icmp sgt i32 %4, 0
  br i1 %8, label %.lr.ph66, label %._crit_edge

.lr.ph66:                                         ; preds = %1
  %9 = tail call ptr @__ctype_b_loc() #8
  %wide.trip.count = and i64 %3, 2147483647
  br label %19

.preheader:                                       ; preds = %67
  %10 = icmp sgt i32 %.342, -1
  br i1 %10, label %.lr.ph71.preheader, label %._crit_edge

.lr.ph71.preheader:                               ; preds = %.preheader
  %11 = sext i32 %.3 to i64
  %12 = zext nneg i32 %.342 to i64
  %13 = add nuw nsw i64 %12, 1
  %min.iters.check = icmp ult i32 %.342, 31
  br i1 %min.iters.check, label %.lr.ph71.preheader109, label %vector.ph

.lr.ph71.preheader109:                            ; preds = %middle.block, %.lr.ph71.preheader
  %indvars.iv86.ph = phi i64 [ %12, %.lr.ph71.preheader ], [ %ind.end, %middle.block ]
  %indvars.iv84.ph = phi i64 [ %11, %.lr.ph71.preheader ], [ %ind.end104, %middle.block ]
  br label %.lr.ph71

vector.ph:                                        ; preds = %.lr.ph71.preheader
  %n.vec = and i64 %13, 4294967264
  %ind.end = sub nsw i64 %12, %n.vec
  %ind.end104 = add nsw i64 %n.vec, %11
  %invariant.gep = getelementptr i8, ptr %7, i64 %11
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = sub i64 %12, %index
  %14 = getelementptr inbounds [1000 x i8], ptr %2, i64 0, i64 %offset.idx
  %15 = getelementptr inbounds i8, ptr %14, i64 -15
  %16 = getelementptr inbounds i8, ptr %14, i64 -31
  %wide.load = load <16 x i8>, ptr %15, align 1, !tbaa !5
  %reverse = shufflevector <16 x i8> %wide.load, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
  %wide.load107 = load <16 x i8>, ptr %16, align 1, !tbaa !5
  %reverse108 = shufflevector <16 x i8> %wide.load107, <16 x i8> poison, <16 x i32> <i32 15, i32 14, i32 13, i32 12, i32 11, i32 10, i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>
  %gep = getelementptr i8, ptr %invariant.gep, i64 %index
  %17 = getelementptr inbounds i8, ptr %gep, i64 16
  store <16 x i8> %reverse, ptr %gep, align 1, !tbaa !5
  store <16 x i8> %reverse108, ptr %17, align 1, !tbaa !5
  %index.next = add nuw i64 %index, 32
  %18 = icmp eq i64 %index.next, %n.vec
  br i1 %18, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %13, %n.vec
  br i1 %cmp.n, label %._crit_edge.loopexit, label %.lr.ph71.preheader109

19:                                               ; preds = %.lr.ph66, %67
  %indvars.iv81 = phi i64 [ 0, %.lr.ph66 ], [ %indvars.iv.next82, %67 ]
  %.065 = phi i32 [ 0, %.lr.ph66 ], [ %.3, %67 ]
  %.03963 = phi i32 [ -1, %.lr.ph66 ], [ %.342, %67 ]
  %20 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv81
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = load ptr, ptr %9, align 8, !tbaa !12
  %23 = sext i8 %21 to i64
  %24 = getelementptr inbounds i16, ptr %22, i64 %23
  %25 = load i16, ptr %24, align 2, !tbaa !14
  %26 = and i16 %25, 8
  %.not = icmp eq i16 %26, 0
  br i1 %.not, label %31, label %27

27:                                               ; preds = %19
  %28 = add nsw i32 %.065, 1
  %29 = sext i32 %.065 to i64
  %30 = getelementptr inbounds i8, ptr %7, i64 %29
  store i8 %21, ptr %30, align 1, !tbaa !5
  br label %67

31:                                               ; preds = %19
  switch i8 %21, label %.preheader47 [
    i8 40, label %41
    i8 41, label %.preheader48
  ]

.preheader48:                                     ; preds = %31
  %32 = icmp sgt i32 %.03963, -1
  br i1 %32, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %.preheader48
  %33 = sext i32 %.065 to i64
  %34 = add i32 %.065, 1
  %35 = add i32 %34, %.03963
  br label %.lr.ph

.preheader47:                                     ; preds = %31
  %36 = icmp sgt i32 %.03963, -1
  br i1 %36, label %.lr.ph57.preheader, label %.critedge2

.lr.ph57.preheader:                               ; preds = %.preheader47
  %37 = sext i32 %.065 to i64
  %38 = zext nneg i32 %.03963 to i64
  %39 = add i32 %.065, 1
  %40 = add i32 %39, %.03963
  br label %.lr.ph57

41:                                               ; preds = %31
  %42 = add nsw i32 %.03963, 1
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1000 x i8], ptr %2, i64 0, i64 %43
  store i8 40, ptr %44, align 1, !tbaa !5
  br label %67

.lr.ph:                                           ; preds = %.lr.ph.preheader, %48
  %indvars.iv = phi i64 [ %33, %.lr.ph.preheader ], [ %indvars.iv.next, %48 ]
  %.14049 = phi i32 [ %.03963, %.lr.ph.preheader ], [ %49, %48 ]
  %45 = zext nneg i32 %.14049 to i64
  %46 = getelementptr inbounds [1000 x i8], ptr %2, i64 0, i64 %45
  %47 = load i8, ptr %46, align 1, !tbaa !5
  %.not46 = icmp eq i8 %47, 40
  br i1 %.not46, label %.critedge.loopexit.split.loop.exit93, label %48

48:                                               ; preds = %.lr.ph
  %49 = add nsw i32 %.14049, -1
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %50 = getelementptr inbounds i8, ptr %7, i64 %indvars.iv
  store i8 %47, ptr %50, align 1, !tbaa !5
  %51 = icmp sgt i32 %.14049, 0
  br i1 %51, label %.lr.ph, label %.critedge, !llvm.loop !16

.critedge.loopexit.split.loop.exit93:             ; preds = %.lr.ph
  %52 = trunc nsw i64 %indvars.iv to i32
  br label %.critedge

.critedge:                                        ; preds = %48, %.critedge.loopexit.split.loop.exit93, %.preheader48
  %.140.lcssa = phi i32 [ %.03963, %.preheader48 ], [ %.14049, %.critedge.loopexit.split.loop.exit93 ], [ -1, %48 ]
  %.1.lcssa = phi i32 [ %.065, %.preheader48 ], [ %52, %.critedge.loopexit.split.loop.exit93 ], [ %35, %48 ]
  %53 = add nsw i32 %.140.lcssa, -1
  br label %67

.lr.ph57:                                         ; preds = %.lr.ph57.preheader, %59
  %indvars.iv76 = phi i64 [ %38, %.lr.ph57.preheader ], [ %indvars.iv.next77, %59 ]
  %indvars.iv74 = phi i64 [ %37, %.lr.ph57.preheader ], [ %indvars.iv.next75, %59 ]
  %54 = load i8, ptr %20, align 1, !tbaa !5
  %55 = tail call i32 @prec(i8 noundef signext %54)
  %56 = getelementptr inbounds [1000 x i8], ptr %2, i64 0, i64 %indvars.iv76
  %57 = load i8, ptr %56, align 1, !tbaa !5
  %58 = tail call i32 @prec(i8 noundef signext %57)
  %.not45 = icmp sgt i32 %55, %58
  br i1 %.not45, label %.critedge2.loopexit.split.loop.exit96, label %59

59:                                               ; preds = %.lr.ph57
  %indvars.iv.next77 = add nsw i64 %indvars.iv76, -1
  %indvars.iv.next75 = add nsw i64 %indvars.iv74, 1
  %60 = getelementptr inbounds i8, ptr %7, i64 %indvars.iv74
  store i8 %57, ptr %60, align 1, !tbaa !5
  %61 = icmp sgt i64 %indvars.iv76, 0
  br i1 %61, label %.lr.ph57, label %.critedge2, !llvm.loop !17

.critedge2.loopexit.split.loop.exit96:            ; preds = %.lr.ph57
  %62 = trunc nsw i64 %indvars.iv74 to i32
  %63 = trunc nuw nsw i64 %indvars.iv76 to i32
  br label %.critedge2

.critedge2:                                       ; preds = %59, %.critedge2.loopexit.split.loop.exit96, %.preheader47
  %.241.lcssa = phi i32 [ %.03963, %.preheader47 ], [ %63, %.critedge2.loopexit.split.loop.exit96 ], [ -1, %59 ]
  %.2.lcssa = phi i32 [ %.065, %.preheader47 ], [ %62, %.critedge2.loopexit.split.loop.exit96 ], [ %40, %59 ]
  %64 = add nsw i32 %.241.lcssa, 1
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1000 x i8], ptr %2, i64 0, i64 %65
  store i8 %21, ptr %66, align 1, !tbaa !5
  br label %67

67:                                               ; preds = %41, %.critedge2, %.critedge, %27
  %.342 = phi i32 [ %.03963, %27 ], [ %42, %41 ], [ %53, %.critedge ], [ %64, %.critedge2 ]
  %.3 = phi i32 [ %28, %27 ], [ %.065, %41 ], [ %.1.lcssa, %.critedge ], [ %.2.lcssa, %.critedge2 ]
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next82, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %19, !llvm.loop !18

.lr.ph71:                                         ; preds = %.lr.ph71.preheader109, %.lr.ph71
  %indvars.iv86 = phi i64 [ %indvars.iv.next87, %.lr.ph71 ], [ %indvars.iv86.ph, %.lr.ph71.preheader109 ]
  %indvars.iv84 = phi i64 [ %indvars.iv.next85, %.lr.ph71 ], [ %indvars.iv84.ph, %.lr.ph71.preheader109 ]
  %indvars.iv.next87 = add nsw i64 %indvars.iv86, -1
  %68 = getelementptr inbounds [1000 x i8], ptr %2, i64 0, i64 %indvars.iv86
  %69 = load i8, ptr %68, align 1, !tbaa !5
  %indvars.iv.next85 = add nsw i64 %indvars.iv84, 1
  %70 = getelementptr inbounds i8, ptr %7, i64 %indvars.iv84
  store i8 %69, ptr %70, align 1, !tbaa !5
  %.not99 = icmp eq i64 %indvars.iv86, 0
  br i1 %.not99, label %._crit_edge.loopexit, label %.lr.ph71, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %.lr.ph71, %middle.block
  %indvars.iv.next85.lcssa = phi i64 [ %ind.end104, %middle.block ], [ %indvars.iv.next85, %.lr.ph71 ]
  %71 = trunc nsw i64 %indvars.iv.next85.lcssa to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %1, %._crit_edge.loopexit, %.preheader
  %.4.lcssa = phi i32 [ %.3, %.preheader ], [ %71, %._crit_edge.loopexit ], [ 0, %1 ]
  %72 = sext i32 %.4.lcssa to i64
  %73 = getelementptr inbounds i8, ptr %7, i64 %72
  store i8 0, ptr %73, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1000, ptr nonnull %2) #7
  ret ptr %7
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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 allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #4

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

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !6, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"short", !6, i64 0}
!16 = distinct !{!16, !9}
!17 = distinct !{!17, !9}
!18 = distinct !{!18, !9}
!19 = distinct !{!19, !9, !11, !10}


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