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

34:                                               ; preds = %9
  br label %89

35:                                               ; preds = %9
  store i32 0, ptr %22, align 4, !tbaa !11
  br label %36

36:                                               ; preds = %77, %35
  %37 = load i32, ptr %22, align 4, !tbaa !11
  %38 = load i32, ptr %15, align 4, !tbaa !11
  %39 = icmp slt i32 %37, %38
  br i1 %39, label %40, label %80

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

44:                                               ; preds = %40
  store i32 4, ptr %21, align 4, !tbaa !11
  br label %89

45:                                               ; preds = %40
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = load ptr, ptr %23, align 8, !tbaa !5
  %48 = load ptr, ptr %16, align 8, !tbaa !5
  %49 = load i32, ptr %22, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds ptr, ptr %48, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = load ptr, ptr %17, align 8, !tbaa !5
  %54 = load i32, ptr %22, align 4, !tbaa !11
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i64, ptr %53, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = call i32 @rl_multi_string_set(ptr noundef %46, ptr noundef %47, ptr noundef %52, i64 noundef %57)
  store i32 %58, ptr %21, align 4, !tbaa !11
  %59 = load i32, ptr %21, align 4, !tbaa !11
  %60 = icmp ne i32 0, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %45
  br label %89

62:                                               ; preds = %45
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = load ptr, ptr %19, align 8, !tbaa !5
  %65 = load i64, ptr %20, align 8, !tbaa !9
  %66 = load ptr, ptr %23, align 8, !tbaa !5
  %67 = load i32, ptr %14, align 4, !tbaa !11
  %68 = icmp ne i32 %67, 0
  %69 = zext i1 %68 to i64
  %70 = select i1 %68, i32 0, i32 -1
  %71 = sext i32 %70 to i64
  %72 = call i32 @rl_list_add_element(ptr noundef %63, ptr noundef %64, i64 noundef %65, ptr noundef %66, i64 noundef %71)
  store i32 %72, ptr %21, align 4, !tbaa !11
  %73 = load i32, ptr %21, align 4, !tbaa !11
  %74 = icmp ne i32 0, %73
  br i1 %74, label %75, label %76

75:                                               ; preds = %62
  br label %89

76:                                               ; preds = %62
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %22, align 4, !tbaa !11
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %22, align 4, !tbaa !11
  br label %36, !llvm.loop !13

80:                                               ; preds = %36
  %81 = load ptr, ptr %18, align 8, !tbaa !5
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %88

83:                                               ; preds = %80
  %84 = load ptr, ptr %19, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.rl_list, ptr %84, i32 0, i32 1
  %86 = load i64, ptr %85, align 8, !tbaa !15
  %87 = load ptr, ptr %18, align 8, !tbaa !5
  store i64 %86, ptr %87, align 8, !tbaa !9
  br label %88

88:                                               ; preds = %83, %80
  store i32 0, ptr %21, align 4, !tbaa !11
  br label %89

89:                                               ; preds = %88, %75, %61, %44, %34
  %90 = load i32, ptr %21, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  ret i32 %90
}

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

; 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) #0

; 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) #1

attributes #0 = { 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 = { 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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !10, i64 8}
!16 = !{!"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: nounwind uwtable
define dso_local i32 @rl_push(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, ptr nocapture noundef readonly %6, ptr nocapture noundef readonly %7, ptr noundef writeonly %8) local_unnamed_addr #0 {
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #4
  %.not = icmp ne i32 %3, 0
  %12 = zext i1 %.not to i32
  %13 = call i32 @rl_llist_get_objects(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef nonnull %11, ptr noundef nonnull %10, i32 noundef 1, i32 noundef %12)
  %.not28 = icmp eq i32 %13, 0
  br i1 %.not28, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %9
  %14 = icmp sgt i32 %5, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %.not32 = icmp eq i32 %4, 0
  %15 = sext i1 %.not32 to i64
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %17

16:                                               ; preds = %25
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %17, !llvm.loop !5

17:                                               ; preds = %.lr.ph, %16
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %16 ]
  %18 = call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #5
  %.not30 = icmp eq ptr %18, null
  br i1 %.not30, label %.loopexit, label %19

19:                                               ; preds = %17
  %20 = getelementptr inbounds ptr, ptr %6, i64 %indvars.iv
  %21 = load ptr, ptr %20, align 8, !tbaa !7
  %22 = getelementptr inbounds i64, ptr %7, i64 %indvars.iv
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = call i32 @rl_multi_string_set(ptr noundef %0, ptr noundef nonnull %18, ptr noundef %21, i64 noundef %23) #4
  %.not31 = icmp eq i32 %24, 0
  br i1 %.not31, label %25, label %.loopexit

25:                                               ; preds = %19
  %26 = load ptr, ptr %10, align 8, !tbaa !7
  %27 = load i64, ptr %11, align 8, !tbaa !11
  %28 = call i32 @rl_list_add_element(ptr noundef %0, ptr noundef %26, i64 noundef %27, ptr noundef nonnull %18, i64 noundef %15) #4
  %.not33 = icmp eq i32 %28, 0
  br i1 %.not33, label %16, label %.loopexit

._crit_edge:                                      ; preds = %16, %.preheader
  %.not29 = icmp eq ptr %8, null
  br i1 %.not29, label %.loopexit, label %29

29:                                               ; preds = %._crit_edge
  %30 = load ptr, ptr %10, align 8, !tbaa !7
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  %32 = load i64, ptr %31, align 8, !tbaa !13
  store i64 %32, ptr %8, align 8, !tbaa !11
  br label %.loopexit

.loopexit:                                        ; preds = %17, %25, %19, %._crit_edge, %29, %9
  %.022 = phi i32 [ %13, %9 ], [ 0, %29 ], [ 0, %._crit_edge ], [ 4, %17 ], [ %28, %25 ], [ %24, %19 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #4
  ret i32 %.022
}

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

; 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 #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 #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) #1

attributes #0 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !9, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"rl_list", !12, i64 0, !12, i64 8, !8, i64 16, !12, i64 24, !12, i64 32}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass