; 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_callbacks_s = 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 uwtable
declare dso_local void @evhtp_callback_free(ptr noundef) #1

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local ptr @evhtp_set_cb(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  br label %12

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

17:                                               ; preds = %12
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.evhtp_s, ptr %18, i32 0, i32 10
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = call i32 @pthread_mutex_lock(ptr noundef %20) #4
  br label %22

22:                                               ; preds = %17, %12
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.evhtp_s, ptr %25, i32 0, i32 13
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %64

29:                                               ; preds = %24
  %30 = call noalias ptr @calloc(i64 noundef 16, i64 noundef 1) #5
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.evhtp_s, ptr %31, i32 0, i32 13
  store ptr %30, ptr %32, align 8, !tbaa !16
  %33 = icmp ne ptr %30, null
  br i1 %33, label %48, label %34

34:                                               ; preds = %29
  br label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.evhtp_s, ptr %36, i32 0, i32 10
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %45

40:                                               ; preds = %35
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.evhtp_s, ptr %41, i32 0, i32 10
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = call i32 @pthread_mutex_unlock(ptr noundef %43) #4
  br label %45

45:                                               ; preds = %40, %35
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %121

48:                                               ; preds = %29
  br label %49

49:                                               ; preds = %48
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.evhtp_s, ptr %50, i32 0, i32 13
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = getelementptr inbounds %struct.evhtp_callbacks_s, ptr %52, i32 0, i32 0
  store ptr null, ptr %53, align 8, !tbaa !17
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.evhtp_s, ptr %54, i32 0, i32 13
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  %57 = getelementptr inbounds %struct.evhtp_callbacks_s, ptr %56, i32 0, i32 0
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.evhtp_s, ptr %58, i32 0, i32 13
  %60 = load ptr, ptr %59, align 8, !tbaa !16
  %61 = getelementptr inbounds %struct.evhtp_callbacks_s, ptr %60, i32 0, i32 1
  store ptr %57, ptr %61, align 8, !tbaa !19
  br label %62

62:                                               ; preds = %49
  br label %63

63:                                               ; preds = %62
  br label %64

64:                                               ; preds = %63, %24
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = call ptr @evhtp_callback_new(ptr noundef %65, i32 noundef 0, ptr noundef %66, ptr noundef %67)
  store ptr %68, ptr %10, align 8, !tbaa !5
  %69 = icmp ne ptr %68, null
  br i1 %69, label %84, label %70

70:                                               ; preds = %64
  br label %71

71:                                               ; preds = %70
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.evhtp_s, ptr %72, i32 0, i32 10
  %74 = load ptr, ptr %73, align 8, !tbaa !9
  %75 = icmp ne ptr %74, null
  br i1 %75, label %76, label %81

76:                                               ; preds = %71
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.evhtp_s, ptr %77, i32 0, i32 10
  %79 = load ptr, ptr %78, align 8, !tbaa !9
  %80 = call i32 @pthread_mutex_unlock(ptr noundef %79) #4
  br label %81

81:                                               ; preds = %76, %71
  br label %82

82:                                               ; preds = %81
  br label %83

83:                                               ; preds = %82
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %121

84:                                               ; preds = %64
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.evhtp_s, ptr %85, i32 0, i32 13
  %87 = load ptr, ptr %86, align 8, !tbaa !16
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  %89 = call i32 @evhtp_callbacks_add_callback(ptr noundef %87, ptr noundef %88)
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %106

91:                                               ; preds = %84
  %92 = load ptr, ptr %10, align 8, !tbaa !5
  call void @evhtp_callback_free(ptr noundef %92)
  br label %93

93:                                               ; preds = %91
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.evhtp_s, ptr %94, i32 0, i32 10
  %96 = load ptr, ptr %95, align 8, !tbaa !9
  %97 = icmp ne ptr %96, null
  br i1 %97, label %98, label %103

98:                                               ; preds = %93
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.evhtp_s, ptr %99, i32 0, i32 10
  %101 = load ptr, ptr %100, align 8, !tbaa !9
  %102 = call i32 @pthread_mutex_unlock(ptr noundef %101) #4
  br label %103

103:                                              ; preds = %98, %93
  br label %104

104:                                              ; preds = %103
  br label %105

105:                                              ; preds = %104
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %121

106:                                              ; preds = %84
  br label %107

107:                                              ; preds = %106
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.evhtp_s, ptr %108, i32 0, i32 10
  %110 = load ptr, ptr %109, align 8, !tbaa !9
  %111 = icmp ne ptr %110, null
  br i1 %111, label %112, label %117

112:                                              ; preds = %107
  %113 = load ptr, ptr %6, align 8, !tbaa !5
  %114 = getelementptr inbounds %struct.evhtp_s, ptr %113, i32 0, i32 10
  %115 = load ptr, ptr %114, align 8, !tbaa !9
  %116 = call i32 @pthread_mutex_unlock(ptr noundef %115) #4
  br label %117

117:                                              ; preds = %112, %107
  br label %118

118:                                              ; preds = %117
  br label %119

119:                                              ; preds = %118
  %120 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %120, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %121

121:                                              ; preds = %119, %105, %83, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %122 = load ptr, ptr %5, align 8
  ret ptr %122
}

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) #3

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

