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

; 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_hash_attr = type { ptr, ptr, ptr, ptr, i64, i8, ptr, ptr, ptr }
%struct.mln_http_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i8 }
%struct.mln_websocket_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i64, i16, i16, i32 }

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_websocket_init(ptr noundef nonnull %0, ptr noundef nonnull %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.mln_hash_attr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 72, ptr %6) #3
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.mln_http_s, ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 6
  store ptr %10, ptr %11, align 8, !tbaa !12
  %12 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 7
  store ptr @mln_alloc_m, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 8
  store ptr @mln_alloc_free, ptr %13, align 8, !tbaa !16
  %14 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 0
  store ptr @mln_websocket_hash_calc, ptr %14, align 8, !tbaa !17
  %15 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 1
  store ptr @mln_websocket_hash_cmp, ptr %15, align 8, !tbaa !18
  %16 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 2
  store ptr @mln_websocket_hash_free, ptr %16, align 8, !tbaa !19
  %17 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 3
  store ptr @mln_websocket_hash_free, ptr %17, align 8, !tbaa !20
  %18 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 4
  store i64 37, ptr %18, align 8, !tbaa !21
  %19 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 5
  %20 = load i8, ptr %19, align 8
  %21 = and i8 %20, -2
  %22 = or i8 %21, 0
  store i8 %22, ptr %19, align 8
  %23 = getelementptr inbounds %struct.mln_hash_attr, ptr %6, i32 0, i32 5
  %24 = load i8, ptr %23, align 8
  %25 = and i8 %24, -3
  %26 = or i8 %25, 0
  store i8 %26, ptr %23, align 8
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.mln_websocket_s, ptr %28, i32 0, i32 0
  store ptr %27, ptr %29, align 8, !tbaa !22
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.mln_http_s, ptr %30, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mln_websocket_s, ptr %33, i32 0, i32 1
  store ptr %32, ptr %34, align 8, !tbaa !25
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.mln_http_s, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !26
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mln_websocket_s, ptr %38, i32 0, i32 2
  store ptr %37, ptr %39, align 8, !tbaa !27
  %40 = call ptr @mln_hash_new(ptr noundef %6)
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mln_websocket_s, ptr %41, i32 0, i32 3
  store ptr %40, ptr %42, align 8, !tbaa !28
  %43 = icmp eq ptr %40, null
  br i1 %43, label %44, label %45

44:                                               ; preds = %2
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

45:                                               ; preds = %2
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.mln_websocket_s, ptr %46, i32 0, i32 6
  store ptr null, ptr %47, align 8, !tbaa !29
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.mln_websocket_s, ptr %48, i32 0, i32 5
  store ptr null, ptr %49, align 8, !tbaa !30
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.mln_websocket_s, ptr %50, i32 0, i32 4
  store ptr null, ptr %51, align 8, !tbaa !31
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.mln_websocket_s, ptr %52, i32 0, i32 7
  store ptr null, ptr %53, align 8, !tbaa !32
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.mln_websocket_s, ptr %54, i32 0, i32 8
  store ptr null, ptr %55, align 8, !tbaa !33
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mln_websocket_s, ptr %56, i32 0, i32 9
  store ptr null, ptr %57, align 8, !tbaa !34
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mln_websocket_s, ptr %58, i32 0, i32 10
  store i64 0, ptr %59, align 8, !tbaa !35
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.mln_websocket_s, ptr %60, i32 0, i32 11
  %62 = load i16, ptr %61, align 8
  %63 = and i16 %62, -2
  %64 = or i16 %63, 0
  store i16 %64, ptr %61, align 8
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.mln_websocket_s, ptr %65, i32 0, i32 11
  %67 = load i16, ptr %66, align 8
  %68 = and i16 %67, -3
  %69 = or i16 %68, 0
  store i16 %69, ptr %66, align 8
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.mln_websocket_s, ptr %70, i32 0, i32 11
  %72 = load i16, ptr %71, align 8
  %73 = and i16 %72, -17
  %74 = or i16 %73, 0
  store i16 %74, ptr %71, align 8
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.mln_websocket_s, ptr %75, i32 0, i32 11
  %77 = load i16, ptr %76, align 8
  %78 = and i16 %77, -9
  %79 = or i16 %78, 0
  store i16 %79, ptr %76, align 8
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.mln_websocket_s, ptr %80, i32 0, i32 11
  %82 = load i16, ptr %81, align 8
  %83 = and i16 %82, -5
  %84 = or i16 %83, 0
  store i16 %84, ptr %81, align 8
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.mln_websocket_s, ptr %85, i32 0, i32 11
  %87 = load i16, ptr %86, align 8
  %88 = and i16 %87, -481
  %89 = or i16 %88, 0
  store i16 %89, ptr %86, align 8
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.mln_websocket_s, ptr %90, i32 0, i32 11
  %92 = load i16, ptr %91, align 8
  %93 = and i16 %92, -513
  %94 = or i16 %93, 0
  store i16 %94, ptr %91, align 8
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.mln_websocket_s, ptr %95, i32 0, i32 12
  store i16 0, ptr %96, align 2, !tbaa !36
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.mln_websocket_s, ptr %97, i32 0, i32 13
  store i32 0, ptr %98, align 4, !tbaa !37
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

99:                                               ; preds = %45, %44
  call void @llvm.lifetime.end.p0(i64 72, ptr %6) #3
  %100 = load i32, ptr %3, align 4
  ret i32 %100
}

