; LLVM IR from buaazp/zimg :: deps/hiredis (sds)

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

@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @sdscatprintf(ptr noundef, ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local ptr @sdscatrepr(ptr noundef %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = call ptr @sdscatlen(ptr noundef %8, ptr noundef @.str.1, i64 noundef 1)
  store ptr %9, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %13

12:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  br label %78

13:                                               ; preds = %3
  br label %14

14:                                               ; preds = %74, %13
  %15 = load i64, ptr %7, align 8, !tbaa !9
  %16 = add i64 %15, -1
  store i64 %16, ptr %7, align 8, !tbaa !9
  %17 = icmp ne i64 %15, 0
  br i1 %17, label %18, label %75

18:                                               ; preds = %14
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = load i8, ptr %19, align 1, !tbaa !11
  %21 = sext i8 %20 to i32
  switch i32 %21, label %43 [
    i32 92, label %22
    i32 34, label %22
    i32 10, label %28
    i32 13, label %31
    i32 9, label %34
    i32 7, label %37
    i32 8, label %40
  ]

22:                                               ; preds = %18, %18
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load i8, ptr %24, align 1, !tbaa !11
  %26 = sext i8 %25 to i32
  %27 = call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef %23, ptr noundef @.str.2, i32 noundef %26)
  store ptr %27, ptr %5, align 8, !tbaa !5
  br label %68

28:                                               ; preds = %18
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call ptr @sdscatlen(ptr noundef %29, ptr noundef @.str.3, i64 noundef 2)
  store ptr %30, ptr %5, align 8, !tbaa !5
  br label %68

31:                                               ; preds = %18
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call ptr @sdscatlen(ptr noundef %32, ptr noundef @.str.4, i64 noundef 2)
  store ptr %33, ptr %5, align 8, !tbaa !5
  br label %68

34:                                               ; preds = %18
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call ptr @sdscatlen(ptr noundef %35, ptr noundef @.str.5, i64 noundef 2)
  store ptr %36, ptr %5, align 8, !tbaa !5
  br label %68

37:                                               ; preds = %18
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = call ptr @sdscatlen(ptr noundef %38, ptr noundef @.str.6, i64 noundef 2)
  store ptr %39, ptr %5, align 8, !tbaa !5
  br label %68

40:                                               ; preds = %18
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call ptr @sdscatlen(ptr noundef %41, ptr noundef @.str.7, i64 noundef 2)
  store ptr %42, ptr %5, align 8, !tbaa !5
  br label %68

43:                                               ; preds = %18
  %44 = call ptr @__ctype_b_loc() #2
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i8, ptr %46, align 1, !tbaa !11
  %48 = sext i8 %47 to i32
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i16, ptr %45, i64 %49
  %51 = load i16, ptr %50, align 2, !tbaa !12
  %52 = zext i16 %51 to i32
  %53 = and i32 %52, 16384
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %61

55:                                               ; preds = %43
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i8, ptr %57, align 1, !tbaa !11
  %59 = sext i8 %58 to i32
  %60 = call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef %56, ptr noundef @.str.8, i32 noundef %59)
  store ptr %60, ptr %5, align 8, !tbaa !5
  br label %67

61:                                               ; preds = %43
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load i8, ptr %63, align 1, !tbaa !11
  %65 = zext i8 %64 to i32
  %66 = call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef %62, ptr noundef @.str.9, i32 noundef %65)
  store ptr %66, ptr %5, align 8, !tbaa !5
  br label %67

67:                                               ; preds = %61, %55
  br label %68

68:                                               ; preds = %67, %40, %37, %34, %31, %28, %22
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %69, i32 1
  store ptr %70, ptr %6, align 8, !tbaa !5
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = icmp eq ptr %71, null
  br i1 %72, label %73, label %74

73:                                               ; preds = %68
  store ptr null, ptr %4, align 8
  br label %78

74:                                               ; preds = %68
  br label %14, !llvm.loop !14

75:                                               ; preds = %14
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = call ptr @sdscatlen(ptr noundef %76, ptr noundef @.str.1, i64 noundef 1)
  store ptr %77, ptr %4, align 8
  br label %78

