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

declare void @mln_alloc_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden i32 @mln_websocket_masking_key_generate() #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mln_websocket_generate(ptr noundef nonnull, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_websocket_ping_generate(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = and i32 %8, 4
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %16

11:                                               ; preds = %3
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = and i32 %12, 8
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %11
  store i32 -1, ptr %4, align 4
  br label %83

16:                                               ; preds = %11, %3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.mln_websocket_s, ptr %17, i32 0, i32 11
  %19 = load i16, ptr %18, align 8
  %20 = and i16 %19, 1
  %21 = icmp ne i16 %20, 0
  br i1 %21, label %22, label %26

22:                                               ; preds = %16
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.mln_websocket_s, ptr %23, i32 0, i32 8
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  call void @mln_alloc_free(ptr noundef %25)
  br label %26

26:                                               ; preds = %22, %16
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.mln_websocket_s, ptr %27, i32 0, i32 8
  store ptr null, ptr %28, align 8, !tbaa !11
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mln_websocket_s, ptr %29, i32 0, i32 10
  store i64 0, ptr %30, align 8, !tbaa !15
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mln_websocket_s, ptr %31, i32 0, i32 11
  %33 = load i16, ptr %32, align 8
  %34 = and i16 %33, -2
  %35 = or i16 %34, 0
  store i16 %35, ptr %32, align 8
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.mln_websocket_s, ptr %36, i32 0, i32 11
  %38 = load i16, ptr %37, align 8
  %39 = and i16 %38, -3
  %40 = or i16 %39, 2
  store i16 %40, ptr %37, align 8
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.mln_websocket_s, ptr %41, i32 0, i32 11
  %43 = load i16, ptr %42, align 8
  %44 = and i16 %43, -5
  %45 = or i16 %44, 0
  store i16 %45, ptr %42, align 8
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.mln_websocket_s, ptr %46, i32 0, i32 11
  %48 = load i16, ptr %47, align 8
  %49 = and i16 %48, -9
  %50 = or i16 %49, 0
  store i16 %50, ptr %47, align 8
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.mln_websocket_s, ptr %51, i32 0, i32 11
  %53 = load i16, ptr %52, align 8
  %54 = and i16 %53, -17
  %55 = or i16 %54, 0
  store i16 %55, ptr %52, align 8
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mln_websocket_s, ptr %56, i32 0, i32 11
  %58 = load i16, ptr %57, align 8
  %59 = and i16 %58, -481
  %60 = or i16 %59, 288
  store i16 %60, ptr %57, align 8
  %61 = load i32, ptr %7, align 4, !tbaa !9
  %62 = and i32 %61, 4
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %73

64:                                               ; preds = %26
  %65 = load ptr, ptr %5, 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, -513
  %69 = or i16 %68, 512
  store i16 %69, ptr %66, align 8
  %70 = call i32 @mln_websocket_masking_key_generate()
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.mln_websocket_s, ptr %71, i32 0, i32 13
  store i32 %70, ptr %72, align 4, !tbaa !16
  br label %79

73:                                               ; preds = %26
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.mln_websocket_s, ptr %74, i32 0, i32 11
  %76 = load i16, ptr %75, align 8
  %77 = and i16 %76, -513
  %78 = or i16 %77, 0
  store i16 %78, ptr %75, align 8
  br label %79

79:                                               ; preds = %73, %64
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = call i32 @mln_websocket_generate(ptr noundef %80, ptr noundef %81)
  store i32 %82, ptr %4, align 4
  br label %83

83:                                               ; preds = %79, %15
  %84 = load i32, ptr %4, align 4
  ret i32 %84
}

attributes #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" }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 64}
!12 = !{!"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, !13, i64 80, !14, i64 88, !14, i64 88, !14, i64 88, !14, i64 88, !14, i64 88, !14, i64 88, !14, i64 89, !14, i64 89, !14, i64 90, !10, i64 92}
!13 = !{!"long", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !13, i64 80}
!16 = !{!12, !10, 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"

declare void @mln_alloc_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @mln_websocket_masking_key_generate() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @mln_websocket_generate(ptr noundef nonnull, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @mln_websocket_ping_generate(ptr noundef nonnull %0, ptr noundef nonnull %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = and i32 %2, 4
  %.not = icmp eq i32 %4, 0
  %5 = and i32 %2, 12
  %or.cond.not = icmp eq i32 %5, 12
  br i1 %or.cond.not, label %26, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 88
  %8 = load i16, ptr %7, align 8
  %9 = and i16 %8, 1
  %.not19 = icmp eq i16 %9, 0
  br i1 %.not19, label %13, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %0, i64 64
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  tail call void @mln_alloc_free(ptr noundef %12) #2
  %.pre = load i16, ptr %7, align 8
  br label %13

13:                                               ; preds = %10, %6
  %14 = phi i16 [ %.pre, %10 ], [ %8, %6 ]
  %15 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr null, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 80
  store i64 0, ptr %16, align 8, !tbaa !13
  %17 = and i16 %14, -1024
  br i1 %.not, label %22, label %18

18:                                               ; preds = %13
  %19 = or disjoint i16 %17, 802
  store i16 %19, ptr %7, align 8
  %20 = tail call i32 @mln_websocket_masking_key_generate()
  %21 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 %20, ptr %21, align 4, !tbaa !14
  br label %24

22:                                               ; preds = %13
  %23 = or disjoint i16 %17, 290
  store i16 %23, ptr %7, align 8
  br label %24

24:                                               ; preds = %22, %18
  %25 = tail call i32 @mln_websocket_generate(ptr noundef %0, ptr noundef nonnull %1)
  br label %26

26:                                               ; preds = %3, %24
  %.0 = phi i32 [ %25, %24 ], [ -1, %3 ]
  ret i32 %.0
}

attributes #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 = { 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 64}
!6 = !{!"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, !10, i64 80, !11, i64 88, !11, i64 88, !11, i64 88, !11, i64 88, !11, i64 88, !11, i64 88, !11, i64 89, !11, i64 89, !11, i64 90, !12, i64 92}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!6, !10, i64 80}
!14 = !{!6, !12, i64 92}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass