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

%struct.rl_list = type { i64, i64, ptr, i64, i64 }

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

declare i32 @rl_multi_string_set(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #3

declare i32 @rl_list_add_element(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) #3

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

declare i32 @rl_list_get_element(ptr noundef, ptr noundef, ptr noundef, i64 noundef) #3

declare i32 @rl_list_remove_element(ptr noundef, ptr noundef, i64 noundef, i64 noundef) #3

declare i32 @rl_multi_string_delete(ptr noundef, i64 noundef) #3

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

24:                                               ; preds = %6
  br label %96

25:                                               ; preds = %6
  %26 = load i64, ptr %10, align 8, !tbaa !9
  %27 = icmp slt i64 %26, 0
  br i1 %27, label %28, label %38

28:                                               ; preds = %25
  %29 = load ptr, ptr %13, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.rl_list, ptr %29, i32 0, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !13
  %32 = load i64, ptr %10, align 8, !tbaa !9
  %33 = add nsw i64 %32, %31
  store i64 %33, ptr %10, align 8, !tbaa !9
  %34 = load i64, ptr %10, align 8, !tbaa !9
  %35 = icmp slt i64 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %28
  store i32 5, ptr %14, align 4, !tbaa !11
  br label %96

37:                                               ; preds = %28
  br label %38

38:                                               ; preds = %37, %25
  %39 = load i64, ptr %10, align 8, !tbaa !9
  %40 = load ptr, ptr %13, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.rl_list, ptr %40, i32 0, i32 1
  %42 = load i64, ptr %41, align 8, !tbaa !13
  %43 = icmp sge i64 %39, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %38
  store i32 5, ptr %14, align 4, !tbaa !11
  br label %96

45:                                               ; preds = %38
  %46 = call noalias ptr @malloc(i64 noundef 8) #5
  store ptr %46, ptr %16, align 8, !tbaa !5
  %47 = load ptr, ptr %16, align 8, !tbaa !5
  %48 = icmp ne ptr %47, null
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  store i32 4, ptr %14, align 4, !tbaa !11
  br label %96

50:                                               ; preds = %45
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load ptr, ptr %16, align 8, !tbaa !5
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = load i64, ptr %12, align 8, !tbaa !9
  %55 = call i32 @rl_multi_string_set(ptr noundef %51, ptr noundef %52, ptr noundef %53, i64 noundef %54)
  store i32 %55, ptr %14, align 4, !tbaa !11
  %56 = load i32, ptr %14, align 4, !tbaa !11
  %57 = icmp ne i32 0, %56
  br i1 %57, label %58, label %59

58:                                               ; preds = %50
  br label %96

59:                                               ; preds = %50
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %13, align 8, !tbaa !5
  %62 = load i64, ptr %15, align 8, !tbaa !9
  %63 = load ptr, ptr %16, align 8, !tbaa !5
  %64 = load i64, ptr %10, align 8, !tbaa !9
  %65 = add nsw i64 %64, 1
  %66 = call i32 @rl_list_add_element(ptr noundef %60, ptr noundef %61, i64 noundef %62, ptr noundef %63, i64 noundef %65)
  store i32 %66, ptr %14, align 4, !tbaa !11
  %67 = load i32, ptr %14, align 4, !tbaa !11
  %68 = icmp ne i32 0, %67
  br i1 %68, label %69, label %70

69:                                               ; preds = %59
  br label %96

70:                                               ; preds = %59
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = load i64, ptr %10, align 8, !tbaa !9
  %74 = call i32 @rl_list_get_element(ptr noundef %71, ptr noundef %72, ptr noundef %17, i64 noundef %73)
  store i32 %74, ptr %14, align 4, !tbaa !11
  %75 = load i32, ptr %14, align 4, !tbaa !11
  %76 = icmp ne i32 2, %75
  br i1 %76, label %77, label %78

77:                                               ; preds = %70
  br label %96

78:                                               ; preds = %70
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = load ptr, ptr %17, align 8, !tbaa !5
  %81 = load i64, ptr %80, align 8, !tbaa !9
  %82 = call i32 @rl_multi_string_delete(ptr noundef %79, i64 noundef %81)
  store i32 %82, ptr %14, align 4, !tbaa !11
  %83 = load i32, ptr %14, align 4, !tbaa !11
  %84 = icmp ne i32 0, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %78
  br label %96

86:                                               ; preds = %78
  %87 = load ptr, ptr %7, align 8, !tbaa !5
  %88 = load ptr, ptr %13, align 8, !tbaa !5
  %89 = load i64, ptr %15, align 8, !tbaa !9
  %90 = load i64, ptr %10, align 8, !tbaa !9
  %91 = call i32 @rl_list_remove_element(ptr noundef %87, ptr noundef %88, i64 noundef %89, i64 noundef %90)
  store i32 %91, ptr %14, align 4, !tbaa !11
  %92 = load i32, ptr %14, align 4, !tbaa !11
  %93 = icmp ne i32 0, %92
  br i1 %93, label %94, label %95

94:                                               ; preds = %86
  br label %96

95:                                               ; preds = %86
  store i32 0, ptr %14, align 4, !tbaa !11
  br label %96

96:                                               ; preds = %95, %94, %85, %77, %69, %58, %49, %44, %36, %24
  %97 = load i32, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret i32 %97
}

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 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 #3 = { "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 = { 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 = !{!14, !10, i64 8}
!14 = !{!"rl_list", !10, i64 0, !10, i64 8, !6, i64 16, !10, i64 24, !10, i64 32}


; 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_llist_get_objects(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

declare i32 @rl_multi_string_set(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

declare i32 @rl_list_add_element(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

; 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_list_get_element(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

declare i32 @rl_list_remove_element(ptr noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

declare i32 @rl_multi_string_delete(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_lset(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #1 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #4
  %10 = call i32 @rl_llist_get_objects(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef nonnull %8, ptr noundef nonnull %7, i32 noundef 1, i32 noundef 0)
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %11, label %38

11:                                               ; preds = %6
  %12 = icmp slt i64 %3, 0
  %.pre = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %.pre, i64 8
  %14 = load i64, ptr %13, align 8, !tbaa !9
  br i1 %12, label %15, label %._crit_edge

15:                                               ; preds = %11
  %16 = add nsw i64 %14, %3
  %17 = icmp slt i64 %16, 0
  br i1 %17, label %38, label %._crit_edge

._crit_edge:                                      ; preds = %11, %15
  %.0 = phi i64 [ %16, %15 ], [ %3, %11 ]
  %.not35 = icmp slt i64 %.0, %14
  br i1 %.not35, label %18, label %38

18:                                               ; preds = %._crit_edge
  %19 = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %.not36 = icmp eq ptr %19, null
  br i1 %.not36, label %38, label %20

20:                                               ; preds = %18
  %21 = call i32 @rl_multi_string_set(ptr noundef %0, ptr noundef nonnull %19, ptr noundef %4, i64 noundef %5) #4
  %.not37 = icmp eq i32 %21, 0
  br i1 %.not37, label %22, label %38

22:                                               ; preds = %20
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load i64, ptr %8, align 8, !tbaa !12
  %25 = add nuw nsw i64 %.0, 1
  %26 = call i32 @rl_list_add_element(ptr noundef %0, ptr noundef %23, i64 noundef %24, ptr noundef nonnull %19, i64 noundef %25) #4
  %.not38 = icmp eq i32 %26, 0
  br i1 %.not38, label %27, label %38

27:                                               ; preds = %22
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = call i32 @rl_list_get_element(ptr noundef %0, ptr noundef %28, ptr noundef nonnull %9, i64 noundef %.0) #4
  %.not39 = icmp eq i32 %29, 2
  br i1 %.not39, label %30, label %38

30:                                               ; preds = %27
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = load i64, ptr %31, align 8, !tbaa !12
  %33 = call i32 @rl_multi_string_delete(ptr noundef %0, i64 noundef %32) #4
  %.not40 = icmp eq i32 %33, 0
  br i1 %.not40, label %34, label %38

34:                                               ; preds = %30
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load i64, ptr %8, align 8, !tbaa !12
  %37 = call i32 @rl_list_remove_element(ptr noundef %0, ptr noundef %35, i64 noundef %36, i64 noundef %.0) #4
  br label %38

38:                                               ; preds = %18, %._crit_edge, %15, %34, %30, %27, %22, %20, %6
  %.026 = phi i32 [ %10, %6 ], [ %21, %20 ], [ %26, %22 ], [ %29, %27 ], [ %33, %30 ], [ %37, %34 ], [ 5, %15 ], [ 5, %._crit_edge ], [ 4, %18 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  ret i32 %.026
}

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 = { 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 #3 = { "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 = { 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, !11, i64 8}
!10 = !{!"rl_list", !11, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}


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