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

; 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: inlinehint nounwind uwtable
declare hidden void @mln_string_vector_free(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @mln_fec_encode(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i16 noundef zeroext %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i16, align 2
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i64 %3, ptr %10, align 8, !tbaa !9
  store i16 %4, ptr %11, align 2, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 8, 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %38, label %22

22:                                               ; preds = %5
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %38, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %38, label %28

28:                                               ; preds = %25
  %29 = load i64, ptr %10, align 8, !tbaa !9
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %31, label %38

31:                                               ; preds = %28
  %32 = load i16, ptr %11, align 2, !tbaa !11
  %33 = zext i16 %32 to i32
  %34 = icmp sgt i32 %33, 48
  br i1 %34, label %38, label %35

35:                                               ; preds = %31
  %36 = load i16, ptr %11, align 2, !tbaa !11
  %37 = icmp ne i16 %36, 0
  br i1 %37, label %40, label %38

38:                                               ; preds = %35, %31, %28, %25, %22, %5
  %39 = call ptr @__errno_location() #5
  store i32 22, ptr %39, align 4, !tbaa !13
  store ptr null, ptr %6, align 8
  store i32 1, ptr %19, align 4
  br label %127

40:                                               ; preds = %35
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %41, ptr %12, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = load i64, ptr %10, align 8, !tbaa !9
  %44 = getelementptr inbounds i16, ptr %42, i64 %43
  store ptr %44, ptr %13, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %62, %40
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = load ptr, ptr %13, align 8, !tbaa !5
  %48 = icmp ult ptr %46, %47
  br i1 %48, label %49, label %65

49:                                               ; preds = %45
  %50 = load ptr, ptr %12, align 8, !tbaa !5
  %51 = load i16, ptr %50, align 2, !tbaa !11
  %52 = zext i16 %51 to i32
  %53 = icmp slt i32 %52, 12
  br i1 %53, label %59, label %54

54:                                               ; preds = %49
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = load i16, ptr %55, align 2, !tbaa !11
  %57 = zext i16 %56 to i32
  %58 = icmp sgt i32 %57, 1442
  br i1 %58, label %59, label %61

59:                                               ; preds = %54, %49
  %60 = call ptr @__errno_location() #5
  store i32 22, ptr %60, align 4, !tbaa !13
  store ptr null, ptr %6, align 8
  store i32 1, ptr %19, align 4
  br label %127

61:                                               ; preds = %54
  br label %62

62:                                               ; preds = %61
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  %64 = getelementptr inbounds i16, ptr %63, i32 1
  store ptr %64, ptr %12, align 8, !tbaa !5
  br label %45, !llvm.loop !15

65:                                               ; preds = %45
  %66 = load i64, ptr %10, align 8, !tbaa !9
  %67 = load i16, ptr %11, align 2, !tbaa !11
  %68 = zext i16 %67 to i64
  %69 = udiv i64 %66, %68
  %70 = call ptr @mln_string_vector_new(i64 noundef %69)
  store ptr %70, ptr %16, align 8, !tbaa !5
  %71 = icmp eq ptr %70, null
  br i1 %71, label %72, label %74

72:                                               ; preds = %65
  %73 = call ptr @__errno_location() #5
  store i32 12, ptr %73, align 4, !tbaa !13
  store ptr null, ptr %6, align 8
  store i32 1, ptr %19, align 4
  br label %127

74:                                               ; preds = %65
  %75 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %75, ptr %17, align 8, !tbaa !5
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %76, ptr %14, align 8, !tbaa !5
  %77 = load ptr, ptr %8, align 8, !tbaa !5
  %78 = load i64, ptr %10, align 8, !tbaa !9
  %79 = getelementptr inbounds ptr, ptr %77, i64 %78
  store ptr %79, ptr %15, align 8, !tbaa !5
  %80 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %80, ptr %12, align 8, !tbaa !5
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = load i64, ptr %10, align 8, !tbaa !9
  %83 = getelementptr inbounds i16, ptr %81, i64 %82
  store ptr %83, ptr %13, align 8, !tbaa !5
  br label %84

84:                                               ; preds = %101, %74
  %85 = load ptr, ptr %14, align 8, !tbaa !5
  %86 = load ptr, ptr %15, align 8, !tbaa !5
  %87 = icmp ult ptr %85, %86
  br i1 %87, label %88, label %114

88:                                               ; preds = %84
  %89 = load ptr, ptr %7, align 8, !tbaa !5
  %90 = load i16, ptr %11, align 2, !tbaa !11
  %91 = zext i16 %90 to i64
  %92 = load ptr, ptr %14, align 8, !tbaa !5
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = call ptr @mln_fec_generate_fecpacket(ptr noundef %89, i64 noundef %91, ptr noundef %92, ptr noundef %93)
  %95 = load ptr, ptr %17, align 8, !tbaa !5
  store ptr %94, ptr %95, align 8, !tbaa !5
  %96 = icmp eq ptr %94, null
  br i1 %96, label %97, label %100

97:                                               ; preds = %88
  %98 = load ptr, ptr %16, align 8, !tbaa !5
  call void @mln_string_vector_free(ptr noundef %98)
  %99 = call ptr @__errno_location() #5
  store i32 12, ptr %99, align 4, !tbaa !13
  store ptr null, ptr %6, align 8
  store i32 1, ptr %19, align 4
  br label %127

100:                                              ; preds = %88
  br label %101

101:                                              ; preds = %100
  %102 = load i16, ptr %11, align 2, !tbaa !11
  %103 = zext i16 %102 to i32
  %104 = load ptr, ptr %14, align 8, !tbaa !5
  %105 = sext i32 %103 to i64
  %106 = getelementptr inbounds ptr, ptr %104, i64 %105
  store ptr %106, ptr %14, align 8, !tbaa !5
  %107 = load i16, ptr %11, align 2, !tbaa !11
  %108 = zext i16 %107 to i32
  %109 = load ptr, ptr %12, align 8, !tbaa !5
  %110 = sext i32 %108 to i64
  %111 = getelementptr inbounds i16, ptr %109, i64 %110
  store ptr %111, ptr %12, align 8, !tbaa !5
  %112 = load ptr, ptr %17, align 8, !tbaa !5
  %113 = getelementptr inbounds ptr, ptr %112, i32 1
  store ptr %113, ptr %17, align 8, !tbaa !5
  br label %84, !llvm.loop !17

114:                                              ; preds = %84
  %115 = load ptr, ptr %16, align 8, !tbaa !5
  %116 = load i64, ptr %10, align 8, !tbaa !9
  %117 = load i16, ptr %11, align 2, !tbaa !11
  %118 = zext i16 %117 to i64
  %119 = udiv i64 %116, %118
  %120 = call ptr @mln_fec_result_new(ptr noundef %115, i64 noundef %119)
  store ptr %120, ptr %18, align 8, !tbaa !5
  %121 = icmp eq ptr %120, null
  br i1 %121, label %122, label %125

122:                                              ; preds = %114
  %123 = load ptr, ptr %16, align 8, !tbaa !5
  call void @mln_string_vector_free(ptr noundef %123)
  %124 = call ptr @__errno_location() #5
  store i32 12, ptr %124, align 4, !tbaa !13
  store ptr null, ptr %6, align 8
  store i32 1, ptr %19, align 4
  br label %127

125:                                              ; preds = %114
  %126 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %126, ptr %6, align 8
  store i32 1, ptr %19, align 4
  br label %127

127:                                              ; preds = %125, %122, %97, %72, %59, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  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 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %128 = load ptr, ptr %6, align 8
  ret ptr %128
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mln_string_vector_new(i64 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden ptr @mln_fec_generate_fecpacket(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden ptr @mln_fec_result_new(ptr noundef, i64 noundef) #2

attributes #0 = { inlinehint 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 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 #3 = { nounwind willreturn memory(none) "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 willreturn memory(none) }

!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 = !{!"short", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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: inlinehint nounwind uwtable
declare hidden void @mln_string_vector_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @mln_fec_encode(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i16 noundef zeroext %4) local_unnamed_addr #1 {
  %6 = icmp ne ptr %0, null
  %7 = icmp ne ptr %1, null
  %or.cond.not61.not67.not75 = and i1 %6, %7
  %8 = icmp ne ptr %2, null
  %or.cond3.not58.not64.not72 = and i1 %or.cond.not61.not67.not75, %8
  %9 = icmp ne i64 %3, 0
  %or.cond5.not62.not70 = and i1 %or.cond3.not58.not64.not72, %9
  %10 = add i16 %4, -1
  %11 = icmp ult i16 %10, 48
  %or.cond10 = and i1 %or.cond5.not62.not70, %11
  br i1 %or.cond10, label %12, label %.sink.split

12:                                               ; preds = %5
  %13 = getelementptr inbounds i16, ptr %2, i64 %3
  %14 = icmp sgt i64 %3, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

15:                                               ; preds = %.lr.ph
  %16 = getelementptr inbounds i8, ptr %.05276, i64 2
  %17 = icmp ult ptr %16, %13
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !5

.lr.ph:                                           ; preds = %12, %15
  %.05276 = phi ptr [ %16, %15 ], [ %2, %12 ]
  %18 = load i16, ptr %.05276, align 2, !tbaa !7
  %19 = add i16 %18, -1443
  %or.cond = icmp ult i16 %19, -1431
  br i1 %or.cond, label %.sink.split, label %15

._crit_edge:                                      ; preds = %15, %12
  %20 = zext nneg i16 %4 to i64
  %21 = udiv i64 %3, %20
  %22 = tail call ptr @mln_string_vector_new(i64 noundef %21)
  %23 = icmp eq ptr %22, null
  br i1 %23, label %.sink.split, label %24

24:                                               ; preds = %._crit_edge
  %25 = getelementptr inbounds ptr, ptr %1, i64 %3
  br i1 %14, label %.lr.ph81, label %._crit_edge82

.lr.ph81:                                         ; preds = %24, %28
  %.05179 = phi ptr [ %31, %28 ], [ %22, %24 ]
  %.178 = phi ptr [ %30, %28 ], [ %2, %24 ]
  %.05377 = phi ptr [ %29, %28 ], [ %1, %24 ]
  %26 = tail call ptr @mln_fec_generate_fecpacket(ptr noundef nonnull %0, i64 noundef %20, ptr noundef %.05377, ptr noundef %.178)
  store ptr %26, ptr %.05179, align 8, !tbaa !11
  %27 = icmp eq ptr %26, null
  br i1 %27, label %.sink.split.sink.split, label %28

28:                                               ; preds = %.lr.ph81
  %29 = getelementptr inbounds ptr, ptr %.05377, i64 %20
  %30 = getelementptr inbounds i16, ptr %.178, i64 %20
  %31 = getelementptr inbounds i8, ptr %.05179, i64 8
  %32 = icmp ult ptr %29, %25
  br i1 %32, label %.lr.ph81, label %._crit_edge82, !llvm.loop !13

._crit_edge82:                                    ; preds = %28, %24
  %33 = tail call ptr @mln_fec_result_new(ptr noundef nonnull %22, i64 noundef %21)
  %34 = icmp eq ptr %33, null
  br i1 %34, label %.sink.split.sink.split, label %36

.sink.split.sink.split:                           ; preds = %.lr.ph81, %._crit_edge82
  tail call void @mln_string_vector_free(ptr noundef nonnull %22)
  br label %.sink.split

.sink.split:                                      ; preds = %.lr.ph, %.sink.split.sink.split, %._crit_edge, %5
  %.sink = phi i32 [ 22, %5 ], [ 12, %._crit_edge ], [ 12, %.sink.split.sink.split ], [ 22, %.lr.ph ]
  %35 = tail call ptr @__errno_location() #3
  store i32 %.sink, ptr %35, align 4, !tbaa !14
  br label %36

36:                                               ; preds = %.sink.split, %._crit_edge82
  %.0 = phi ptr [ %33, %._crit_edge82 ], [ null, %.sink.split ]
  ret ptr %.0
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mln_string_vector_new(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden ptr @mln_fec_generate_fecpacket(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @mln_fec_result_new(ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { inlinehint 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 = { 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 nosync nounwind willreturn memory(none) "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 willreturn memory(none) }

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


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