; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

; Function Attrs: nounwind
declare noalias ptr @strdup(ptr noundef) #1

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

10:                                               ; preds = %3
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %16, label %13

13:                                               ; preds = %10
  %14 = load ptr, ptr %7, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %17

16:                                               ; preds = %13, %10, %3
  store i32 -1, ptr %4, align 4
  br label %81

17:                                               ; preds = %13
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.evhtp_s, ptr %18, i32 0, i32 18
  %20 = getelementptr inbounds %struct.anon.3, ptr %19, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %17
  store i32 -1, ptr %4, align 4
  br label %81

24:                                               ; preds = %17
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = call noalias ptr @strdup(ptr noundef %25) #3
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.evhtp_s, ptr %27, i32 0, i32 3
  store ptr %26, ptr %28, align 8, !tbaa !16
  %29 = icmp ne ptr %26, null
  br i1 %29, label %31, label %30

30:                                               ; preds = %24
  store i32 -1, ptr %4, align 4
  br label %81

31:                                               ; preds = %24
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.evhtp_s, ptr %33, i32 0, i32 0
  store ptr %32, ptr %34, align 8, !tbaa !17
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.evhtp_s, ptr %35, i32 0, i32 5
  %37 = load i32, ptr %36, align 8, !tbaa !18
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.evhtp_s, ptr %38, i32 0, i32 5
  store i32 %37, ptr %39, align 8, !tbaa !18
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.evhtp_s, ptr %40, i32 0, i32 6
  %42 = load i64, ptr %41, align 8, !tbaa !19
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.evhtp_s, ptr %43, i32 0, i32 6
  store i64 %42, ptr %44, align 8, !tbaa !19
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.evhtp_s, ptr %45, i32 0, i32 7
  %47 = load i64, ptr %46, align 8, !tbaa !20
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.evhtp_s, ptr %48, i32 0, i32 7
  store i64 %47, ptr %49, align 8, !tbaa !20
  %50 = load ptr, ptr %7, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.evhtp_s, ptr %50, i32 0, i32 15
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.evhtp_s, ptr %52, i32 0, i32 15
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %51, ptr align 8 %53, i64 16, i1 false), !tbaa.struct !21
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.evhtp_s, ptr %54, i32 0, i32 16
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.evhtp_s, ptr %56, i32 0, i32 16
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %55, ptr align 8 %57, i64 16, i1 false), !tbaa.struct !21
  br label %58

58:                                               ; preds = %31
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.evhtp_s, ptr %59, i32 0, i32 19
  %61 = getelementptr inbounds %struct.anon.4, ptr %60, i32 0, i32 0
  store ptr null, ptr %61, align 8, !tbaa !23
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.evhtp_s, ptr %62, i32 0, i32 18
  %64 = getelementptr inbounds %struct.anon.3, ptr %63, i32 0, i32 1
  %65 = load ptr, ptr %64, align 8, !tbaa !24
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.evhtp_s, ptr %66, i32 0, i32 19
  %68 = getelementptr inbounds %struct.anon.4, ptr %67, i32 0, i32 1
  store ptr %65, ptr %68, align 8, !tbaa !25
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.evhtp_s, ptr %70, i32 0, i32 18
  %72 = getelementptr inbounds %struct.anon.3, ptr %71, i32 0, i32 1
  %73 = load ptr, ptr %72, align 8, !tbaa !24
  store ptr %69, ptr %73, align 8, !tbaa !5
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.evhtp_s, ptr %74, i32 0, i32 19
  %76 = getelementptr inbounds %struct.anon.4, ptr %75, i32 0, i32 0
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.evhtp_s, ptr %77, i32 0, i32 18
  %79 = getelementptr inbounds %struct.anon.3, ptr %78, i32 0, i32 1
  store ptr %76, ptr %79, align 8, !tbaa !24
  br label %80

80:                                               ; preds = %58
  store i32 0, ptr %4, align 4
  br label %81

81:                                               ; preds = %80, %30, %23, %16
  %82 = load i32, ptr %4, align 4
  ret i32 %82
}

attributes #0 = { nocallback nofree 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 = { 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 208}
!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 0}
!18 = !{!10, !11, i64 40}
!19 = !{!10, !12, i64 48}
!20 = !{!10, !12, i64 56}
!21 = !{i64 0, i64 8, !22, i64 8, i64 8, !22}
!22 = !{!12, !12, i64 0}
!23 = !{!10, !6, i64 224}
!24 = !{!10, !6, i64 216}
!25 = !{!10, !6, i64 232}


; 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 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) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) uwtable
define dso_local range(i32 -1, 1) i32 @evhtp_add_vhost(ptr noundef %0, ptr noundef readonly %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = icmp eq ptr %0, null
  %5 = icmp eq ptr %1, null
  %or.cond = or i1 %4, %5
  %6 = icmp eq ptr %2, null
  %or.cond3 = or i1 %or.cond, %6
  br i1 %or.cond3, label %28, label %7

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %2, i64 208
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %10, label %28

10:                                               ; preds = %7
  %11 = tail call noalias ptr @strdup(ptr noundef nonnull %1) #3
  %12 = getelementptr inbounds i8, ptr %2, i64 24
  store ptr %11, ptr %12, align 8, !tbaa !15
  %.not31 = icmp eq ptr %11, null
  br i1 %.not31, label %28, label %13

13:                                               ; preds = %10
  store ptr %0, ptr %2, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %0, i64 40
  %15 = load i32, ptr %14, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %2, i64 40
  store i32 %15, ptr %16, align 8, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %0, i64 48
  %18 = getelementptr inbounds i8, ptr %2, i64 48
  %19 = load <2 x i64>, ptr %17, align 8, !tbaa !18
  store <2 x i64> %19, ptr %18, align 8, !tbaa !18
  %20 = getelementptr inbounds i8, ptr %2, i64 160
  %21 = getelementptr inbounds i8, ptr %0, i64 160
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %21, i64 16, i1 false), !tbaa.struct !19
  %22 = getelementptr inbounds i8, ptr %2, i64 176
  %23 = getelementptr inbounds i8, ptr %0, i64 176
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %22, ptr noundef nonnull align 8 dereferenceable(16) %23, i64 16, i1 false), !tbaa.struct !19
  %24 = getelementptr inbounds i8, ptr %2, i64 224
  store ptr null, ptr %24, align 8, !tbaa !20
  %25 = getelementptr inbounds i8, ptr %0, i64 216
  %26 = load ptr, ptr %25, align 8, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %2, i64 232
  store ptr %26, ptr %27, align 8, !tbaa !22
  store ptr %2, ptr %26, align 8, !tbaa !23
  store ptr %24, ptr %25, align 8, !tbaa !21
  br label %28

28:                                               ; preds = %10, %7, %3, %13
  %.0 = phi i32 [ 0, %13 ], [ -1, %3 ], [ -1, %7 ], [ -1, %10 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn 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 #2 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite, inaccessiblemem: readwrite) 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 }

!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 208}
!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 0}
!17 = !{!6, !10, i64 40}
!18 = !{!11, !11, i64 0}
!19 = !{i64 0, i64 8, !18, i64 8, i64 8, !18}
!20 = !{!6, !7, i64 224}
!21 = !{!6, !7, i64 216}
!22 = !{!6, !7, i64 232}
!23 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass