; 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 }

; 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 allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @evhtp_new(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 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 8, ptr %6) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %51

11:                                               ; preds = %2
  %12 = call noalias ptr @calloc(i64 noundef 240, i64 noundef 1) #4
  store ptr %12, ptr %6, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %51

15:                                               ; preds = %11
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.evhtp_s, ptr %17, i32 0, i32 4
  store ptr %16, ptr %18, align 8, !tbaa !9
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.evhtp_s, ptr %20, i32 0, i32 1
  store ptr %19, ptr %21, align 8, !tbaa !16
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.evhtp_s, ptr %22, i32 0, i32 5
  store i32 1, ptr %23, align 8, !tbaa !17
  br label %24

24:                                               ; preds = %15
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.evhtp_s, ptr %25, i32 0, i32 18
  %27 = getelementptr inbounds %struct.anon.3, ptr %26, i32 0, i32 0
  store ptr null, ptr %27, align 8, !tbaa !18
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.evhtp_s, ptr %28, i32 0, i32 18
  %30 = getelementptr inbounds %struct.anon.3, ptr %29, i32 0, i32 0
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.evhtp_s, ptr %31, i32 0, i32 18
  %33 = getelementptr inbounds %struct.anon.3, ptr %32, i32 0, i32 1
  store ptr %30, ptr %33, align 8, !tbaa !19
  br label %34

34:                                               ; preds = %24
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.evhtp_s, ptr %37, i32 0, i32 17
  %39 = getelementptr inbounds %struct.anon.2, ptr %38, i32 0, i32 0
  store ptr null, ptr %39, align 8, !tbaa !20
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.evhtp_s, ptr %40, i32 0, i32 17
  %42 = getelementptr inbounds %struct.anon.2, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.evhtp_s, ptr %43, i32 0, i32 17
  %45 = getelementptr inbounds %struct.anon.2, ptr %44, i32 0, i32 1
  store ptr %42, ptr %45, align 8, !tbaa !21
  br label %46

46:                                               ; preds = %36
  br label %47

47:                                               ; preds = %46
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  call void @evhtp_set_gencb(ptr noundef %48, ptr noundef @_evhtp_default_request_cb, ptr noundef %49)
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %50, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %51

51:                                               ; preds = %47, %14, %10
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %52 = load ptr, ptr %3, align 8
  ret ptr %52
}

; Function Attrs: nounwind uwtable
declare hidden void @_evhtp_default_request_cb(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 32}
!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 8}
!17 = !{!10, !11, i64 40}
!18 = !{!10, !6, i64 208}
!19 = !{!10, !6, i64 216}
!20 = !{!10, !6, i64 192}
!21 = !{!10, !6, i64 200}


; 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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #0

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

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

4:                                                ; preds = %2
  %5 = tail call noalias dereferenceable_or_null(240) ptr @calloc(i64 noundef 240, i64 noundef 1) #2
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %14, label %6

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %1, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %0, ptr %8, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %5, i64 40
  store i32 1, ptr %9, align 8, !tbaa !16
  %10 = getelementptr inbounds i8, ptr %5, i64 208
  %11 = getelementptr inbounds i8, ptr %5, i64 216
  store ptr %10, ptr %11, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %5, i64 192
  %13 = getelementptr inbounds i8, ptr %5, i64 200
  store ptr %12, ptr %13, align 8, !tbaa !18
  tail call void @evhtp_set_gencb(ptr noundef nonnull %5, ptr noundef nonnull @_evhtp_default_request_cb, ptr noundef nonnull %5)
  br label %14

14:                                               ; preds = %4, %2, %6
  %.0 = phi ptr [ %5, %6 ], [ null, %2 ], [ null, %4 ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare hidden void @_evhtp_default_request_cb(ptr noundef, ptr noundef) #1

attributes #0 = { 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 #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) }

!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 32}
!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 8}
!16 = !{!6, !10, i64 40}
!17 = !{!6, !7, i64 216}
!18 = !{!6, !7, i64 200}


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