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

; 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: nounwind uwtable
define dso_local void @mln_rc4_init(ptr noundef nonnull %0, ptr noundef nonnull %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i8, align 1
  %10 = alloca [256 x i64], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 2048, ptr %10) #3
  call void @llvm.memset.p0.i64(ptr align 16 %10, i8 0, i64 2048, i1 false)
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %11

11:                                               ; preds = %32, %3
  %12 = load i32, ptr %7, align 4, !tbaa !11
  %13 = icmp ult i32 %12, 256
  br i1 %13, label %14, label %35

14:                                               ; preds = %11
  %15 = load i32, ptr %7, align 4, !tbaa !11
  %16 = trunc i32 %15 to i8
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !11
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr %17, i64 %19
  store i8 %16, ptr %20, align 1, !tbaa !13
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load i32, ptr %7, align 4, !tbaa !11
  %23 = zext i32 %22 to i64
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = urem i64 %23, %24
  %26 = getelementptr inbounds i8, ptr %21, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !13
  %28 = zext i8 %27 to i64
  %29 = load i32, ptr %7, align 4, !tbaa !11
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds [256 x i64], ptr %10, i64 0, i64 %30
  store i64 %28, ptr %31, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %14
  %33 = load i32, ptr %7, align 4, !tbaa !11
  %34 = add i32 %33, 1
  store i32 %34, ptr %7, align 4, !tbaa !11
  br label %11, !llvm.loop !14

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

36:                                               ; preds = %75, %35
  %37 = load i32, ptr %7, align 4, !tbaa !11
  %38 = icmp ult i32 %37, 256
  br i1 %38, label %39, label %78

39:                                               ; preds = %36
  %40 = load i32, ptr %8, align 4, !tbaa !11
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load i32, ptr %7, align 4, !tbaa !11
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds i8, ptr %41, i64 %43
  %45 = load i8, ptr %44, align 1, !tbaa !13
  %46 = zext i8 %45 to i32
  %47 = add i32 %40, %46
  %48 = zext i32 %47 to i64
  %49 = load i32, ptr %7, align 4, !tbaa !11
  %50 = zext i32 %49 to i64
  %51 = getelementptr inbounds [256 x i64], ptr %10, i64 0, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = add i64 %48, %52
  %54 = urem i64 %53, 256
  %55 = trunc i64 %54 to i32
  store i32 %55, ptr %8, align 4, !tbaa !11
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = load i32, ptr %7, align 4, !tbaa !11
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %56, i64 %58
  %60 = load i8, ptr %59, align 1, !tbaa !13
  store i8 %60, ptr %9, align 1, !tbaa !13
  %61 = load ptr, ptr %4, align 8, !tbaa !5
  %62 = load i32, ptr %8, align 4, !tbaa !11
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds i8, ptr %61, i64 %63
  %65 = load i8, ptr %64, align 1, !tbaa !13
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load i32, ptr %7, align 4, !tbaa !11
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds i8, ptr %66, i64 %68
  store i8 %65, ptr %69, align 1, !tbaa !13
  %70 = load i8, ptr %9, align 1, !tbaa !13
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = load i32, ptr %8, align 4, !tbaa !11
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds i8, ptr %71, i64 %73
  store i8 %70, ptr %74, align 1, !tbaa !13
  br label %75

75:                                               ; preds = %39
  %76 = load i32, ptr %7, align 4, !tbaa !11
  %77 = add i32 %76, 1
  store i32 %77, ptr %7, align 4, !tbaa !11
  br label %36, !llvm.loop !16

78:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 2048, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

; 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: 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !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"

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @mln_rc4_init(ptr nocapture noundef nonnull %0, ptr nocapture noundef nonnull readonly %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = alloca [256 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %4) #3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(2048) %4, i8 0, i64 2048, i1 false)
  br label %5

5:                                                ; preds = %5, %3
  %indvars.iv = phi i64 [ 0, %3 ], [ %indvars.iv.next.1, %5 ]
  %6 = trunc i64 %indvars.iv to i8
  %7 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv
  store i8 %6, ptr %7, align 1, !tbaa !5
  %8 = urem i64 %indvars.iv, %2
  %9 = getelementptr inbounds i8, ptr %1, i64 %8
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = zext i8 %10 to i64
  %12 = getelementptr inbounds [256 x i64], ptr %4, i64 0, i64 %indvars.iv
  store i64 %11, ptr %12, align 16, !tbaa !8
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %13 = trunc i64 %indvars.iv.next to i8
  %14 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next
  store i8 %13, ptr %14, align 1, !tbaa !5
  %15 = urem i64 %indvars.iv.next, %2
  %16 = getelementptr inbounds i8, ptr %1, i64 %15
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = zext i8 %17 to i64
  %19 = getelementptr inbounds [256 x i64], ptr %4, i64 0, i64 %indvars.iv.next
  store i64 %18, ptr %19, align 8, !tbaa !8
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond.not.1 = icmp eq i64 %indvars.iv.next.1, 256
  br i1 %exitcond.not.1, label %.preheader, label %5, !llvm.loop !10

.preheader:                                       ; preds = %5, %.preheader
  %indvars.iv28 = phi i64 [ %indvars.iv.next29.1, %.preheader ], [ 0, %5 ]
  %.02325 = phi i64 [ %37, %.preheader ], [ 0, %5 ]
  %20 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv28
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = zext i8 %21 to i64
  %23 = add nuw nsw i64 %.02325, %22
  %24 = getelementptr inbounds [256 x i64], ptr %4, i64 0, i64 %indvars.iv28
  %25 = load i64, ptr %24, align 16, !tbaa !8
  %26 = add i64 %23, %25
  %27 = and i64 %26, 255
  %28 = getelementptr inbounds i8, ptr %0, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !5
  store i8 %29, ptr %20, align 1, !tbaa !5
  store i8 %21, ptr %28, align 1, !tbaa !5
  %indvars.iv.next29 = or disjoint i64 %indvars.iv28, 1
  %30 = getelementptr inbounds i8, ptr %0, i64 %indvars.iv.next29
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %32 = zext i8 %31 to i64
  %33 = add i64 %26, %32
  %34 = getelementptr inbounds [256 x i64], ptr %4, i64 0, i64 %indvars.iv.next29
  %35 = load i64, ptr %34, align 8, !tbaa !8
  %36 = add i64 %33, %35
  %37 = and i64 %36, 255
  %38 = getelementptr inbounds i8, ptr %0, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !5
  store i8 %39, ptr %30, align 1, !tbaa !5
  store i8 %31, ptr %38, align 1, !tbaa !5
  %indvars.iv.next29.1 = add nuw nsw i64 %indvars.iv28, 2
  %exitcond31.not.1 = icmp eq i64 %indvars.iv.next29.1, 256
  br i1 %exitcond31.not.1, label %40, label %.preheader, !llvm.loop !12

40:                                               ; preds = %.preheader
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %4) #3
  ret void
}

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass