; LLVM IR from Water-Melon/Melon :: src (mln_tools)

; 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_boot_t = type { ptr, ptr, ptr, i64 }

@boot_params = external dso_local global [3 x %struct.mln_boot_t], align 16

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

; 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
define dso_local i32 @mln_boot_params(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store ptr getelementptr inbounds (%struct.mln_boot_t, ptr @boot_params, i64 3), ptr %10, align 8, !tbaa !9
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %70, %2
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %73

16:                                               ; preds = %12
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds ptr, ptr %17, i64 %19
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  store ptr %21, ptr %8, align 8, !tbaa !9
  store ptr @boot_params, ptr %9, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %66, %16
  %23 = load ptr, ptr %9, align 8, !tbaa !9
  %24 = load ptr, ptr %10, align 8, !tbaa !9
  %25 = icmp ult ptr %23, %24
  br i1 %25, label %26, label %69

26:                                               ; preds = %22
  %27 = load ptr, ptr %9, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.mln_boot_t, ptr %27, i32 0, i32 3
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %65, label %31

31:                                               ; preds = %26
  %32 = load ptr, ptr %8, align 8, !tbaa !9
  %33 = load ptr, ptr %9, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.mln_boot_t, ptr %33, i32 0, i32 0
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = call i32 @strcmp(ptr noundef %32, ptr noundef %35) #4
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %45

38:                                               ; preds = %31
  %39 = load ptr, ptr %8, align 8, !tbaa !9
  %40 = load ptr, ptr %9, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.mln_boot_t, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = call i32 @strcmp(ptr noundef %39, ptr noundef %42) #4
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %65, label %45

45:                                               ; preds = %38, %31
  %46 = load ptr, ptr %9, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.mln_boot_t, ptr %46, i32 0, i32 3
  %48 = load i64, ptr %47, align 8, !tbaa !11
  %49 = add i64 %48, 1
  store i64 %49, ptr %47, align 8, !tbaa !11
  %50 = load ptr, ptr %9, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct.mln_boot_t, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = load ptr, ptr %9, align 8, !tbaa !9
  %54 = getelementptr inbounds %struct.mln_boot_t, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !14
  %56 = load ptr, ptr %9, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.mln_boot_t, ptr %56, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = call i32 %52(ptr noundef %55, ptr noundef %58)
  store i32 %59, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = icmp slt i32 %60, 0
  br i1 %61, label %62, label %64

62:                                               ; preds = %45
  %63 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %63, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %74

64:                                               ; preds = %45
  br label %65

65:                                               ; preds = %64, %38, %26
  br label %66

66:                                               ; preds = %65
  %67 = load ptr, ptr %9, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.mln_boot_t, ptr %67, i32 1
  store ptr %68, ptr %9, align 8, !tbaa !9
  br label %22, !llvm.loop !17

69:                                               ; preds = %22
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %6, align 4, !tbaa !5
  br label %12, !llvm.loop !19

73:                                               ; preds = %12
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %74

74:                                               ; preds = %73, %62
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %75 = load i32, ptr %3, align 4
  ret i32 %75
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #2

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 willreturn memory(read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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, !13, i64 24}
!12 = !{!"", !10, i64 0, !10, i64 8, !10, i64 16, !13, i64 24}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !10, i64 0}
!15 = !{!12, !10, i64 8}
!16 = !{!12, !10, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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_boot_t = type { ptr, ptr, ptr, i64 }

@boot_params = external dso_local local_unnamed_addr global [3 x %struct.mln_boot_t], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 -2147483648, 1) i32 @mln_boot_params(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = icmp sgt i32 %0, 1
  br i1 %3, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %38
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %38 ]
  %4 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = load i64, ptr getelementptr inbounds (i8, ptr @boot_params, i64 24), align 8, !tbaa !9
  %.not = icmp eq i64 %6, 0
  br i1 %.not, label %7, label %16

7:                                                ; preds = %.lr.ph
  %8 = load ptr, ptr @boot_params, align 16, !tbaa !12
  %9 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %8) #2
  %.not22 = icmp eq i32 %9, 0
  %.pre = load ptr, ptr getelementptr inbounds (i8, ptr @boot_params, i64 8), align 8, !tbaa !13
  br i1 %.not22, label %12, label %10

10:                                               ; preds = %7
  %11 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %.pre) #2
  %.not23 = icmp eq i32 %11, 0
  br i1 %.not23, label %12, label %16

12:                                               ; preds = %10, %7
  store i64 1, ptr getelementptr inbounds (i8, ptr @boot_params, i64 24), align 8, !tbaa !9
  %13 = load ptr, ptr getelementptr inbounds (i8, ptr @boot_params, i64 16), align 16, !tbaa !14
  %14 = tail call i32 %13(ptr noundef %8, ptr noundef %.pre) #3
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %.loopexit, label %16

16:                                               ; preds = %.lr.ph, %10, %12
  %17 = load i64, ptr getelementptr inbounds (i8, ptr @boot_params, i64 56), align 8, !tbaa !9
  %.not.1 = icmp eq i64 %17, 0
  br i1 %.not.1, label %18, label %27

18:                                               ; preds = %16
  %19 = load ptr, ptr getelementptr inbounds (i8, ptr @boot_params, i64 32), align 16, !tbaa !12
  %20 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %19) #2
  %.not22.1 = icmp eq i32 %20, 0
  %.pre30 = load ptr, ptr getelementptr inbounds (i8, ptr @boot_params, i64 40), align 8, !tbaa !13
  br i1 %.not22.1, label %23, label %21

21:                                               ; preds = %18
  %22 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %.pre30) #2
  %.not23.1 = icmp eq i32 %22, 0
  br i1 %.not23.1, label %23, label %27

23:                                               ; preds = %21, %18
  store i64 1, ptr getelementptr inbounds (i8, ptr @boot_params, i64 56), align 8, !tbaa !9
  %24 = load ptr, ptr getelementptr inbounds (i8, ptr @boot_params, i64 48), align 16, !tbaa !14
  %25 = tail call i32 %24(ptr noundef %19, ptr noundef %.pre30) #3
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %.loopexit, label %27

27:                                               ; preds = %23, %21, %16
  %28 = load i64, ptr getelementptr inbounds (i8, ptr @boot_params, i64 88), align 8, !tbaa !9
  %.not.2 = icmp eq i64 %28, 0
  br i1 %.not.2, label %29, label %38

29:                                               ; preds = %27
  %30 = load ptr, ptr getelementptr inbounds (i8, ptr @boot_params, i64 64), align 16, !tbaa !12
  %31 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %30) #2
  %.not22.2 = icmp eq i32 %31, 0
  %.pre31 = load ptr, ptr getelementptr inbounds (i8, ptr @boot_params, i64 72), align 8, !tbaa !13
  br i1 %.not22.2, label %34, label %32

32:                                               ; preds = %29
  %33 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %5, ptr noundef nonnull dereferenceable(1) %.pre31) #2
  %.not23.2 = icmp eq i32 %33, 0
  br i1 %.not23.2, label %34, label %38

34:                                               ; preds = %32, %29
  store i64 1, ptr getelementptr inbounds (i8, ptr @boot_params, i64 88), align 8, !tbaa !9
  %35 = load ptr, ptr getelementptr inbounds (i8, ptr @boot_params, i64 80), align 16, !tbaa !14
  %36 = tail call i32 %35(ptr noundef %30, ptr noundef %.pre31) #3
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %.loopexit, label %38

38:                                               ; preds = %34, %32, %27
  %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 %.loopexit, label %.lr.ph, !llvm.loop !15

.loopexit:                                        ; preds = %38, %12, %23, %34, %2
  %.0 = phi i32 [ 0, %2 ], [ 0, %38 ], [ %36, %34 ], [ %25, %23 ], [ %14, %12 ]
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #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 nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }
attributes #3 = { 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, !11, i64 24}
!10 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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