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

@.str = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@__PRETTY_FUNCTION__.redisReaderFeed = external hidden unnamed_addr constant [57 x i8], align 1

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

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

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

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

declare ptr @sdsempty() #2

declare void @sdsfree(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @redisReaderFeed(ptr noundef %0, ptr noundef %1, i64 noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.redisReader, ptr %10, i32 0, i32 0
  %12 = load i32, ptr %11, align 8, !tbaa !11
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %78

15:                                               ; preds = %3
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %77

18:                                               ; preds = %15
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = icmp uge i64 %19, 1
  br i1 %20, label %21, label %77

21:                                               ; preds = %18
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.redisReader, ptr %22, i32 0, i32 4
  %24 = load i64, ptr %23, align 8, !tbaa !14
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %56

26:                                               ; preds = %21
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.redisReader, ptr %27, i32 0, i32 5
  %29 = load i64, ptr %28, align 8, !tbaa !15
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %31, label %56

31:                                               ; preds = %26
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.redisReader, ptr %32, i32 0, i32 2
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = call i64 @sdsavail(ptr noundef %34)
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.redisReader, ptr %36, i32 0, i32 5
  %38 = load i64, ptr %37, align 8, !tbaa !15
  %39 = icmp ugt i64 %35, %38
  br i1 %39, label %40, label %56

40:                                               ; preds = %31
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.redisReader, ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  call void @sdsfree(ptr noundef %43)
  %44 = call ptr @sdsempty()
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.redisReader, ptr %45, i32 0, i32 2
  store ptr %44, ptr %46, align 8, !tbaa !16
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.redisReader, ptr %47, i32 0, i32 3
  store i64 0, ptr %48, align 8, !tbaa !17
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.redisReader, ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !16
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %54

53:                                               ; preds = %40
  br label %55

54:                                               ; preds = %40
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 601, ptr noundef @__PRETTY_FUNCTION__.redisReaderFeed) #6
  unreachable

55:                                               ; preds = %53
  br label %56

56:                                               ; preds = %55, %31, %26, %21
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.redisReader, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !16
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load i64, ptr %7, align 8, !tbaa !9
  %62 = call ptr @sdscatlen(ptr noundef %59, ptr noundef %60, i64 noundef %61)
  store ptr %62, ptr %8, align 8, !tbaa !5
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = icmp eq ptr %63, null
  br i1 %64, label %65, label %67

65:                                               ; preds = %56
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  call void @__redisReaderSetErrorOOM(ptr noundef %66)
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %78

67:                                               ; preds = %56
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.redisReader, ptr %69, i32 0, i32 2
  store ptr %68, ptr %70, align 8, !tbaa !16
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.redisReader, ptr %71, i32 0, i32 2
  %73 = load ptr, ptr %72, align 8, !tbaa !16
  %74 = call i64 @sdslen(ptr noundef %73)
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.redisReader, ptr %75, i32 0, i32 4
  store i64 %74, ptr %76, align 8, !tbaa !14
  br label %77

77:                                               ; preds = %67, %18, %15
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %78

78:                                               ; preds = %77, %65, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %79 = load i32, ptr %4, align 4
  ret i32 %79
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

declare ptr @sdscatlen(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @__redisReaderSetErrorOOM(ptr noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { noreturn nounwind "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 = { noreturn 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 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"redisReader", !13, i64 0, !7, i64 4, !6, i64 136, !10, i64 144, !10, i64 152, !10, i64 160, !7, i64 168, !13, i64 528, !6, i64 536, !6, i64 544, !6, i64 552}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 152}
!15 = !{!12, !10, i64 160}
!16 = !{!12, !6, i64 136}
!17 = !{!12, !10, i64 144}


; 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 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@__PRETTY_FUNCTION__.redisReaderFeed = external hidden unnamed_addr constant [57 x i8], align 1

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

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

declare ptr @sdsempty() local_unnamed_addr #1

declare void @sdsfree(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @redisReaderFeed(ptr noundef %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #2 {
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %34

5:                                                ; preds = %3
  %6 = icmp ne ptr %1, null
  %7 = icmp ne i64 %2, 0
  %or.cond = and i1 %6, %7
  br i1 %or.cond, label %8, label %34

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 152
  %10 = load i64, ptr %9, align 8, !tbaa !12
  %11 = icmp eq i64 %10, 0
  br i1 %11, label %12, label %26

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %0, i64 160
  %14 = load i64, ptr %13, align 8, !tbaa !13
  %.not24 = icmp eq i64 %14, 0
  br i1 %.not24, label %26, label %15

15:                                               ; preds = %12
  %16 = getelementptr inbounds i8, ptr %0, i64 136
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = tail call i64 @sdsavail(ptr noundef %17)
  %19 = load i64, ptr %13, align 8, !tbaa !13
  %20 = icmp ugt i64 %18, %19
  br i1 %20, label %21, label %26

21:                                               ; preds = %15
  %22 = load ptr, ptr %16, align 8, !tbaa !14
  tail call void @sdsfree(ptr noundef %22) #4
  %23 = tail call ptr @sdsempty() #4
  store ptr %23, ptr %16, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %0, i64 144
  store i64 0, ptr %24, align 8, !tbaa !15
  %.not25 = icmp eq ptr %23, null
  br i1 %.not25, label %25, label %26

25:                                               ; preds = %21
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 601, ptr noundef nonnull @__PRETTY_FUNCTION__.redisReaderFeed) #5
  unreachable

26:                                               ; preds = %21, %15, %12, %8
  %27 = getelementptr inbounds i8, ptr %0, i64 136
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  %29 = tail call ptr @sdscatlen(ptr noundef %28, ptr noundef nonnull %1, i64 noundef %2) #4
  %30 = icmp eq ptr %29, null
  br i1 %30, label %31, label %32

31:                                               ; preds = %26
  tail call void @__redisReaderSetErrorOOM(ptr noundef nonnull %0)
  br label %34

32:                                               ; preds = %26
  store ptr %29, ptr %27, align 8, !tbaa !14
  %33 = tail call i64 @sdslen(ptr noundef nonnull %29)
  store i64 %33, ptr %9, align 8, !tbaa !12
  br label %34

34:                                               ; preds = %5, %32, %3, %31
  %.0 = phi i32 [ -1, %31 ], [ -1, %3 ], [ 0, %32 ], [ 0, %5 ]
  ret i32 %.0
}

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare ptr @sdscatlen(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @__redisReaderSetErrorOOM(ptr noundef) local_unnamed_addr #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 = { "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 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 = { noreturn nounwind "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 }
attributes #5 = { noreturn 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, !7, i64 0}
!6 = !{!"redisReader", !7, i64 0, !8, i64 4, !10, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !8, i64 168, !7, i64 528, !10, i64 536, !10, i64 544, !10, i64 552}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !11, i64 152}
!13 = !{!6, !11, i64 160}
!14 = !{!6, !10, i64 136}
!15 = !{!6, !11, i64 144}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass