; LLVM IR from aagdev/mlimgsynth :: src (tensor_name_conv)

; 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.StrSlice = type { ptr, i64 }

@g_allocator_dopt = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @tnconv_prefix_match_replace(ptr noundef, ptr noundef, ptr, i64, ptr, i64) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @dynbuf_append(ptr noundef, i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @tnconv_number_match_push(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @tnconv_clip_diffusers(ptr %0, i64 %1, ptr noundef %2) #1 {
  %4 = alloca %struct.StrSlice, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.StrSlice, align 8
  %8 = alloca %struct.StrSlice, align 8
  %9 = alloca %struct.StrSlice, align 8
  %10 = alloca %struct.StrSlice, align 8
  %11 = alloca %struct.StrSlice, align 8
  %12 = alloca %struct.StrSlice, align 8
  %13 = alloca %struct.StrSlice, align 8
  %14 = alloca %struct.StrSlice, align 8
  %15 = alloca %struct.StrSlice, align 8
  %16 = alloca %struct.StrSlice, align 8
  %17 = alloca %struct.StrSlice, align 8
  %18 = alloca %struct.StrSlice, align 8
  %19 = getelementptr inbounds { ptr, i64 }, ptr %4, i32 0, i32 0
  store ptr %0, ptr %19, align 8
  %20 = getelementptr inbounds { ptr, i64 }, ptr %4, i32 0, i32 1
  store i64 %1, ptr %20, align 8
  store ptr %2, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.StrSlice, ptr %7, i32 0, i32 0
  store ptr @.str.34, ptr %22, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.StrSlice, ptr %7, i32 0, i32 1
  store i64 11, ptr %23, align 8, !tbaa !14
  %24 = getelementptr inbounds %struct.StrSlice, ptr %8, i32 0, i32 0
  store ptr @.str.1, ptr %24, align 8, !tbaa !11
  %25 = getelementptr inbounds %struct.StrSlice, ptr %8, i32 0, i32 1
  store i64 5, ptr %25, align 8, !tbaa !14
  %26 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8
  %28 = getelementptr inbounds { ptr, i64 }, ptr %7, i32 0, i32 1
  %29 = load i64, ptr %28, align 8
  %30 = getelementptr inbounds { ptr, i64 }, ptr %8, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8
  %32 = getelementptr inbounds { ptr, i64 }, ptr %8, i32 0, i32 1
  %33 = load i64, ptr %32, align 8
  %34 = call i32 @tnconv_prefix_match_replace(ptr noundef %4, ptr noundef %21, ptr %27, i64 %29, ptr %31, i64 %33)
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %127

36:                                               ; preds = %3
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.StrSlice, ptr %9, i32 0, i32 0
  store ptr @.str.8, ptr %38, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct.StrSlice, ptr %9, i32 0, i32 1
  store i64 15, ptr %39, align 8, !tbaa !14
  %40 = getelementptr inbounds %struct.StrSlice, ptr %10, i32 0, i32 0
  store ptr @.str.8, ptr %40, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct.StrSlice, ptr %10, i32 0, i32 1
  store i64 15, ptr %41, align 8, !tbaa !14
  %42 = getelementptr inbounds { ptr, i64 }, ptr %9, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8
  %44 = getelementptr inbounds { ptr, i64 }, ptr %9, i32 0, i32 1
  %45 = load i64, ptr %44, align 8
  %46 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8
  %48 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 1
  %49 = load i64, ptr %48, align 8
  %50 = call i32 @tnconv_prefix_match_replace(ptr noundef %4, ptr noundef %37, ptr %43, i64 %45, ptr %47, i64 %49)
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %126

52:                                               ; preds = %36
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = call i32 @tnconv_number_match_push(ptr noundef %4, ptr noundef %53)
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.StrSlice, ptr %11, i32 0, i32 0
  store ptr @.str.25, ptr %56, align 8, !tbaa !11
  %57 = getelementptr inbounds %struct.StrSlice, ptr %11, i32 0, i32 1
  store i64 5, ptr %57, align 8, !tbaa !14
  %58 = getelementptr inbounds %struct.StrSlice, ptr %12, i32 0, i32 0
  store ptr @.str.10, ptr %58, align 8, !tbaa !11
  %59 = getelementptr inbounds %struct.StrSlice, ptr %12, i32 0, i32 1
  store i64 6, ptr %59, align 8, !tbaa !14
  %60 = getelementptr inbounds { ptr, i64 }, ptr %11, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8
  %62 = getelementptr inbounds { ptr, i64 }, ptr %11, i32 0, i32 1
  %63 = load i64, ptr %62, align 8
  %64 = getelementptr inbounds { ptr, i64 }, ptr %12, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8
  %66 = getelementptr inbounds { ptr, i64 }, ptr %12, i32 0, i32 1
  %67 = load i64, ptr %66, align 8
  %68 = call i32 @tnconv_prefix_match_replace(ptr noundef %4, ptr noundef %55, ptr %61, i64 %63, ptr %65, i64 %67)
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %71

70:                                               ; preds = %52
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %125

71:                                               ; preds = %52
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.StrSlice, ptr %13, i32 0, i32 0
  store ptr @.str.26, ptr %73, align 8, !tbaa !11
  %74 = getelementptr inbounds %struct.StrSlice, ptr %13, i32 0, i32 1
  store i64 5, ptr %74, align 8, !tbaa !14
  %75 = getelementptr inbounds %struct.StrSlice, ptr %14, i32 0, i32 0
  store ptr @.str.12, ptr %75, align 8, !tbaa !11
  %76 = getelementptr inbounds %struct.StrSlice, ptr %14, i32 0, i32 1
  store i64 6, ptr %76, align 8, !tbaa !14
  %77 = getelementptr inbounds { ptr, i64 }, ptr %13, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8
  %79 = getelementptr inbounds { ptr, i64 }, ptr %13, i32 0, i32 1
  %80 = load i64, ptr %79, align 8
  %81 = getelementptr inbounds { ptr, i64 }, ptr %14, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8
  %83 = getelementptr inbounds { ptr, i64 }, ptr %14, i32 0, i32 1
  %84 = load i64, ptr %83, align 8
  %85 = call i32 @tnconv_prefix_match_replace(ptr noundef %4, ptr noundef %72, ptr %78, i64 %80, ptr %82, i64 %84)
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %88

87:                                               ; preds = %71
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %124

88:                                               ; preds = %71
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.StrSlice, ptr %15, i32 0, i32 0
  store ptr @.str.13, ptr %90, align 8, !tbaa !11
  %91 = getelementptr inbounds %struct.StrSlice, ptr %15, i32 0, i32 1
  store i64 10, ptr %91, align 8, !tbaa !14
  %92 = getelementptr inbounds %struct.StrSlice, ptr %16, i32 0, i32 0
  store ptr @.str.14, ptr %92, align 8, !tbaa !11
  %93 = getelementptr inbounds %struct.StrSlice, ptr %16, i32 0, i32 1
  store i64 5, ptr %93, align 8, !tbaa !14
  %94 = getelementptr inbounds { ptr, i64 }, ptr %15, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8
  %96 = getelementptr inbounds { ptr, i64 }, ptr %15, i32 0, i32 1
  %97 = load i64, ptr %96, align 8
  %98 = getelementptr inbounds { ptr, i64 }, ptr %16, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8
  %100 = getelementptr inbounds { ptr, i64 }, ptr %16, i32 0, i32 1
  %101 = load i64, ptr %100, align 8
  %102 = call i32 @tnconv_prefix_match_replace(ptr noundef %4, ptr noundef %89, ptr %95, i64 %97, ptr %99, i64 %101)
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %105

104:                                              ; preds = %88
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %123

105:                                              ; preds = %88
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.StrSlice, ptr %17, i32 0, i32 0
  store ptr @.str.15, ptr %107, align 8, !tbaa !11
  %108 = getelementptr inbounds %struct.StrSlice, ptr %17, i32 0, i32 1
  store i64 4, ptr %108, align 8, !tbaa !14
  %109 = getelementptr inbounds %struct.StrSlice, ptr %18, i32 0, i32 0
  store ptr @.str.15, ptr %109, align 8, !tbaa !11
  %110 = getelementptr inbounds %struct.StrSlice, ptr %18, i32 0, i32 1
  store i64 4, ptr %110, align 8, !tbaa !14
  %111 = getelementptr inbounds { ptr, i64 }, ptr %17, i32 0, i32 0
  %112 = load ptr, ptr %111, align 8
  %113 = getelementptr inbounds { ptr, i64 }, ptr %17, i32 0, i32 1
  %114 = load i64, ptr %113, align 8
  %115 = getelementptr inbounds { ptr, i64 }, ptr %18, i32 0, i32 0
  %116 = load ptr, ptr %115, align 8
  %117 = getelementptr inbounds { ptr, i64 }, ptr %18, i32 0, i32 1
  %118 = load i64, ptr %117, align 8
  %119 = call i32 @tnconv_prefix_match_replace(ptr noundef %4, ptr noundef %106, ptr %112, i64 %114, ptr %116, i64 %118)
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %122

121:                                              ; preds = %105
  store i32 1, ptr %6, align 4, !tbaa !9
  br label %122

122:                                              ; preds = %121, %105
  br label %123

123:                                              ; preds = %122, %104
  br label %124

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

125:                                              ; preds = %124, %70
  br label %126

126:                                              ; preds = %125, %36
  br label %127

127:                                              ; preds = %126, %3
  %128 = load i32, ptr %6, align 4, !tbaa !9
  %129 = icmp sgt i32 %128, 0
  br i1 %129, label %130, label %139

130:                                              ; preds = %127
  %131 = load ptr, ptr %5, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.StrSlice, ptr %4, i32 0, i32 1
  %133 = load i64, ptr %132, align 8, !tbaa !14
  %134 = trunc i64 %133 to i32
  %135 = getelementptr inbounds %struct.StrSlice, ptr %4, i32 0, i32 0
  %136 = load ptr, ptr %135, align 8, !tbaa !11
  %137 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !5
  %138 = call ptr @dynbuf_append(ptr noundef %131, i32 noundef %134, ptr noundef %136, i64 noundef 1, i32 noundef 1, ptr noundef %137)
  br label %139

139:                                              ; preds = %130, %127
  %140 = load i32, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  ret i32 %140
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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 #3 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"StrSlice", !6, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 8}


; 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.StrSlice = type { ptr, i64 }

@g_allocator_dopt = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [12 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @tnconv_prefix_match_replace(ptr noundef, ptr noundef, ptr, i64, ptr, i64) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @dynbuf_append(ptr noundef, i32 noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @tnconv_number_match_push(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @tnconv_clip_diffusers(ptr %0, i64 %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.StrSlice, align 8
  store ptr %0, ptr %4, align 8
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %1, ptr %5, align 8
  %6 = call i32 @tnconv_prefix_match_replace(ptr noundef nonnull %4, ptr noundef %2, ptr nonnull @.str.34, i64 11, ptr nonnull @.str.1, i64 5)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.thread41, label %7

7:                                                ; preds = %3
  %8 = call i32 @tnconv_prefix_match_replace(ptr noundef nonnull %4, ptr noundef %2, ptr nonnull @.str.8, i64 15, ptr nonnull @.str.8, i64 15)
  %.not31 = icmp eq i32 %8, 0
  br i1 %.not31, label %.thread41, label %9

9:                                                ; preds = %7
  %10 = call i32 @tnconv_number_match_push(ptr noundef nonnull %4, ptr noundef %2)
  %11 = call i32 @tnconv_prefix_match_replace(ptr noundef nonnull %4, ptr noundef %2, ptr nonnull @.str.25, i64 5, ptr nonnull @.str.10, i64 6)
  %.not32 = icmp eq i32 %11, 0
  br i1 %.not32, label %12, label %.thread

12:                                               ; preds = %9
  %13 = call i32 @tnconv_prefix_match_replace(ptr noundef nonnull %4, ptr noundef %2, ptr nonnull @.str.26, i64 5, ptr nonnull @.str.12, i64 6)
  %.not33 = icmp eq i32 %13, 0
  br i1 %.not33, label %14, label %.thread

14:                                               ; preds = %12
  %15 = call i32 @tnconv_prefix_match_replace(ptr noundef nonnull %4, ptr noundef %2, ptr nonnull @.str.13, i64 10, ptr nonnull @.str.14, i64 5)
  %.not34 = icmp eq i32 %15, 0
  br i1 %.not34, label %16, label %.thread

16:                                               ; preds = %14
  %17 = call i32 @tnconv_prefix_match_replace(ptr noundef nonnull %4, ptr noundef %2, ptr nonnull @.str.15, i64 4, ptr nonnull @.str.15, i64 4)
  %.not35.not.not = icmp eq i32 %17, 0
  br i1 %.not35.not.not, label %.thread41, label %.thread

.thread:                                          ; preds = %14, %12, %9, %16
  %18 = load i64, ptr %5, align 8, !tbaa !5
  %19 = trunc i64 %18 to i32
  %20 = load ptr, ptr %4, align 8, !tbaa !11
  %21 = load ptr, ptr @g_allocator_dopt, align 8, !tbaa !12
  %22 = call ptr @dynbuf_append(ptr noundef %2, i32 noundef %19, ptr noundef %20, i64 noundef 1, i32 noundef 1, ptr noundef %21)
  br label %.thread41

.thread41:                                        ; preds = %3, %7, %.thread, %16
  %.038 = phi i32 [ 1, %.thread ], [ 0, %16 ], [ 0, %7 ], [ 0, %3 ]
  ret i32 %.038
}

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 = { 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" }

!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, !10, i64 8}
!6 = !{!"StrSlice", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!7, !7, i64 0}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass