; LLVM IR from seppo0010/rlite :: src (type_zset)

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

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

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

; 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 hidden i32 @_rl_zrange(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i32 noundef, ptr noundef) #1

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

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

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

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

33:                                               ; preds = %8
  br label %83

34:                                               ; preds = %8
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = load i64, ptr %11, align 8, !tbaa !9
  %38 = call i32 @rl_zset_get_objects(ptr noundef %35, ptr noundef %36, i64 noundef %37, ptr noundef %24, ptr noundef %18, ptr noundef %20, ptr noundef %19, ptr noundef %21, i32 noundef 1, i32 noundef 1)
  store i32 %38, ptr %25, align 4, !tbaa !11
  %39 = load i32, ptr %25, align 4, !tbaa !11
  %40 = icmp ne i32 0, %39
  br i1 %40, label %41, label %42

41:                                               ; preds = %34
  br label %83

42:                                               ; preds = %34
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = load ptr, ptr %12, align 8, !tbaa !5
  %45 = load i64, ptr %13, align 8, !tbaa !9
  %46 = load ptr, ptr %14, align 8, !tbaa !5
  %47 = load i64, ptr %15, align 8, !tbaa !9
  %48 = load ptr, ptr %19, align 8, !tbaa !5
  %49 = call i32 @lex_get_range(ptr noundef %43, ptr noundef %44, i64 noundef %45, ptr noundef %46, i64 noundef %47, ptr noundef %48, ptr noundef %22, ptr noundef %23)
  store i32 %49, ptr %25, align 4, !tbaa !11
  %50 = load i32, ptr %25, align 4, !tbaa !11
  %51 = icmp eq i32 %50, 3
  br i1 %51, label %52, label %54

52:                                               ; preds = %42
  %53 = load ptr, ptr %16, align 8, !tbaa !5
  store i64 0, ptr %53, align 8, !tbaa !9
  store i32 0, ptr %25, align 4, !tbaa !11
  br label %83

54:                                               ; preds = %42
  %55 = load i32, ptr %25, align 4, !tbaa !11
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %54
  br label %83

58:                                               ; preds = %54
  %59 = load ptr, ptr %9, align 8, !tbaa !5
  %60 = load ptr, ptr %19, align 8, !tbaa !5
  %61 = load i64, ptr %22, align 8, !tbaa !9
  %62 = load i64, ptr %23, align 8, !tbaa !9
  %63 = call i32 @_rl_zrange(ptr noundef %59, ptr noundef %60, i64 noundef %61, i64 noundef %62, i32 noundef 1, ptr noundef %17)
  store i32 %63, ptr %25, align 4, !tbaa !11
  %64 = load i32, ptr %25, align 4, !tbaa !11
  %65 = icmp ne i32 0, %64
  br i1 %65, label %66, label %67

66:                                               ; preds = %58
  br label %83

67:                                               ; preds = %58
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = load i64, ptr %11, align 8, !tbaa !9
  %71 = load i64, ptr %24, align 8, !tbaa !9
  %72 = load ptr, ptr %17, align 8, !tbaa !5
  %73 = load ptr, ptr %18, align 8, !tbaa !5
  %74 = load i64, ptr %20, align 8, !tbaa !9
  %75 = load ptr, ptr %19, align 8, !tbaa !5
  %76 = load i64, ptr %21, align 8, !tbaa !9
  %77 = load ptr, ptr %16, align 8, !tbaa !5
  %78 = call i32 @_zremiterator(ptr noundef %68, ptr noundef %69, i64 noundef %70, i64 noundef %71, ptr noundef %72, ptr noundef %73, i64 noundef %74, ptr noundef %75, i64 noundef %76, ptr noundef %77)
  store i32 %78, ptr %25, align 4, !tbaa !11
  %79 = load i32, ptr %25, align 4, !tbaa !11
  %80 = icmp ne i32 0, %79
  br i1 %80, label %81, label %82

81:                                               ; preds = %67
  br label %83

82:                                               ; preds = %67
  store i32 0, ptr %25, align 4, !tbaa !11
  br label %83

83:                                               ; preds = %82, %81, %66, %57, %52, %41, %33
  %84 = load i32, ptr %25, align 4, !tbaa !11
  %85 = icmp ne i32 %84, 0
  br i1 %85, label %86, label %91

86:                                               ; preds = %83
  %87 = load ptr, ptr %16, align 8, !tbaa !5
  %88 = icmp ne ptr %87, null
  br i1 %88, label %89, label %91

89:                                               ; preds = %86
  %90 = load ptr, ptr %16, align 8, !tbaa !5
  store i64 0, ptr %90, align 8, !tbaa !9
  br label %91

91:                                               ; preds = %89, %86, %83
  %92 = load i32, ptr %25, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  ret i32 %92
}

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 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_zremrangebylex(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %7) local_unnamed_addr #1 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %14) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %15) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %16) #2
  %17 = tail call i32 @validate_lex_range(ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6)
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %18, label %36

18:                                               ; preds = %8
  %19 = call i32 @rl_zset_get_objects(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef nonnull %16, ptr noundef nonnull %10, ptr noundef nonnull %12, ptr noundef nonnull %11, ptr noundef nonnull %13, i32 noundef 1, i32 noundef 1)
  %.not33 = icmp eq i32 %19, 0
  br i1 %.not33, label %20, label %36

20:                                               ; preds = %18
  %21 = load ptr, ptr %11, align 8, !tbaa !5
  %22 = call i32 @lex_get_range(ptr noundef %0, ptr noundef %3, i64 noundef %4, ptr noundef %5, i64 noundef %6, ptr noundef %21, ptr noundef nonnull %14, ptr noundef nonnull %15)
  switch i32 %22, label %36 [
    i32 3, label %.sink.split
    i32 0, label %23
  ]

23:                                               ; preds = %20
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = load i64, ptr %14, align 8, !tbaa !9
  %26 = load i64, ptr %15, align 8, !tbaa !9
  %27 = call i32 @_rl_zrange(ptr noundef %0, ptr noundef %24, i64 noundef %25, i64 noundef %26, i32 noundef 1, ptr noundef nonnull %9)
  %.not35 = icmp eq i32 %27, 0
  br i1 %.not35, label %28, label %36

28:                                               ; preds = %23
  %29 = load i64, ptr %16, align 8, !tbaa !9
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load i64, ptr %12, align 8, !tbaa !9
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = load i64, ptr %13, align 8, !tbaa !9
  %35 = call i32 @_zremiterator(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %29, ptr noundef %30, ptr noundef %31, i64 noundef %32, ptr noundef %33, i64 noundef %34, ptr noundef %7)
  br label %36

36:                                               ; preds = %20, %28, %23, %18, %8
  %.0 = phi i32 [ %17, %8 ], [ %19, %18 ], [ %27, %23 ], [ %35, %28 ], [ %22, %20 ]
  %37 = icmp ne i32 %.0, 0
  %38 = icmp ne ptr %7, null
  %or.cond = and i1 %38, %37
  br i1 %or.cond, label %.sink.split, label %39

.sink.split:                                      ; preds = %36, %20
  %.038.ph = phi i32 [ 0, %20 ], [ %.0, %36 ]
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %.sink.split, %36
  %.038 = phi i32 [ %.0, %36 ], [ %.038.ph, %.sink.split ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %15) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #2
  ret i32 %.038
}

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


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