!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 80}
!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 104}
!17 = !{!18, !6, i64 0}
!18 = !{!"evhtp_callbacks_s", !6, i64 0, !6, i64 8}
!19 = !{!18, !6, i64 8}


; 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
declare dso_local void @evhtp_callback_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @evhtp_callback_new(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @evhtp_callbacks_add_callback(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @evhtp_set_cb(ptr nocapture noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %9, label %7

7:                                                ; preds = %4
  %8 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull %6) #3
  br label %9

9:                                                ; preds = %7, %4
  %10 = getelementptr inbounds i8, ptr %0, i64 104
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %19

13:                                               ; preds = %9
  %14 = tail call noalias dereferenceable_or_null(16) ptr @calloc(i64 noundef 16, i64 noundef 1) #4
  store ptr %14, ptr %10, align 8, !tbaa !15
  %.not30 = icmp eq ptr %14, null
  br i1 %.not30, label %15, label %17

15:                                               ; preds = %13
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %.not31 = icmp eq ptr %16, null
  br i1 %.not31, label %31, label %.sink.split

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %14, i64 8
  store ptr %14, ptr %18, align 8, !tbaa !16
  br label %19

19:                                               ; preds = %17, %9
  %20 = tail call ptr @evhtp_callback_new(ptr noundef %1, i32 noundef 0, ptr noundef %2, ptr noundef %3)
  %.not32 = icmp eq ptr %20, null
  br i1 %.not32, label %21, label %23

21:                                               ; preds = %19
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %.not33 = icmp eq ptr %22, null
  br i1 %.not33, label %31, label %.sink.split

23:                                               ; preds = %19
  %24 = load ptr, ptr %10, align 8, !tbaa !15
  %25 = tail call i32 @evhtp_callbacks_add_callback(ptr noundef %24, ptr noundef nonnull %20)
  %.not34 = icmp eq i32 %25, 0
  br i1 %.not34, label %28, label %26

26:                                               ; preds = %23
  tail call void @evhtp_callback_free(ptr noundef nonnull %20)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %.not36 = icmp eq ptr %27, null
  br i1 %.not36, label %31, label %.sink.split

28:                                               ; preds = %23
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %.not35 = icmp eq ptr %29, null
  br i1 %.not35, label %31, label %.sink.split

.sink.split:                                      ; preds = %28, %26, %21, %15
  %.sink = phi ptr [ %16, %15 ], [ %22, %21 ], [ %27, %26 ], [ %29, %28 ]
  %.0.ph = phi ptr [ null, %15 ], [ null, %21 ], [ null, %26 ], [ %20, %28 ]
  %30 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull %.sink) #3
  br label %31

31:                                               ; preds = %.sink.split, %28, %26, %21, %15
  %.0 = phi ptr [ null, %15 ], [ null, %21 ], [ null, %26 ], [ %20, %28 ], [ %.0.ph, %.sink.split ]
  ret ptr %.0
}

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) local_unnamed_addr #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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(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 #2 = { 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 #3 = { nounwind }
attributes #4 = { nounwind allocsize(0,1) }

!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 80}
!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 104}
!16 = !{!17, !7, i64 8}
!17 = !{!"evhtp_callbacks_s", !7, i64 0, !7, i64 8}


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