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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @mln_buf_new(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = call ptr @mln_alloc_m(ptr noundef %4, i64 noundef 88)
  store ptr %5, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.mln_buf_s, ptr %6, i32 0, i32 2
  store ptr null, ptr %7, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.mln_buf_s, ptr %8, i32 0, i32 1
  store ptr null, ptr %9, align 8, !tbaa !13
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.mln_buf_s, ptr %10, i32 0, i32 0
  store ptr null, ptr %11, align 8, !tbaa !14
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.mln_buf_s, ptr %12, i32 0, i32 4
  store ptr null, ptr %13, align 8, !tbaa !15
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.mln_buf_s, ptr %14, i32 0, i32 3
  store ptr null, ptr %15, align 8, !tbaa !16
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.mln_buf_s, ptr %16, i32 0, i32 5
  store ptr null, ptr %17, align 8, !tbaa !17
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.mln_buf_s, ptr %18, i32 0, i32 8
  store i64 0, ptr %19, align 8, !tbaa !18
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mln_buf_s, ptr %20, i32 0, i32 7
  store i64 0, ptr %21, align 8, !tbaa !19
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mln_buf_s, ptr %22, i32 0, i32 6
  store i64 0, ptr %23, align 8, !tbaa !20
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.mln_buf_s, ptr %24, i32 0, i32 9
  store ptr null, ptr %25, align 8, !tbaa !21
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.mln_buf_s, ptr %26, i32 0, i32 10
  %28 = load i8, ptr %27, align 8
  %29 = and i8 %28, -9
  %30 = or i8 %29, 0
  store i8 %30, ptr %27, align 8
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mln_buf_s, ptr %31, i32 0, i32 10
  %33 = load i8, ptr %32, align 8
  %34 = and i8 %33, -5
  %35 = or i8 %34, 0
  store i8 %35, ptr %32, align 8
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mln_buf_s, ptr %36, i32 0, i32 10
  %38 = load i8, ptr %37, align 8
  %39 = and i8 %38, -2
  %40 = or i8 %39, 0
  store i8 %40, ptr %37, align 8
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mln_buf_s, ptr %41, i32 0, i32 10
  %43 = load i8, ptr %42, align 8
  %44 = and i8 %43, 127
  %45 = or i8 %44, 0
  store i8 %45, ptr %42, align 8
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.mln_buf_s, ptr %46, i32 0, i32 10
  %48 = load i8, ptr %47, align 8
  %49 = and i8 %48, -65
  %50 = or i8 %49, 0
  store i8 %50, ptr %47, align 8
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.mln_buf_s, ptr %51, i32 0, i32 10
  %53 = load i8, ptr %52, align 8
  %54 = and i8 %53, -33
  %55 = or i8 %54, 0
  store i8 %55, ptr %52, align 8
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mln_buf_s, ptr %56, i32 0, i32 10
  %58 = load i8, ptr %57, align 8
  %59 = and i8 %58, -17
  %60 = or i8 %59, 0
  store i8 %60, ptr %57, align 8
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret ptr %61
}

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

declare ptr @mln_alloc_m(ptr noundef, i64 noundef) #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 = { "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 }

!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, !6, i64 16}
!10 = !{!"mln_buf_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !6, i64 72, !12, i64 80, !12, i64 80, !12, i64 80, !12, i64 80, !12, i64 80, !12, i64 80, !12, i64 80, !12, i64 80}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 0}
!15 = !{!10, !6, i64 32}
!16 = !{!10, !6, i64 24}
!17 = !{!10, !6, i64 40}
!18 = !{!10, !11, i64 64}
!19 = !{!10, !11, i64 56}
!20 = !{!10, !11, i64 48}
!21 = !{!10, !6, i64 72}


; 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 noundef ptr @mln_buf_new(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call ptr @mln_alloc_m(ptr noundef %0, i64 noundef 88) #3
  %3 = getelementptr inbounds i8, ptr %2, i64 80
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(80) %2, i8 0, i64 80, i1 false)
  %4 = load i8, ptr %3, align 8
  %5 = and i8 %4, 2
  store i8 %5, ptr %3, align 8
  ret ptr %2
}

declare ptr @mln_alloc_m(ptr noundef, i64 noundef) local_unnamed_addr #1

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

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 = { "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 = { 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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass