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

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

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

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

declare ptr @mln_string_pool_dup(ptr noundef, ptr noundef) #1

declare void @mln_alloc_free(ptr noundef) #1

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

22:                                               ; preds = %40, %2
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = call ptr @mln_hash_search_iterator(ptr noundef %23, ptr noundef %24, ptr noundef %6)
  store ptr %25, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %39

28:                                               ; preds = %22
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.mln_string_t, ptr %29, i32 0, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !14
  %32 = add i64 %31, 1
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = add i64 %34, %32
  %36 = trunc i64 %35 to i32
  store i32 %36, ptr %9, align 4, !tbaa !9
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = add i32 %37, 1
  store i32 %38, ptr %10, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %28, %22
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %22, label %43, !llvm.loop !17

43:                                               ; preds = %40
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = icmp ult i32 %44, 1
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  store ptr null, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %118

47:                                               ; preds = %43
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = add i32 %49, 1
  %51 = zext i32 %50 to i64
  %52 = call ptr @mln_alloc_m(ptr noundef %48, i64 noundef %51)
  store ptr %52, ptr %8, align 8, !tbaa !5
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = icmp eq ptr %53, null
  br i1 %54, label %55, label %56

55:                                               ; preds = %47
  store ptr null, ptr %3, align 8
  store i32 1, ptr %13, align 4
  br label %118

56:                                               ; preds = %47
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %92, %56
  %58 = load ptr, ptr %12, align 8, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = call ptr @mln_hash_search_iterator(ptr noundef %58, ptr noundef %59, ptr noundef %6)
  store ptr %60, ptr %7, align 8, !tbaa !5
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %91

63:                                               ; preds = %57
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = load i32, ptr %9, align 4, !tbaa !9
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds i8, ptr %64, i64 %66
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.mln_string_t, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !19
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.mln_string_t, ptr %71, i32 0, i32 1
  %73 = load i64, ptr %72, align 8, !tbaa !14
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %67, ptr align 1 %70, i64 %73, i1 false)
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.mln_string_t, ptr %74, i32 0, i32 1
  %76 = load i64, ptr %75, align 8, !tbaa !14
  %77 = load i32, ptr %9, align 4, !tbaa !9
  %78 = zext i32 %77 to i64
  %79 = add i64 %78, %76
  %80 = trunc i64 %79 to i32
  store i32 %80, ptr %9, align 4, !tbaa !9
  %81 = load i32, ptr %10, align 4, !tbaa !9
  %82 = add i32 %81, -1
  store i32 %82, ptr %10, align 4, !tbaa !9
  %83 = icmp ugt i32 %81, 1
  br i1 %83, label %84, label %90

84:                                               ; preds = %63
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  %86 = load i32, ptr %9, align 4, !tbaa !9
  %87 = add i32 %86, 1
  store i32 %87, ptr %9, align 4, !tbaa !9
  %88 = zext i32 %86 to i64
  %89 = getelementptr inbounds i8, ptr %85, i64 %88
  store i8 44, ptr %89, align 1, !tbaa !20
  br label %90

90:                                               ; preds = %84, %63
  br label %91

91:                                               ; preds = %90, %57
  br label %92

92:                                               ; preds = %91
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = icmp ne ptr %93, null
  br i1 %94, label %57, label %95, !llvm.loop !21

95:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #4
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.mln_string_t, ptr %14, i32 0, i32 0
  store ptr %96, ptr %97, align 8, !tbaa !19
  %98 = load i32, ptr %9, align 4, !tbaa !9
  %99 = zext i32 %98 to i64
  %100 = getelementptr inbounds %struct.mln_string_t, ptr %14, i32 0, i32 1
  store i64 %99, ptr %100, align 8, !tbaa !14
  %101 = getelementptr inbounds %struct.mln_string_t, ptr %14, i32 0, i32 2
  %102 = load i32, ptr %101, align 8
  %103 = and i32 %102, -2
  %104 = or i32 %103, 1
  store i32 %104, ptr %101, align 8
  %105 = getelementptr inbounds %struct.mln_string_t, ptr %14, i32 0, i32 2
  %106 = load i32, ptr %105, align 8
  %107 = and i32 %106, -3
  %108 = or i32 %107, 0
  store i32 %108, ptr %105, align 8
  %109 = getelementptr inbounds %struct.mln_string_t, ptr %14, i32 0, i32 2
  %110 = load i32, ptr %109, align 8
  %111 = and i32 %110, 3
  %112 = or i32 %111, 4
  store i32 %112, ptr %109, align 8
  store ptr %14, ptr %15, align 8, !tbaa !5
  %113 = load ptr, ptr %15, align 8, !tbaa !5
  %114 = load ptr, ptr %11, align 8, !tbaa !5
  %115 = call ptr @mln_string_pool_dup(ptr noundef %114, ptr noundef %14)
  store ptr %115, ptr %7, align 8, !tbaa !5
  %116 = load ptr, ptr %8, align 8, !tbaa !5
  call void @mln_alloc_free(ptr noundef %116)
  %117 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %117, ptr %3, align 8
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #4
  br label %118

118:                                              ; preds = %95, %55, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %119 = load ptr, ptr %3, align 8
  ret ptr %119
}

declare ptr @mln_hash_search_iterator(ptr noundef, ptr noundef, ptr noundef) #1

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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 8}
!12 = !{!"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, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !10, i64 96}
!13 = !{!12, !6, i64 16}
!14 = !{!15, !16, i64 8}
!15 = !{!"", !6, i64 0, !16, i64 8, !16, i64 16, !16, i64 16, !16, i64 16}
!16 = !{!"long", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!15, !6, i64 0}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !18}


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

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

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

declare ptr @mln_string_pool_dup(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @mln_alloc_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @mln_http_field_iterator(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  %4 = alloca %struct.mln_string_t, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store ptr null, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !12
  br label %9

9:                                                ; preds = %18, %2
  %.031 = phi i32 [ 0, %2 ], [ %.132, %18 ]
  %.030 = phi i32 [ 0, %2 ], [ %.1, %18 ]
  %10 = call ptr @mln_hash_search_iterator(ptr noundef %8, ptr noundef %1, ptr noundef nonnull %3) #4
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %18, label %11

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %10, i64 8
  %13 = load i64, ptr %12, align 8, !tbaa !13
  %14 = trunc i64 %13 to i32
  %15 = add i32 %.030, 1
  %16 = add i32 %15, %14
  %17 = add i32 %.031, 1
  br label %18

18:                                               ; preds = %9, %11
  %.132 = phi i32 [ %17, %11 ], [ %.031, %9 ]
  %.1 = phi i32 [ %16, %11 ], [ %.030, %9 ]
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %.not38 = icmp eq ptr %19, null
  br i1 %.not38, label %20, label %9, !llvm.loop !16

20:                                               ; preds = %18
  %21 = icmp eq i32 %.132, 0
  br i1 %21, label %50, label %22

22:                                               ; preds = %20
  %23 = add i32 %.1, 1
  %24 = zext i32 %23 to i64
  %25 = call ptr @mln_alloc_m(ptr noundef %6, i64 noundef %24) #4
  %26 = icmp eq ptr %25, null
  br i1 %26, label %50, label %.preheader

.preheader:                                       ; preds = %22, %43
  %.233 = phi i32 [ %.334, %43 ], [ %.132, %22 ]
  %.2 = phi i32 [ %.3, %43 ], [ 0, %22 ]
  %27 = call ptr @mln_hash_search_iterator(ptr noundef %8, ptr noundef %1, ptr noundef nonnull %3) #4
  %.not39 = icmp eq ptr %27, null
  br i1 %.not39, label %43, label %28

28:                                               ; preds = %.preheader
  %29 = zext i32 %.2 to i64
  %30 = getelementptr inbounds i8, ptr %25, i64 %29
  %31 = load ptr, ptr %27, align 8, !tbaa !18
  %32 = getelementptr inbounds i8, ptr %27, i64 8
  %33 = load i64, ptr %32, align 8, !tbaa !13
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %30, ptr align 1 %31, i64 %33, i1 false)
  %34 = load i64, ptr %32, align 8, !tbaa !13
  %35 = trunc i64 %34 to i32
  %36 = add i32 %.2, %35
  %37 = add i32 %.233, -1
  %38 = icmp ugt i32 %.233, 1
  br i1 %38, label %39, label %43

39:                                               ; preds = %28
  %40 = add i32 %36, 1
  %41 = zext i32 %36 to i64
  %42 = getelementptr inbounds i8, ptr %25, i64 %41
  store i8 44, ptr %42, align 1, !tbaa !19
  br label %43

43:                                               ; preds = %.preheader, %39, %28
  %.334 = phi i32 [ %37, %39 ], [ %37, %28 ], [ %.233, %.preheader ]
  %.3 = phi i32 [ %40, %39 ], [ %36, %28 ], [ %.2, %.preheader ]
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %.not40 = icmp eq ptr %44, null
  br i1 %.not40, label %45, label %.preheader, !llvm.loop !20

45:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  store ptr %25, ptr %4, align 8, !tbaa !18
  %46 = zext i32 %.3 to i64
  %47 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %46, ptr %47, align 8, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %4, i64 16
  store i32 5, ptr %48, align 8
  %49 = call ptr @mln_string_pool_dup(ptr noundef %6, ptr noundef nonnull %4) #4
  call void @mln_alloc_free(ptr noundef nonnull %25) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  br label %50

50:                                               ; preds = %22, %20, %45
  %.0 = phi ptr [ %49, %45 ], [ null, %20 ], [ null, %22 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret ptr %.0
}

declare ptr @mln_hash_search_iterator(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!10, !6, i64 16}
!13 = !{!14, !15, i64 8}
!14 = !{!"", !6, i64 0, !15, i64 8, !15, i64 16, !15, i64 16, !15, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!14, !6, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !17}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass