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

; 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.redisReader = type { i32, [128 x i8], ptr, i64, i64, i64, [9 x %struct.redisReadTask], i32, ptr, ptr, ptr }
%struct.redisReadTask = type { i32, i32, i32, ptr, ptr, ptr }

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @sdslen(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @redisReaderGetReply(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %10

8:                                                ; preds = %2
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr null, ptr %9, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %8, %2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.redisReader, ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 8, !tbaa !9
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %10
  store i32 -1, ptr %3, align 4
  br label %116

16:                                               ; preds = %10
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.redisReader, ptr %17, i32 0, i32 4
  %19 = load i64, ptr %18, align 8, !tbaa !13
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  store i32 0, ptr %3, align 4
  br label %116

22:                                               ; preds = %16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.redisReader, ptr %23, i32 0, i32 7
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %26 = icmp eq i32 %25, -1
  br i1 %26, label %27, label %57

27:                                               ; preds = %22
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.redisReader, ptr %28, i32 0, i32 6
  %30 = getelementptr inbounds [9 x %struct.redisReadTask], ptr %29, i64 0, i64 0
  %31 = getelementptr inbounds %struct.redisReadTask, ptr %30, i32 0, i32 0
  store i32 -1, ptr %31, align 8, !tbaa !15
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.redisReader, ptr %32, i32 0, i32 6
  %34 = getelementptr inbounds [9 x %struct.redisReadTask], ptr %33, i64 0, i64 0
  %35 = getelementptr inbounds %struct.redisReadTask, ptr %34, i32 0, i32 1
  store i32 -1, ptr %35, align 4, !tbaa !17
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.redisReader, ptr %36, i32 0, i32 6
  %38 = getelementptr inbounds [9 x %struct.redisReadTask], ptr %37, i64 0, i64 0
  %39 = getelementptr inbounds %struct.redisReadTask, ptr %38, i32 0, i32 2
  store i32 -1, ptr %39, align 8, !tbaa !18
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.redisReader, ptr %40, i32 0, i32 6
  %42 = getelementptr inbounds [9 x %struct.redisReadTask], ptr %41, i64 0, i64 0
  %43 = getelementptr inbounds %struct.redisReadTask, ptr %42, i32 0, i32 3
  store ptr null, ptr %43, align 8, !tbaa !19
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.redisReader, ptr %44, i32 0, i32 6
  %46 = getelementptr inbounds [9 x %struct.redisReadTask], ptr %45, i64 0, i64 0
  %47 = getelementptr inbounds %struct.redisReadTask, ptr %46, i32 0, i32 4
  store ptr null, ptr %47, align 8, !tbaa !20
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.redisReader, ptr %48, i32 0, i32 10
  %50 = load ptr, ptr %49, align 8, !tbaa !21
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.redisReader, ptr %51, i32 0, i32 6
  %53 = getelementptr inbounds [9 x %struct.redisReadTask], ptr %52, i64 0, i64 0
  %54 = getelementptr inbounds %struct.redisReadTask, ptr %53, i32 0, i32 5
  store ptr %50, ptr %54, align 8, !tbaa !22
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.redisReader, ptr %55, i32 0, i32 7
  store i32 0, ptr %56, align 8, !tbaa !14
  br label %57

57:                                               ; preds = %27, %22
  br label %58

58:                                               ; preds = %68, %57
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.redisReader, ptr %59, i32 0, i32 7
  %61 = load i32, ptr %60, align 8, !tbaa !14
  %62 = icmp sge i32 %61, 0
  br i1 %62, label %63, label %69

63:                                               ; preds = %58
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = call i32 @processItem(ptr noundef %64)
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %63
  br label %69

68:                                               ; preds = %63
  br label %58, !llvm.loop !23

69:                                               ; preds = %67, %58
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.redisReader, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 8, !tbaa !9
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %75

74:                                               ; preds = %69
  store i32 -1, ptr %3, align 4
  br label %116

75:                                               ; preds = %69
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.redisReader, ptr %76, i32 0, i32 3
  %78 = load i64, ptr %77, align 8, !tbaa !25
  %79 = icmp uge i64 %78, 1024
  br i1 %79, label %80, label %99

80:                                               ; preds = %75
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.redisReader, ptr %81, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !26
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.redisReader, ptr %84, i32 0, i32 3
  %86 = load i64, ptr %85, align 8, !tbaa !25
  %87 = trunc i64 %86 to i32
  %88 = call ptr @sdsrange(ptr noundef %83, i32 noundef %87, i32 noundef -1)
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.redisReader, ptr %89, i32 0, i32 2
  store ptr %88, ptr %90, align 8, !tbaa !26
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.redisReader, ptr %91, i32 0, i32 3
  store i64 0, ptr %92, align 8, !tbaa !25
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.redisReader, ptr %93, i32 0, i32 2
  %95 = load ptr, ptr %94, align 8, !tbaa !26
  %96 = call i64 @sdslen(ptr noundef %95)
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.redisReader, ptr %97, i32 0, i32 4
  store i64 %96, ptr %98, align 8, !tbaa !13
  br label %99

99:                                               ; preds = %80, %75
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.redisReader, ptr %100, i32 0, i32 7
  %102 = load i32, ptr %101, align 8, !tbaa !14
  %103 = icmp eq i32 %102, -1
  br i1 %103, label %104, label %115

104:                                              ; preds = %99
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = icmp ne ptr %105, null
  br i1 %106, label %107, label %112

107:                                              ; preds = %104
  %108 = load ptr, ptr %4, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.redisReader, ptr %108, i32 0, i32 8
  %110 = load ptr, ptr %109, align 8, !tbaa !27
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %110, ptr %111, align 8, !tbaa !5
  br label %112

112:                                              ; preds = %107, %104
  %113 = load ptr, ptr %4, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.redisReader, ptr %113, i32 0, i32 8
  store ptr null, ptr %114, align 8, !tbaa !27
  br label %115

115:                                              ; preds = %112, %99
  store i32 0, ptr %3, align 4
  br label %116

116:                                              ; preds = %115, %74, %21, %15
  %117 = load i32, ptr %3, align 4
  ret i32 %117
}

; Function Attrs: nounwind uwtable
declare hidden i32 @processItem(ptr noundef) #1

declare ptr @sdsrange(ptr noundef, i32 noundef, i32 noundef) #2

attributes #0 = { 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 #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 = { "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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"redisReader", !11, i64 0, !7, i64 4, !6, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !7, i64 168, !11, i64 528, !6, i64 536, !6, i64 544, !6, i64 552}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 152}
!14 = !{!10, !11, i64 528}
!15 = !{!16, !11, i64 0}
!16 = !{!"redisReadTask", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!17 = !{!16, !11, i64 4}
!18 = !{!16, !11, i64 8}
!19 = !{!16, !6, i64 16}
!20 = !{!16, !6, i64 24}
!21 = !{!10, !6, i64 552}
!22 = !{!16, !6, i64 32}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!10, !12, i64 144}
!26 = !{!10, !6, i64 136}
!27 = !{!10, !6, i64 536}


; 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: inlinehint nounwind uwtable
declare hidden i64 @sdslen(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @redisReaderGetReply(ptr noundef %0, ptr noundef writeonly %1) local_unnamed_addr #1 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %4, label %3

3:                                                ; preds = %2
  store ptr null, ptr %1, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %3, %2
  %5 = load i32, ptr %0, align 8, !tbaa !9
  %.not30 = icmp eq i32 %5, 0
  br i1 %.not30, label %6, label %48

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 152
  %8 = load i64, ptr %7, align 8, !tbaa !13
  %9 = icmp eq i64 %8, 0
  br i1 %9, label %48, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 528
  %12 = load i32, ptr %11, align 8, !tbaa !14
  %13 = icmp eq i32 %12, -1
  br i1 %13, label %14, label %.preheader

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %0, i64 168
  store i32 -1, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %0, i64 172
  store i32 -1, ptr %16, align 4, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 176
  store i32 -1, ptr %17, align 8, !tbaa !18
  %18 = getelementptr inbounds i8, ptr %0, i64 184
  %19 = getelementptr inbounds i8, ptr %0, i64 552
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %18, i8 0, i64 16, i1 false)
  %20 = load ptr, ptr %19, align 8, !tbaa !19
  %21 = getelementptr inbounds i8, ptr %0, i64 200
  store ptr %20, ptr %21, align 8, !tbaa !20
  store i32 0, ptr %11, align 8, !tbaa !14
  br label %.preheader

.preheader:                                       ; preds = %14, %10
  br label %22

22:                                               ; preds = %.preheader, %25
  %23 = load i32, ptr %11, align 8, !tbaa !14
  %24 = icmp sgt i32 %23, -1
  br i1 %24, label %25, label %27

25:                                               ; preds = %22
  %26 = tail call i32 @processItem(ptr noundef nonnull %0)
  %.not31 = icmp eq i32 %26, 0
  br i1 %.not31, label %22, label %27, !llvm.loop !21

27:                                               ; preds = %25, %22
  %28 = load i32, ptr %0, align 8, !tbaa !9
  %.not32 = icmp eq i32 %28, 0
  br i1 %.not32, label %29, label %48

29:                                               ; preds = %27
  %30 = getelementptr inbounds i8, ptr %0, i64 144
  %31 = load i64, ptr %30, align 8, !tbaa !23
  %32 = icmp ugt i64 %31, 1023
  br i1 %32, label %33, label %39

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %0, i64 136
  %35 = load ptr, ptr %34, align 8, !tbaa !24
  %36 = trunc i64 %31 to i32
  %37 = tail call ptr @sdsrange(ptr noundef %35, i32 noundef %36, i32 noundef -1) #4
  store ptr %37, ptr %34, align 8, !tbaa !24
  store i64 0, ptr %30, align 8, !tbaa !23
  %38 = tail call i64 @sdslen(ptr noundef %37)
  store i64 %38, ptr %7, align 8, !tbaa !13
  br label %39

39:                                               ; preds = %33, %29
  %40 = load i32, ptr %11, align 8, !tbaa !14
  %41 = icmp eq i32 %40, -1
  br i1 %41, label %42, label %48

42:                                               ; preds = %39
  br i1 %.not, label %46, label %43

43:                                               ; preds = %42
  %44 = getelementptr inbounds i8, ptr %0, i64 536
  %45 = load ptr, ptr %44, align 8, !tbaa !25
  store ptr %45, ptr %1, align 8, !tbaa !5
  br label %46

46:                                               ; preds = %43, %42
  %47 = getelementptr inbounds i8, ptr %0, i64 536
  store ptr null, ptr %47, align 8, !tbaa !25
  br label %48

48:                                               ; preds = %39, %46, %27, %6, %4
  %.0 = phi i32 [ -1, %4 ], [ 0, %6 ], [ -1, %27 ], [ 0, %46 ], [ 0, %39 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @processItem(ptr noundef) local_unnamed_addr #1

declare ptr @sdsrange(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

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

!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, !11, i64 0}
!10 = !{!"redisReader", !11, i64 0, !7, i64 4, !6, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !7, i64 168, !11, i64 528, !6, i64 536, !6, i64 544, !6, i64 552}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 152}
!14 = !{!10, !11, i64 528}
!15 = !{!16, !11, i64 0}
!16 = !{!"redisReadTask", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!17 = !{!16, !11, i64 4}
!18 = !{!16, !11, i64 8}
!19 = !{!10, !6, i64 552}
!20 = !{!16, !6, i64 32}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!10, !12, i64 144}
!24 = !{!10, !6, i64 136}
!25 = !{!10, !6, i64 536}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass