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

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

; 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: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @str_strdup(ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_cmp_l(ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_cmp_a(ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_cmp_ai(ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_cmp_la(ptr noundef, ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_cmp_lai(ptr noundef, ptr noundef) #5

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #6

; Function Attrs: nounwind uwtable
define dso_local ptr @str_sorted(ptr noundef %0, i64 noundef %1, ptr noundef %2, ...) #4 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [5 x i8], align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca [1 x %struct.__va_list_tag], align 16
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 5, ptr %8) #7
  call void @llvm.memset.p0.i64(ptr align 1 %8, i8 0, i64 5, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %15, ptr %9, align 8, !tbaa !5
  br label %16

16:                                               ; preds = %73, %3
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = load i8, ptr %17, align 1, !tbaa !11
  %19 = sext i8 %18 to i32
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %22, label %21

21:                                               ; preds = %16
  store i32 2, ptr %10, align 4
  br label %76

22:                                               ; preds = %16
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = load i8, ptr %23, align 1, !tbaa !11
  %25 = sext i8 %24 to i32
  %26 = icmp eq i32 %25, 99
  br i1 %26, label %27, label %29

27:                                               ; preds = %22
  %28 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 0
  store i8 1, ptr %28, align 1, !tbaa !12
  store i32 2, ptr %10, align 4
  br label %76

29:                                               ; preds = %22
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load i8, ptr %30, align 1, !tbaa !11
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 105
  br i1 %33, label %34, label %36

34:                                               ; preds = %29
  %35 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 1
  store i8 1, ptr %35, align 1, !tbaa !12
  br label %71

36:                                               ; preds = %29
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = load i8, ptr %37, align 1, !tbaa !11
  %39 = sext i8 %38 to i32
  %40 = icmp eq i32 %39, 108
  br i1 %40, label %41, label %51

41:                                               ; preds = %36
  %42 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 3
  %43 = load i8, ptr %42, align 1, !tbaa !12, !range !14, !noundef !15
  %44 = trunc i8 %43 to i1
  %45 = zext i1 %44 to i32
  %46 = icmp eq i32 %45, 1
  br i1 %46, label %47, label %48

47:                                               ; preds = %41
  br label %73

48:                                               ; preds = %41
  %49 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 2
  store i8 1, ptr %49, align 1, !tbaa !12
  br label %50

50:                                               ; preds = %48
  br label %70

51:                                               ; preds = %36
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load i8, ptr %52, align 1, !tbaa !11
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 97
  br i1 %55, label %56, label %68

56:                                               ; preds = %51
  %57 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 2
  %58 = load i8, ptr %57, align 1, !tbaa !12, !range !14, !noundef !15
  %59 = trunc i8 %58 to i1
  %60 = zext i1 %59 to i32
  %61 = icmp eq i32 %60, 1
  br i1 %61, label %62, label %65

62:                                               ; preds = %56
  %63 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 2
  store i8 0, ptr %63, align 1, !tbaa !12
  %64 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 4
  store i8 1, ptr %64, align 1, !tbaa !12
  br label %67

65:                                               ; preds = %56
  %66 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 3
  store i8 1, ptr %66, align 1, !tbaa !12
  br label %67

67:                                               ; preds = %65, %62
  br label %69

68:                                               ; preds = %51
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %76

69:                                               ; preds = %67
  br label %70

70:                                               ; preds = %69, %50
  br label %71

71:                                               ; preds = %70, %34
  br label %72

72:                                               ; preds = %71
  br label %73

73:                                               ; preds = %72, %47
  %74 = load ptr, ptr %9, align 8, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %74, i32 1
  store ptr %75, ptr %9, align 8, !tbaa !5
  br label %16, !llvm.loop !16

76:                                               ; preds = %68, %27, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  %77 = load i32, ptr %10, align 4
  switch i32 %77, label %208 [
    i32 2, label %78
  ]

78:                                               ; preds = %76
  %79 = load i64, ptr %6, align 8, !tbaa !9
  %80 = icmp eq i64 %79, 0
  br i1 %80, label %81, label %93

81:                                               ; preds = %78
  br label %82

82:                                               ; preds = %89, %81
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = load i64, ptr %6, align 8, !tbaa !9
  %85 = getelementptr inbounds ptr, ptr %83, i64 %84
  %86 = load ptr, ptr %85, align 8, !tbaa !5
  %87 = icmp ne ptr %86, null
  br i1 %87, label %88, label %92

88:                                               ; preds = %82
  br label %89

89:                                               ; preds = %88
  %90 = load i64, ptr %6, align 8, !tbaa !9
  %91 = add i64 %90, 1
  store i64 %91, ptr %6, align 8, !tbaa !9
  br label %82, !llvm.loop !18

92:                                               ; preds = %82
  br label %93

93:                                               ; preds = %92, %78
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %94 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 0
  %95 = load i8, ptr %94, align 1, !tbaa !12, !range !14, !noundef !15
  %96 = trunc i8 %95 to i1
  %97 = zext i1 %96 to i32
  %98 = icmp eq i32 %97, 1
  br i1 %98, label %99, label %118

99:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #7
  %100 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %12, i64 0, i64 0
  call void @llvm.va_start.p0(ptr %100)
  %101 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %12, i64 0, i64 0
  %102 = getelementptr inbounds %struct.__va_list_tag, ptr %101, i32 0, i32 0
  %103 = load i32, ptr %102, align 16
  %104 = icmp ule i32 %103, 40
  br i1 %104, label %105, label %110

105:                                              ; preds = %99
  %106 = getelementptr inbounds %struct.__va_list_tag, ptr %101, i32 0, i32 3
  %107 = load ptr, ptr %106, align 16
  %108 = getelementptr i8, ptr %107, i32 %103
  %109 = add i32 %103, 8
  store i32 %109, ptr %102, align 16
  br label %114

110:                                              ; preds = %99
  %111 = getelementptr inbounds %struct.__va_list_tag, ptr %101, i32 0, i32 2
  %112 = load ptr, ptr %111, align 8
  %113 = getelementptr i8, ptr %112, i32 8
  store ptr %113, ptr %111, align 8
  br label %114

114:                                              ; preds = %110, %105
  %115 = phi ptr [ %108, %105 ], [ %112, %110 ]
  %116 = load ptr, ptr %115, align 8, !tbaa !5
  store ptr %116, ptr %11, align 8, !tbaa !5
  %117 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %12, i64 0, i64 0
  call void @llvm.va_end.p0(ptr %117)
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #7
  br label %177

118:                                              ; preds = %93
  %119 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 2
  %120 = load i8, ptr %119, align 1, !tbaa !12, !range !14, !noundef !15
  %121 = trunc i8 %120 to i1
  %122 = zext i1 %121 to i32
  %123 = icmp eq i32 %122, 1
  br i1 %123, label %124, label %125

124:                                              ; preds = %118
  store ptr @str_cmp_l, ptr %11, align 8, !tbaa !5
  br label %176

125:                                              ; preds = %118
  %126 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 3
  %127 = load i8, ptr %126, align 1, !tbaa !12, !range !14, !noundef !15
  %128 = trunc i8 %127 to i1
  %129 = zext i1 %128 to i32
  %130 = icmp eq i32 %129, 1
  br i1 %130, label %131, label %138

131:                                              ; preds = %125
  %132 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 1
  %133 = load i8, ptr %132, align 1, !tbaa !12, !range !14, !noundef !15
  %134 = trunc i8 %133 to i1
  %135 = zext i1 %134 to i32
  %136 = icmp eq i32 %135, 0
  br i1 %136, label %137, label %138

137:                                              ; preds = %131
  store ptr @str_cmp_a, ptr %11, align 8, !tbaa !5
  br label %175

138:                                              ; preds = %131, %125
  %139 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 3
  %140 = load i8, ptr %139, align 1, !tbaa !12, !range !14, !noundef !15
  %141 = trunc i8 %140 to i1
  %142 = zext i1 %141 to i32
  %143 = icmp eq i32 %142, 1
  br i1 %143, label %144, label %151

144:                                              ; preds = %138
  %145 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 1
  %146 = load i8, ptr %145, align 1, !tbaa !12, !range !14, !noundef !15
  %147 = trunc i8 %146 to i1
  %148 = zext i1 %147 to i32
  %149 = icmp eq i32 %148, 1
  br i1 %149, label %150, label %151

150:                                              ; preds = %144
  store ptr @str_cmp_ai, ptr %11, align 8, !tbaa !5
  br label %174

151:                                              ; preds = %144, %138
  %152 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 4
  %153 = load i8, ptr %152, align 1, !tbaa !12, !range !14, !noundef !15
  %154 = trunc i8 %153 to i1
  %155 = zext i1 %154 to i32
  %156 = icmp eq i32 %155, 1
  br i1 %156, label %157, label %158

157:                                              ; preds = %151
  store ptr @str_cmp_la, ptr %11, align 8, !tbaa !5
  br label %173

158:                                              ; preds = %151
  %159 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 4
  %160 = load i8, ptr %159, align 1, !tbaa !12, !range !14, !noundef !15
  %161 = trunc i8 %160 to i1
  %162 = zext i1 %161 to i32
  %163 = icmp eq i32 %162, 1
  br i1 %163, label %164, label %171

164:                                              ; preds = %158
  %165 = getelementptr inbounds [5 x i8], ptr %8, i64 0, i64 1
  %166 = load i8, ptr %165, align 1, !tbaa !12, !range !14, !noundef !15
  %167 = trunc i8 %166 to i1
  %168 = zext i1 %167 to i32
  %169 = icmp eq i32 %168, 1
  br i1 %169, label %170, label %171

170:                                              ; preds = %164
  store ptr @str_cmp_lai, ptr %11, align 8, !tbaa !5
  br label %172

171:                                              ; preds = %164, %158
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %207

172:                                              ; preds = %170
  br label %173

173:                                              ; preds = %172, %157
  br label %174

174:                                              ; preds = %173, %150
  br label %175

175:                                              ; preds = %174, %137
  br label %176

176:                                              ; preds = %175, %124
  br label %177

177:                                              ; preds = %176, %114
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %178 = load i64, ptr %6, align 8, !tbaa !9
  %179 = add i64 %178, 1
  %180 = mul i64 8, %179
  %181 = call noalias ptr @malloc(i64 noundef %180) #8
  store ptr %181, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %182

182:                                              ; preds = %196, %177
  %183 = load i64, ptr %14, align 8, !tbaa !9
  %184 = load i64, ptr %6, align 8, !tbaa !9
  %185 = icmp ult i64 %183, %184
  br i1 %185, label %187, label %186

186:                                              ; preds = %182
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  br label %199

187:                                              ; preds = %182
  %188 = load ptr, ptr %5, align 8, !tbaa !5
  %189 = load i64, ptr %14, align 8, !tbaa !9
  %190 = getelementptr inbounds ptr, ptr %188, i64 %189
  %191 = load ptr, ptr %190, align 8, !tbaa !5
  %192 = call ptr @str_strdup(ptr noundef %191)
  %193 = load ptr, ptr %13, align 8, !tbaa !5
  %194 = load i64, ptr %14, align 8, !tbaa !9
  %195 = getelementptr inbounds ptr, ptr %193, i64 %194
  store ptr %192, ptr %195, align 8, !tbaa !5
  br label %196

196:                                              ; preds = %187
  %197 = load i64, ptr %14, align 8, !tbaa !9
  %198 = add i64 %197, 1
  store i64 %198, ptr %14, align 8, !tbaa !9
  br label %182, !llvm.loop !19

199:                                              ; preds = %186
  %200 = load ptr, ptr %13, align 8, !tbaa !5
  %201 = load i64, ptr %6, align 8, !tbaa !9
  %202 = getelementptr inbounds ptr, ptr %200, i64 %201
  store ptr null, ptr %202, align 8, !tbaa !5
  %203 = load ptr, ptr %13, align 8, !tbaa !5
  %204 = load i64, ptr %6, align 8, !tbaa !9
  %205 = load ptr, ptr %11, align 8, !tbaa !5
  call void @qsort(ptr noundef %203, i64 noundef %204, i64 noundef 8, ptr noundef %205)
  %206 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %206, ptr %4, align 8
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  br label %207

207:                                              ; preds = %199, %171
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  br label %208

208:                                              ; preds = %207, %76
  call void @llvm.lifetime.end.p0(i64 5, ptr %8) #7
  %209 = load ptr, ptr %4, align 8
  ret ptr %209
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { 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 #6 = { "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 allocsize(0) }

!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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}


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

; 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: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_start.p0(ptr) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.va_end.p0(ptr) #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @str_strdup(ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_cmp_l(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_cmp_a(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_cmp_ai(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @str_cmp_la(ptr noundef, ptr noundef) #4

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @str_sorted(ptr nocapture noundef readonly %0, i64 noundef %1, ptr nocapture noundef readonly %2, ...) local_unnamed_addr #3 {
  %4 = alloca [1 x %struct.__va_list_tag], align 16
  br label %5

5:                                                ; preds = %11, %3
  %.sroa.5.0 = phi i8 [ 0, %3 ], [ %.sroa.5.1, %11 ]
  %.sroa.9.0 = phi i8 [ 0, %3 ], [ %.sroa.9.1, %11 ]
  %.sroa.13.0 = phi i8 [ 0, %3 ], [ %.sroa.13.1, %11 ]
  %.sroa.17.0 = phi i1 [ false, %3 ], [ %.sroa.17.1, %11 ]
  %.040 = phi ptr [ %2, %3 ], [ %12, %11 ]
  %6 = load i8, ptr %.040, align 1, !tbaa !5
  switch i8 %6, label %.loopexit52 [
    i8 0, label %.loopexit53.loopexit
    i8 99, label %.loopexit53
    i8 105, label %11
    i8 108, label %7
    i8 97, label %9
  ]

7:                                                ; preds = %5
  %8 = trunc nuw i8 %.sroa.13.0 to i1
  %spec.select = select i1 %8, i8 %.sroa.9.0, i8 1
  br label %11

9:                                                ; preds = %5
  %10 = trunc nuw i8 %.sroa.9.0 to i1
  %..sroa.9.0 = select i1 %10, i8 0, i8 %.sroa.9.0
  %.sroa.13.0. = select i1 %10, i8 %.sroa.13.0, i8 1
  %..sroa.17.0 = select i1 %10, i1 true, i1 %.sroa.17.0
  br label %11

11:                                               ; preds = %7, %9, %5
  %.sroa.5.1 = phi i8 [ 1, %5 ], [ %.sroa.5.0, %7 ], [ %.sroa.5.0, %9 ]
  %.sroa.9.1 = phi i8 [ %.sroa.9.0, %5 ], [ %spec.select, %7 ], [ %..sroa.9.0, %9 ]
  %.sroa.13.1 = phi i8 [ %.sroa.13.0, %5 ], [ %.sroa.13.0, %7 ], [ %.sroa.13.0., %9 ]
  %.sroa.17.1 = phi i1 [ %.sroa.17.0, %5 ], [ %.sroa.17.0, %7 ], [ %..sroa.17.0, %9 ]
  %12 = getelementptr inbounds i8, ptr %.040, i64 1
  br label %5, !llvm.loop !8

.loopexit53.loopexit:                             ; preds = %5
  br label %.loopexit53

.loopexit53:                                      ; preds = %5, %.loopexit53.loopexit
  %.sroa.0.0.ph = phi i1 [ false, %.loopexit53.loopexit ], [ true, %5 ]
  %13 = icmp eq i64 %1, 0
  br i1 %13, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %.loopexit53, %.preheader
  %.041 = phi i64 [ %16, %.preheader ], [ 0, %.loopexit53 ]
  %14 = getelementptr inbounds ptr, ptr %0, i64 %.041
  %15 = load ptr, ptr %14, align 8, !tbaa !10
  %.not47 = icmp eq ptr %15, null
  %16 = add i64 %.041, 1
  br i1 %.not47, label %.loopexit, label %.preheader, !llvm.loop !12

.loopexit:                                        ; preds = %.preheader, %.loopexit53
  %.142 = phi i64 [ %1, %.loopexit53 ], [ %.041, %.preheader ]
  br i1 %.sroa.0.0.ph, label %17, label %33

17:                                               ; preds = %.loopexit
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.va_start.p0(ptr nonnull %4)
  %18 = load i32, ptr %4, align 16
  %19 = icmp ult i32 %18, 41
  br i1 %19, label %20, label %26

20:                                               ; preds = %17
  %21 = getelementptr inbounds i8, ptr %4, i64 16
  %22 = load ptr, ptr %21, align 16
  %23 = zext nneg i32 %18 to i64
  %24 = getelementptr i8, ptr %22, i64 %23
  %25 = add nuw nsw i32 %18, 8
  store i32 %25, ptr %4, align 16
  br label %30

26:                                               ; preds = %17
  %27 = getelementptr inbounds i8, ptr %4, i64 8
  %28 = load ptr, ptr %27, align 8
  %29 = getelementptr i8, ptr %28, i64 8
  store ptr %29, ptr %27, align 8
  br label %30

30:                                               ; preds = %26, %20
  %31 = phi ptr [ %24, %20 ], [ %28, %26 ]
  %32 = load ptr, ptr %31, align 8, !tbaa !10
  call void @llvm.va_end.p0(ptr nonnull %4)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  br label %43

33:                                               ; preds = %.loopexit
  %34 = trunc nuw i8 %.sroa.9.0 to i1
  br i1 %34, label %43, label %35

35:                                               ; preds = %33
  %36 = trunc nuw i8 %.sroa.13.0 to i1
  %37 = and i8 %.sroa.5.0, 1
  %38 = icmp eq i8 %37, 0
  %or.cond = select i1 %36, i1 %38, i1 false
  br i1 %or.cond, label %43, label %39

39:                                               ; preds = %35
  br i1 %36, label %40, label %42

40:                                               ; preds = %39
  %41 = trunc nuw i8 %.sroa.5.0 to i1
  %brmerge = select i1 %41, i1 true, i1 %.sroa.17.0
  %str_cmp_ai.mux = select i1 %41, ptr @str_cmp_ai, ptr @str_cmp_la
  br i1 %brmerge, label %43, label %.loopexit52

42:                                               ; preds = %39
  br i1 %.sroa.17.0, label %43, label %.loopexit52

43:                                               ; preds = %40, %42, %35, %33, %30
  %.038 = phi ptr [ %32, %30 ], [ @str_cmp_l, %33 ], [ @str_cmp_a, %35 ], [ %str_cmp_ai.mux, %40 ], [ @str_cmp_la, %42 ]
  %44 = shl i64 %.142, 3
  %45 = add i64 %44, 8
  %46 = call noalias ptr @malloc(i64 noundef %45) #7
  %.not = icmp eq i64 %.142, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %43
  %47 = getelementptr inbounds ptr, ptr %46, i64 %.142
  store ptr null, ptr %47, align 8, !tbaa !10
  call void @qsort(ptr noundef %46, i64 noundef %.142, i64 noundef 8, ptr noundef %.038) #6
  br label %.loopexit52

.lr.ph:                                           ; preds = %43, %.lr.ph
  %.066 = phi i64 [ %52, %.lr.ph ], [ 0, %43 ]
  %48 = getelementptr inbounds ptr, ptr %0, i64 %.066
  %49 = load ptr, ptr %48, align 8, !tbaa !10
  %50 = call ptr @str_strdup(ptr noundef %49)
  %51 = getelementptr inbounds ptr, ptr %46, i64 %.066
  store ptr %50, ptr %51, align 8, !tbaa !10
  %52 = add nuw i64 %.066, 1
  %exitcond.not = icmp eq i64 %52, %.142
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

.loopexit52:                                      ; preds = %5, %40, %._crit_edge, %42
  %.2 = phi ptr [ %46, %._crit_edge ], [ null, %42 ], [ null, %40 ], [ null, %5 ]
  ret ptr %.2
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #2 = { 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 #3 = { 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 #4 = { 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 #5 = { nofree "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 allocsize(0) }

!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}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = distinct !{!12, !9}
!13 = distinct !{!13, !9}


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