; 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

declare void @mln_alloc_free(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @mln_websocket_hash_cmp(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @mln_websocket_hash_free(ptr noundef) #0

declare ptr @mln_hash_new(ptr 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 8}
!10 = !{!"mln_http_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !11, i64 96}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 48}
!13 = !{!"mln_hash_attr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !11, i64 40, !11, i64 40, !6, i64 48, !6, i64 56, !6, i64 64}
!14 = !{!"long", !7, i64 0}
!15 = !{!13, !6, i64 56}
!16 = !{!13, !6, i64 64}
!17 = !{!13, !6, i64 0}
!18 = !{!13, !6, i64 8}
!19 = !{!13, !6, i64 16}
!20 = !{!13, !6, i64 24}
!21 = !{!13, !14, i64 32}
!22 = !{!23, !6, i64 0}
!23 = !{!"mln_websocket_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !14, i64 80, !24, i64 88, !24, i64 88, !24, i64 88, !24, i64 88, !24, i64 88, !24, i64 88, !24, i64 89, !24, i64 89, !24, i64 90, !11, i64 92}
!24 = !{!"short", !7, i64 0}
!25 = !{!23, !6, i64 8}
!26 = !{!10, !6, i64 0}
!27 = !{!23, !6, i64 16}
!28 = !{!23, !6, i64 24}
!29 = !{!23, !6, i64 48}
!30 = !{!23, !6, i64 40}
!31 = !{!23, !6, i64 32}
!32 = !{!23, !6, i64 56}
!33 = !{!23, !6, i64 64}
!34 = !{!23, !6, i64 72}
!35 = !{!23, !14, i64 80}
!36 = !{!23, !24, i64 90}
!37 = !{!23, !11, i64 92}


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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @mln_websocket_init(ptr nocapture noundef nonnull %0, ptr noundef nonnull %1) local_unnamed_addr #0 {
  %3 = alloca %struct.mln_hash_attr, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %3) #4
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %3, i64 48
  store ptr %5, ptr %6, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %3, i64 56
  store ptr @mln_alloc_m, ptr %7, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %3, i64 64
  store ptr @mln_alloc_free, ptr %8, align 8, !tbaa !15
  store ptr @mln_websocket_hash_calc, ptr %3, align 8, !tbaa !16
  %9 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr @mln_websocket_hash_cmp, ptr %9, align 8, !tbaa !17
  %10 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr @mln_websocket_hash_free, ptr %10, align 8, !tbaa !18
  %11 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr @mln_websocket_hash_free, ptr %11, align 8, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %3, i64 32
  store i64 37, ptr %12, align 8, !tbaa !20
  %13 = getelementptr inbounds i8, ptr %3, i64 40
  store i8 0, ptr %13, align 8
  store ptr %1, ptr %0, align 8, !tbaa !21
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %5, ptr %14, align 8, !tbaa !24
  %15 = load ptr, ptr %1, align 8, !tbaa !25
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %15, ptr %16, align 8, !tbaa !26
  %17 = call ptr @mln_hash_new(ptr noundef nonnull %3) #4
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %17, ptr %18, align 8, !tbaa !27
  %19 = icmp eq ptr %17, null
  br i1 %19, label %27, label %20

20:                                               ; preds = %2
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  %22 = getelementptr inbounds i8, ptr %0, i64 88
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %21, i8 0, i64 56, i1 false)
  %23 = load i16, ptr %22, align 8
  %24 = and i16 %23, -1024
  store i16 %24, ptr %22, align 8
  %25 = getelementptr inbounds i8, ptr %0, i64 90
  store i16 0, ptr %25, align 2, !tbaa !28
  %26 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 0, ptr %26, align 4, !tbaa !29
  br label %27

27:                                               ; preds = %2, %20
  %.0 = phi i32 [ 0, %20 ], [ -1, %2 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #4
  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

declare ptr @mln_alloc_m(ptr noundef, i64 noundef) #2

declare void @mln_alloc_free(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @mln_websocket_hash_cmp(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @mln_websocket_hash_free(ptr noundef) #0

declare ptr @mln_hash_new(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.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) #3

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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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, !7, i64 8}
!6 = !{!"mln_http_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !7, i64 48}
!12 = !{!"mln_hash_attr", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !13, i64 32, !10, i64 40, !10, i64 40, !7, i64 48, !7, i64 56, !7, i64 64}
!13 = !{!"long", !8, i64 0}
!14 = !{!12, !7, i64 56}
!15 = !{!12, !7, i64 64}
!16 = !{!12, !7, i64 0}
!17 = !{!12, !7, i64 8}
!18 = !{!12, !7, i64 16}
!19 = !{!12, !7, i64 24}
!20 = !{!12, !13, i64 32}
!21 = !{!22, !7, i64 0}
!22 = !{!"mln_websocket_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !13, i64 80, !23, i64 88, !23, i64 88, !23, i64 88, !23, i64 88, !23, i64 88, !23, i64 88, !23, i64 89, !23, i64 89, !23, i64 90, !10, i64 92}
!23 = !{!"short", !8, i64 0}
!24 = !{!22, !7, i64 8}
!25 = !{!6, !7, i64 0}
!26 = !{!22, !7, i64 16}
!27 = !{!22, !7, i64 24}
!28 = !{!22, !23, i64 90}
!29 = !{!22, !10, i64 92}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass