; LLVM IR from Water-Melon/Melon :: t (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.mln_list_s = type { ptr, ptr }
%struct.test_t = type { i32, %struct.mln_list_s }

@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.mln_list_s, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #6
  call void @llvm.memset.p0.i64(ptr align 8 %5, i8 0, i64 16, i1 false)
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %29, %0
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 3
  br i1 %17, label %18, label %32

18:                                               ; preds = %15
  %19 = call noalias ptr @calloc(i64 noundef 1, i64 noundef 24) #7
  store ptr %19, ptr %3, align 8, !tbaa !9
  %20 = load ptr, ptr %3, align 8, !tbaa !9
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  store i32 -1, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %98

23:                                               ; preds = %18
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.test_t, ptr %24, i32 0, i32 1
  call void @mln_list_add(ptr noundef %5, ptr noundef %25)
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = load ptr, ptr %3, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.test_t, ptr %27, i32 0, i32 0
  store i32 %26, ptr %28, align 8, !tbaa !11
  br label %29

29:                                               ; preds = %23
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !14

32:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  store ptr null, ptr %7, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.mln_list_s, ptr %5, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %40

36:                                               ; preds = %32
  %37 = getelementptr inbounds %struct.mln_list_s, ptr %5, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !16
  %39 = getelementptr inbounds i8, ptr %38, i64 sub (i64 0, i64 ptrtoint (ptr getelementptr inbounds (%struct.test_t, ptr null, i32 0, i32 1) to i64))
  store ptr %39, ptr %7, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %36, %32
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %41, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  %42 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %42, ptr %3, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %63, %40
  %44 = load ptr, ptr %3, align 8, !tbaa !9
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %66

46:                                               ; preds = %43
  %47 = load ptr, ptr %3, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.test_t, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !11
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %49)
  br label %51

51:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store ptr null, ptr %9, align 8, !tbaa !9
  %52 = load ptr, ptr %3, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.test_t, ptr %52, i32 0, i32 1
  %54 = getelementptr inbounds %struct.mln_list_s, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = icmp ne ptr %55, null
  br i1 %56, label %57, label %63

57:                                               ; preds = %51
  %58 = load ptr, ptr %3, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.test_t, ptr %58, i32 0, i32 1
  %60 = getelementptr inbounds %struct.mln_list_s, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !17
  %62 = getelementptr inbounds i8, ptr %61, i64 sub (i64 0, i64 ptrtoint (ptr getelementptr inbounds (%struct.test_t, ptr null, i32 0, i32 1) to i64))
  store ptr %62, ptr %9, align 8, !tbaa !9
  br label %63

63:                                               ; preds = %57, %51
  %64 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %64, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  %65 = load ptr, ptr %10, align 8, !tbaa !9
  store ptr %65, ptr %3, align 8, !tbaa !9
  br label %43, !llvm.loop !18

66:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  store ptr null, ptr %11, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.mln_list_s, ptr %5, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8, !tbaa !16
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %74

70:                                               ; preds = %66
  %71 = getelementptr inbounds %struct.mln_list_s, ptr %5, i32 0, i32 1
  %72 = load ptr, ptr %71, align 8, !tbaa !16
  %73 = getelementptr inbounds i8, ptr %72, i64 sub (i64 0, i64 ptrtoint (ptr getelementptr inbounds (%struct.test_t, ptr null, i32 0, i32 1) to i64))
  store ptr %73, ptr %11, align 8, !tbaa !9
  br label %74

74:                                               ; preds = %70, %66
  %75 = load ptr, ptr %11, align 8, !tbaa !9
  store ptr %75, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  %76 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %76, ptr %3, align 8, !tbaa !9
  br label %77

77:                                               ; preds = %93, %74
  %78 = load ptr, ptr %3, align 8, !tbaa !9
  %79 = icmp ne ptr %78, null
  br i1 %79, label %80, label %97

80:                                               ; preds = %77
  %81 = load ptr, ptr %3, align 8, !tbaa !9
  store ptr %81, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store ptr null, ptr %13, align 8, !tbaa !9
  %82 = load ptr, ptr %3, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.test_t, ptr %82, i32 0, i32 1
  %84 = getelementptr inbounds %struct.mln_list_s, ptr %83, i32 0, i32 0
  %85 = load ptr, ptr %84, align 8, !tbaa !17
  %86 = icmp ne ptr %85, null
  br i1 %86, label %87, label %93

87:                                               ; preds = %80
  %88 = load ptr, ptr %3, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.test_t, ptr %88, i32 0, i32 1
  %90 = getelementptr inbounds %struct.mln_list_s, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !17
  %92 = getelementptr inbounds i8, ptr %91, i64 sub (i64 0, i64 ptrtoint (ptr getelementptr inbounds (%struct.test_t, ptr null, i32 0, i32 1) to i64))
  store ptr %92, ptr %13, align 8, !tbaa !9
  br label %93

93:                                               ; preds = %87, %80
  %94 = load ptr, ptr %13, align 8, !tbaa !9
  store ptr %94, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  %95 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %95, ptr %3, align 8, !tbaa !9
  %96 = load ptr, ptr %4, align 8, !tbaa !9
  call void @free(ptr noundef %96) #6
  br label %77, !llvm.loop !19

97:                                               ; preds = %77
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %98

98:                                               ; preds = %97, %22
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  %99 = load i32, ptr %1, align 4
  ret i32 %99
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

declare void @mln_list_add(ptr noundef, ptr noundef) #4

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

declare i32 @printf(ptr noundef, ...) #4

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

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nounwind allocsize(0,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 #4 = { "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 "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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"", !6, i64 0, !13, i64 8}
!13 = !{!"mln_list_s", !10, i64 0, !10, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!13, !10, i64 8}
!17 = !{!12, !10, i64 8}
!18 = distinct !{!18, !15}
!19 = distinct !{!19, !15}


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

%struct.mln_list_s = type { ptr, ptr }

@.str = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.mln_list_s, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #7
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %1, i8 0, i64 16, i1 false)
  %2 = tail call noalias dereferenceable_or_null(24) ptr @calloc(i64 noundef 1, i64 noundef 24) #8
  %3 = icmp eq ptr %2, null
  br i1 %3, label %.loopexit, label %4

4:                                                ; preds = %0
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  call void @mln_list_add(ptr noundef nonnull %1, ptr noundef nonnull %5) #7
  store i32 0, ptr %2, align 8, !tbaa !5
  %6 = call noalias dereferenceable_or_null(24) ptr @calloc(i64 noundef 1, i64 noundef 24) #8
  %7 = icmp eq ptr %6, null
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %4
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  call void @mln_list_add(ptr noundef nonnull %1, ptr noundef nonnull %9) #7
  store i32 1, ptr %6, align 8, !tbaa !5
  %10 = call noalias dereferenceable_or_null(24) ptr @calloc(i64 noundef 1, i64 noundef 24) #8
  %11 = icmp eq ptr %10, null
  br i1 %11, label %.loopexit, label %12

12:                                               ; preds = %8
  %13 = getelementptr inbounds i8, ptr %10, i64 8
  call void @mln_list_add(ptr noundef nonnull %1, ptr noundef nonnull %13) #7
  store i32 2, ptr %10, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %.loopexit, label %select.unfold

select.unfold:                                    ; preds = %12, %select.unfold
  %.pn = phi ptr [ %18, %select.unfold ], [ %15, %12 ]
  %.02650 = getelementptr inbounds i8, ptr %.pn, i64 -8
  %16 = load i32, ptr %.02650, align 8, !tbaa !5
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %16)
  %18 = load ptr, ptr %.pn, align 8, !tbaa !13
  %.not38 = icmp eq ptr %18, null
  br i1 %.not38, label %select.unfold._crit_edge, label %select.unfold

select.unfold._crit_edge:                         ; preds = %select.unfold
  %.pre = load ptr, ptr %14, align 8, !tbaa !12
  %.not35 = icmp eq ptr %.pre, null
  br i1 %.not35, label %.loopexit, label %select.unfold43

select.unfold43:                                  ; preds = %select.unfold._crit_edge, %select.unfold43
  %.pn55 = phi ptr [ %19, %select.unfold43 ], [ %.pre, %select.unfold._crit_edge ]
  %.151 = getelementptr inbounds i8, ptr %.pn55, i64 -8
  %19 = load ptr, ptr %.pn55, align 8, !tbaa !13
  %.not37 = icmp eq ptr %19, null
  call void @free(ptr noundef nonnull %.151) #7
  br i1 %.not37, label %.loopexit, label %select.unfold43

.loopexit:                                        ; preds = %select.unfold43, %12, %0, %4, %8, %select.unfold._crit_edge
  %.0 = phi i32 [ 0, %select.unfold._crit_edge ], [ -1, %8 ], [ -1, %4 ], [ -1, %0 ], [ 0, %12 ], [ 0, %select.unfold43 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #7
  ret i32 %.0
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

declare void @mln_list_add(ptr noundef, ptr noundef) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5

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

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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #4 = { "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 = { nofree 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }

!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 = !{!"", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"mln_list_s", !11, i64 0, !11, i64 8}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!6, !11, i64 8}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass