; LLVM IR from buaazp/zimg :: deps/libevhtp (evhtp)

; 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.evhtp_s = type { ptr, ptr, ptr, ptr, ptr, i32, i64, i64, i32, ptr, ptr, ptr, ptr, ptr, %struct.evhtp_defaults_s, %struct.timeval, %struct.timeval, %struct.anon.2, %struct.anon.3, %struct.anon.4 }
%struct.evhtp_defaults_s = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.timeval = type { i64, i64 }
%struct.anon.2 = type { ptr, ptr }
%struct.anon.3 = type { ptr, ptr }
%struct.anon.4 = type { ptr, ptr }
%struct.evhtp_alias_s = type { ptr, %struct.anon.7 }
%struct.anon.7 = type { ptr, ptr }

; 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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @evhtp_callbacks_free(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @evhtp_free(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  store i32 1, ptr %5, align 4
  br label %106

9:                                                ; preds = %1
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.evhtp_s, ptr %10, i32 0, i32 9
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %22

14:                                               ; preds = %9
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.evhtp_s, ptr %15, i32 0, i32 9
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = call i32 @evthr_pool_stop(ptr noundef %17)
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.evhtp_s, ptr %19, i32 0, i32 9
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  call void @evthr_pool_free(ptr noundef %21)
  br label %22

22:                                               ; preds = %14, %9
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.evhtp_s, ptr %23, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %31

27:                                               ; preds = %22
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.evhtp_s, ptr %28, i32 0, i32 3
  %30 = load ptr, ptr %29, align 8, !tbaa !16
  call void @free(ptr noundef %30) #4
  br label %31

31:                                               ; preds = %27, %22
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.evhtp_s, ptr %32, i32 0, i32 13
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %40

36:                                               ; preds = %31
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.evhtp_s, ptr %37, i32 0, i32 13
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  call void @evhtp_callbacks_free(ptr noundef %39)
  br label %40

40:                                               ; preds = %36, %31
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.evhtp_s, ptr %41, i32 0, i32 17
  %43 = getelementptr inbounds %struct.anon.2, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  store ptr %44, ptr %3, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %102, %40
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %48, label %53

48:                                               ; preds = %45
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.evhtp_alias_s, ptr %49, i32 0, i32 1
  %51 = getelementptr inbounds %struct.anon.7, ptr %50, i32 0, i32 0
  %52 = load ptr, ptr %51, align 8, !tbaa !19
  store ptr %52, ptr %4, align 8, !tbaa !5
  br label %53

53:                                               ; preds = %48, %45
  %54 = phi i1 [ false, %45 ], [ true, %48 ]
  br i1 %54, label %55, label %104

55:                                               ; preds = %53
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.evhtp_alias_s, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %57, align 8, !tbaa !21
  %59 = icmp ne ptr %58, null
  br i1 %59, label %60, label %64

60:                                               ; preds = %55
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.evhtp_alias_s, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !21
  call void @free(ptr noundef %63) #4
  br label %64

64:                                               ; preds = %60, %55
  br label %65

65:                                               ; preds = %64
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.evhtp_alias_s, ptr %66, i32 0, i32 1
  %68 = getelementptr inbounds %struct.anon.7, ptr %67, i32 0, i32 0
  %69 = load ptr, ptr %68, align 8, !tbaa !19
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %82

71:                                               ; preds = %65
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.evhtp_alias_s, ptr %72, i32 0, i32 1
  %74 = getelementptr inbounds %struct.anon.7, ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !22
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.evhtp_alias_s, ptr %76, i32 0, i32 1
  %78 = getelementptr inbounds %struct.anon.7, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %78, align 8, !tbaa !19
  %80 = getelementptr inbounds %struct.evhtp_alias_s, ptr %79, i32 0, i32 1
  %81 = getelementptr inbounds %struct.anon.7, ptr %80, i32 0, i32 1
  store ptr %75, ptr %81, align 8, !tbaa !22
  br label %90

82:                                               ; preds = %65
  %83 = load ptr, ptr %3, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.evhtp_alias_s, ptr %83, i32 0, i32 1
  %85 = getelementptr inbounds %struct.anon.7, ptr %84, i32 0, i32 1
  %86 = load ptr, ptr %85, align 8, !tbaa !22
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.evhtp_s, ptr %87, i32 0, i32 17
  %89 = getelementptr inbounds %struct.anon.2, ptr %88, i32 0, i32 1
  store ptr %86, ptr %89, align 8, !tbaa !23
  br label %90

90:                                               ; preds = %82, %71
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.evhtp_alias_s, ptr %91, i32 0, i32 1
  %93 = getelementptr inbounds %struct.anon.7, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !19
  %95 = load ptr, ptr %3, align 8, !tbaa !5
  %96 = getelementptr inbounds %struct.evhtp_alias_s, ptr %95, i32 0, i32 1
  %97 = getelementptr inbounds %struct.anon.7, ptr %96, i32 0, i32 1
  %98 = load ptr, ptr %97, align 8, !tbaa !22
  store ptr %94, ptr %98, align 8, !tbaa !5
  br label %99

99:                                               ; preds = %90
  br label %100

100:                                              ; preds = %99
  %101 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %101) #4
  br label %102

102:                                              ; preds = %100
  %103 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %103, ptr %3, align 8, !tbaa !5
  br label %45, !llvm.loop !24

104:                                              ; preds = %53
  %105 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %105) #4
  store i32 0, ptr %5, align 4
  br label %106

106:                                              ; preds = %104, %8
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  %107 = load i32, ptr %5, align 4
  switch i32 %107, label %109 [
    i32 0, label %108
    i32 1, label %108
  ]

108:                                              ; preds = %106, %106
  ret void

109:                                              ; preds = %106
  unreachable
}

declare i32 @evthr_pool_stop(ptr noundef) #3

declare void @evthr_pool_free(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { "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 }

!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 72}
!10 = !{!"evhtp_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !12, i64 48, !12, i64 56, !11, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !13, i64 112, !14, i64 160, !14, i64 176, !15, i64 192, !15, i64 208, !15, i64 224}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"evhtp_defaults_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!14 = !{!"timeval", !12, i64 0, !12, i64 8}
!15 = !{!"", !6, i64 0, !6, i64 8}
!16 = !{!10, !6, i64 24}
!17 = !{!10, !6, i64 104}
!18 = !{!10, !6, i64 192}
!19 = !{!20, !6, i64 8}
!20 = !{!"evhtp_alias_s", !6, i64 0, !15, i64 8}
!21 = !{!20, !6, i64 0}
!22 = !{!20, !6, i64 16}
!23 = !{!10, !6, i64 200}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @evhtp_callbacks_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @evhtp_free(ptr noundef %0) local_unnamed_addr #1 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %31, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 72
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %9, label %6

6:                                                ; preds = %3
  %7 = tail call i32 @evthr_pool_stop(ptr noundef nonnull %5) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  tail call void @evthr_pool_free(ptr noundef %8) #3
  br label %9

9:                                                ; preds = %6, %3
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %.not29 = icmp eq ptr %11, null
  br i1 %.not29, label %13, label %12

12:                                               ; preds = %9
  tail call void @free(ptr noundef nonnull %11) #3
  br label %13

13:                                               ; preds = %12, %9
  %14 = getelementptr inbounds i8, ptr %0, i64 104
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %.not30 = icmp eq ptr %15, null
  br i1 %.not30, label %17, label %16

16:                                               ; preds = %13
  tail call void @evhtp_callbacks_free(ptr noundef nonnull %15)
  br label %17

17:                                               ; preds = %16, %13
  %18 = getelementptr inbounds i8, ptr %0, i64 192
  %19 = load ptr, ptr %18, align 8, !tbaa !17
  %.not3134 = icmp eq ptr %19, null
  br i1 %.not3134, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %17
  %20 = getelementptr inbounds i8, ptr %0, i64 200
  br label %21

21:                                               ; preds = %.lr.ph, %26
  %.035 = phi ptr [ %19, %.lr.ph ], [ %23, %26 ]
  %22 = getelementptr inbounds i8, ptr %.035, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !18
  %24 = load ptr, ptr %.035, align 8, !tbaa !20
  %.not32 = icmp eq ptr %24, null
  br i1 %.not32, label %26, label %25

25:                                               ; preds = %21
  tail call void @free(ptr noundef nonnull %24) #3
  %.pr = load ptr, ptr %22, align 8, !tbaa !18
  br label %26

26:                                               ; preds = %21, %25
  %27 = phi ptr [ %23, %21 ], [ %.pr, %25 ]
  %.not33 = icmp eq ptr %27, null
  %28 = getelementptr inbounds i8, ptr %.035, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  %30 = getelementptr inbounds i8, ptr %27, i64 16
  %.sink = select i1 %.not33, ptr %20, ptr %30
  store ptr %29, ptr %.sink, align 8, !tbaa !22
  store ptr %27, ptr %29, align 8, !tbaa !22
  tail call void @free(ptr noundef nonnull %.035) #3
  %.not31 = icmp eq ptr %23, null
  br i1 %.not31, label %.critedge, label %21, !llvm.loop !23

.critedge:                                        ; preds = %26, %17
  tail call void @free(ptr noundef %0) #3
  br label %31

31:                                               ; preds = %1, %.critedge
  ret void
}

declare i32 @evthr_pool_stop(ptr noundef) local_unnamed_addr #2

declare void @evthr_pool_free(ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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, !7, i64 72}
!6 = !{!"evhtp_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !11, i64 48, !11, i64 56, !10, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !12, i64 112, !13, i64 160, !13, i64 176, !14, i64 192, !14, i64 208, !14, i64 224}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"evhtp_defaults_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!13 = !{!"timeval", !11, i64 0, !11, i64 8}
!14 = !{!"", !7, i64 0, !7, i64 8}
!15 = !{!6, !7, i64 24}
!16 = !{!6, !7, i64 104}
!17 = !{!6, !7, i64 192}
!18 = !{!19, !7, i64 8}
!19 = !{!"evhtp_alias_s", !7, i64 0, !14, i64 8}
!20 = !{!19, !7, i64 0}
!21 = !{!19, !7, i64 16}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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