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

; 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

declare i32 @rl_multi_string_get(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @rl_lrange_iterator(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) #3

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

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

32:                                               ; preds = %8
  br label %98

33:                                               ; preds = %8
  %34 = load i64, ptr %23, align 8, !tbaa !9
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  store i64 %34, ptr %35, align 8, !tbaa !9
  %36 = load i64, ptr %23, align 8, !tbaa !9
  %37 = icmp eq i64 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %33
  store i32 0, ptr %18, align 4, !tbaa !11
  br label %98

39:                                               ; preds = %33
  %40 = load i64, ptr %23, align 8, !tbaa !9
  %41 = mul i64 8, %40
  %42 = call noalias ptr @malloc(i64 noundef %41) #6
  store ptr %42, ptr %21, align 8, !tbaa !5
  %43 = load ptr, ptr %21, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %46, label %45

45:                                               ; preds = %39
  store i32 4, ptr %18, align 4, !tbaa !11
  br label %98

46:                                               ; preds = %39
  %47 = load i64, ptr %23, align 8, !tbaa !9
  %48 = mul i64 8, %47
  %49 = call noalias ptr @malloc(i64 noundef %48) #6
  store ptr %49, ptr %22, align 8, !tbaa !5
  %50 = load ptr, ptr %22, align 8, !tbaa !5
  %51 = icmp ne ptr %50, null
  br i1 %51, label %53, label %52

52:                                               ; preds = %46
  store i32 4, ptr %18, align 4, !tbaa !11
  br label %98

53:                                               ; preds = %46
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %78, %53
  %55 = load i64, ptr %19, align 8, !tbaa !9
  %56 = load i64, ptr %23, align 8, !tbaa !9
  %57 = icmp slt i64 %55, %56
  br i1 %57, label %58, label %62

58:                                               ; preds = %54
  %59 = load ptr, ptr %17, align 8, !tbaa !5
  %60 = call i32 @rl_list_iterator_next(ptr noundef %59, ptr noundef %20)
  store i32 %60, ptr %18, align 4, !tbaa !11
  %61 = icmp eq i32 %60, 0
  br label %62

62:                                               ; preds = %58, %54
  %63 = phi i1 [ false, %54 ], [ %61, %58 ]
  br i1 %63, label %64, label %82

64:                                               ; preds = %62
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = load ptr, ptr %20, align 8, !tbaa !5
  %67 = load i64, ptr %66, align 8, !tbaa !9
  %68 = load ptr, ptr %21, align 8, !tbaa !5
  %69 = load i64, ptr %19, align 8, !tbaa !9
  %70 = getelementptr inbounds ptr, ptr %68, i64 %69
  %71 = load ptr, ptr %22, align 8, !tbaa !5
  %72 = load i64, ptr %19, align 8, !tbaa !9
  %73 = getelementptr inbounds i64, ptr %71, i64 %72
  %74 = call i32 @rl_multi_string_get(ptr noundef %65, i64 noundef %67, ptr noundef %70, ptr noundef %73)
  store i32 %74, ptr %18, align 4, !tbaa !11
  %75 = load i32, ptr %18, align 4, !tbaa !11
  %76 = icmp ne i32 0, %75
  br i1 %76, label %77, label %78

77:                                               ; preds = %64
  br label %98

78:                                               ; preds = %64
  %79 = load ptr, ptr %20, align 8, !tbaa !5
  call void @free(ptr noundef %79) #5
  %80 = load i64, ptr %19, align 8, !tbaa !9
  %81 = add nsw i64 %80, 1
  store i64 %81, ptr %19, align 8, !tbaa !9
  br label %54, !llvm.loop !13

82:                                               ; preds = %62
  %83 = load i32, ptr %18, align 4, !tbaa !11
  %84 = icmp ne i32 %83, 9
  br i1 %84, label %85, label %93

85:                                               ; preds = %82
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = load ptr, ptr %17, align 8, !tbaa !5
  %88 = call i32 @rl_list_iterator_destroy(ptr noundef %86, ptr noundef %87)
  %89 = load i32, ptr %18, align 4, !tbaa !11
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %92

91:                                               ; preds = %85
  br label %98

92:                                               ; preds = %85
  br label %93

93:                                               ; preds = %92, %82
  %94 = load ptr, ptr %21, align 8, !tbaa !5
  %95 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %94, ptr %95, align 8, !tbaa !5
  %96 = load ptr, ptr %22, align 8, !tbaa !5
  %97 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %96, ptr %97, align 8, !tbaa !5
  store i32 0, ptr %18, align 4, !tbaa !11
  br label %98

98:                                               ; preds = %93, %91, %77, %52, %45, %38, %32
  %99 = load i32, ptr %18, align 4, !tbaa !11
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %101, label %104

101:                                              ; preds = %98
  %102 = load ptr, ptr %21, align 8, !tbaa !5
  call void @free(ptr noundef %102) #5
  %103 = load ptr, ptr %22, align 8, !tbaa !5
  call void @free(ptr noundef %103) #5
  br label %104

104:                                              ; preds = %101, %98
  %105 = load i32, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  ret i32 %105
}

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 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

declare i32 @rl_multi_string_get(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @rl_lrange_iterator(ptr noundef, ptr noundef, i64 noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_lrange(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef writeonly %6, ptr nocapture noundef writeonly %7) local_unnamed_addr #3 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  store ptr null, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  store i64 0, ptr %11, align 8, !tbaa !9
  %12 = call i32 @rl_lrange_iterator(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, ptr noundef nonnull %11, ptr noundef nonnull %9)
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %13, label %.loopexit60

13:                                               ; preds = %8
  %14 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %14, ptr %5, align 8, !tbaa !9
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %40, label %16

16:                                               ; preds = %13
  %17 = shl i64 %14, 3
  %18 = call noalias ptr @malloc(i64 noundef %17) #6
  %.not40 = icmp eq ptr %18, null
  br i1 %.not40, label %.loopexit60, label %19

19:                                               ; preds = %16
  %20 = call noalias ptr @malloc(i64 noundef %17) #6
  %.not41 = icmp eq ptr %20, null
  br i1 %.not41, label %.loopexit60, label %.preheader

.preheader:                                       ; preds = %19
  %21 = icmp sgt i64 %14, 0
  br i1 %21, label %.lr.ph, label %.thread

.thread:                                          ; preds = %32, %.preheader
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = call i32 @rl_list_iterator_destroy(ptr noundef %0, ptr noundef %22) #5
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %32
  %.02864 = phi i64 [ %34, %32 ], [ 0, %.preheader ]
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = call i32 @rl_list_iterator_next(ptr noundef %24, ptr noundef nonnull %10) #5
  switch i32 %25, label %37 [
    i32 0, label %26
    i32 9, label %.loopexit
  ]

26:                                               ; preds = %.lr.ph
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds ptr, ptr %18, i64 %.02864
  %30 = getelementptr inbounds i64, ptr %20, i64 %.02864
  %31 = call i32 @rl_multi_string_get(ptr noundef %0, i64 noundef %28, ptr noundef nonnull %29, ptr noundef nonnull %30) #5
  %.not44 = icmp eq i32 %31, 0
  br i1 %.not44, label %32, label %.loopexit60

32:                                               ; preds = %26
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  call void @free(ptr noundef %33) #5
  %34 = add nuw nsw i64 %.02864, 1
  %35 = load i64, ptr %11, align 8, !tbaa !9
  %36 = icmp slt i64 %34, %35
  br i1 %36, label %.lr.ph, label %.thread, !llvm.loop !11

37:                                               ; preds = %.lr.ph
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = call i32 @rl_list_iterator_destroy(ptr noundef %0, ptr noundef %38) #5
  br label %.loopexit60

.loopexit:                                        ; preds = %.lr.ph, %.thread
  store ptr %18, ptr %6, align 8, !tbaa !5
  store ptr %20, ptr %7, align 8, !tbaa !5
  br label %40

.loopexit60:                                      ; preds = %26, %8, %37, %16, %19
  %.2.ph = phi i32 [ 4, %19 ], [ 4, %16 ], [ %25, %37 ], [ %12, %8 ], [ %31, %26 ]
  %.027.ph = phi ptr [ %18, %19 ], [ null, %16 ], [ %18, %37 ], [ null, %8 ], [ %18, %26 ]
  %.0.ph = phi ptr [ null, %19 ], [ null, %16 ], [ %20, %37 ], [ null, %8 ], [ %20, %26 ]
  call void @free(ptr noundef %.027.ph) #5
  call void @free(ptr noundef %.0.ph) #5
  br label %40

40:                                               ; preds = %.loopexit, %13, %.loopexit60
  %.257 = phi i32 [ %.2.ph, %.loopexit60 ], [ 0, %.loopexit ], [ 0, %13 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  ret i32 %.257
}

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 #5 = { nounwind }
attributes #6 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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