78:                                               ; preds = %75, %73, %12
  %79 = load ptr, ptr %4, align 8
  ret ptr %79
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() #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 = { 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 #2 = { 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 = !{!"long", !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"}


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

@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @sdscatrepr(ptr noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = tail call ptr @sdscatlen(ptr noundef %0, ptr noundef nonnull @.str.1, i64 noundef 1)
  %5 = icmp eq ptr %4, null
  br i1 %5, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %3, %34
  %.020 = phi ptr [ %.1, %34 ], [ %4, %3 ]
  %.019 = phi ptr [ %35, %34 ], [ %1, %3 ]
  %.0 = phi i64 [ %6, %34 ], [ %2, %3 ]
  %6 = add i64 %.0, -1
  %.not = icmp eq i64 %.0, 0
  br i1 %.not, label %37, label %7

7:                                                ; preds = %.preheader
  %8 = load i8, ptr %.019, align 1, !tbaa !5
  %9 = sext i8 %8 to i32
  switch i8 %8, label %22 [
    i8 92, label %10
    i8 34, label %10
    i8 10, label %12
    i8 13, label %14
    i8 9, label %16
    i8 7, label %18
    i8 8, label %20
  ]

10:                                               ; preds = %7, %7
  %11 = tail call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef nonnull %.020, ptr noundef nonnull @.str.2, i32 noundef %9)
  br label %34

12:                                               ; preds = %7
  %13 = tail call ptr @sdscatlen(ptr noundef nonnull %.020, ptr noundef nonnull @.str.3, i64 noundef 2)
  br label %34

14:                                               ; preds = %7
  %15 = tail call ptr @sdscatlen(ptr noundef nonnull %.020, ptr noundef nonnull @.str.4, i64 noundef 2)
  br label %34

16:                                               ; preds = %7
  %17 = tail call ptr @sdscatlen(ptr noundef nonnull %.020, ptr noundef nonnull @.str.5, i64 noundef 2)
  br label %34

18:                                               ; preds = %7
  %19 = tail call ptr @sdscatlen(ptr noundef nonnull %.020, ptr noundef nonnull @.str.6, i64 noundef 2)
  br label %34

20:                                               ; preds = %7
  %21 = tail call ptr @sdscatlen(ptr noundef nonnull %.020, ptr noundef nonnull @.str.7, i64 noundef 2)
  br label %34

22:                                               ; preds = %7
  %23 = tail call ptr @__ctype_b_loc() #2
  %24 = load ptr, ptr %23, align 8, !tbaa !8
  %25 = sext i8 %8 to i64
  %26 = getelementptr inbounds i16, ptr %24, i64 %25
  %27 = load i16, ptr %26, align 2, !tbaa !10
  %28 = and i16 %27, 16384
  %.not23 = icmp eq i16 %28, 0
  br i1 %.not23, label %31, label %29

29:                                               ; preds = %22
  %30 = tail call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef nonnull %.020, ptr noundef nonnull @.str.8, i32 noundef %9)
  br label %34

31:                                               ; preds = %22
  %32 = zext i8 %8 to i32
  %33 = tail call ptr (ptr, ptr, ...) @sdscatprintf(ptr noundef nonnull %.020, ptr noundef nonnull @.str.9, i32 noundef %32)
  br label %34

34:                                               ; preds = %29, %31, %20, %18, %16, %14, %12, %10
  %.1 = phi ptr [ %30, %29 ], [ %33, %31 ], [ %21, %20 ], [ %19, %18 ], [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ]
  %35 = getelementptr inbounds i8, ptr %.019, i64 1
  %36 = icmp eq ptr %.1, null
  br i1 %36, label %.loopexit, label %.preheader, !llvm.loop !12

37:                                               ; preds = %.preheader
  %38 = tail call ptr @sdscatlen(ptr noundef nonnull %.020, ptr noundef nonnull @.str.1, i64 noundef 1)
  br label %.loopexit

.loopexit:                                        ; preds = %34, %3, %37
  %.021 = phi ptr [ %38, %37 ], [ null, %3 ], [ null, %34 ]
  ret ptr %.021
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__ctype_b_loc() local_unnamed_addr #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 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 #2 = { 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 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"short", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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