; 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_kv_s = type { ptr, ptr, i64, i64, i8, i8, %struct.anon.1 }
%struct.anon.1 = type { ptr, ptr }
%struct.evhtp_kvs_s = type { ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local void @evhtp_kv_free(ptr noundef) #0

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

7:                                                ; preds = %2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %7, %2
  br label %47

11:                                               ; preds = %7
  br label %12

12:                                               ; preds = %11
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.evhtp_kv_s, ptr %13, i32 0, i32 6
  %15 = getelementptr inbounds %struct.anon.1, ptr %14, i32 0, i32 0
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %29

18:                                               ; preds = %12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.evhtp_kv_s, ptr %19, i32 0, i32 6
  %21 = getelementptr inbounds %struct.anon.1, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.evhtp_kv_s, ptr %23, i32 0, i32 6
  %25 = getelementptr inbounds %struct.anon.1, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.evhtp_kv_s, ptr %26, i32 0, i32 6
  %28 = getelementptr inbounds %struct.anon.1, ptr %27, i32 0, i32 1
  store ptr %22, ptr %28, align 8, !tbaa !13
  br label %36

29:                                               ; preds = %12
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.evhtp_kv_s, ptr %30, i32 0, i32 6
  %32 = getelementptr inbounds %struct.anon.1, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.evhtp_kvs_s, ptr %34, i32 0, i32 1
  store ptr %33, ptr %35, align 8, !tbaa !14
  br label %36

36:                                               ; preds = %29, %18
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.evhtp_kv_s, ptr %37, i32 0, i32 6
  %39 = getelementptr inbounds %struct.anon.1, ptr %38, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.evhtp_kv_s, ptr %41, i32 0, i32 6
  %43 = getelementptr inbounds %struct.anon.1, ptr %42, i32 0, i32 1
  %44 = load ptr, ptr %43, align 8, !tbaa !13
  store ptr %40, ptr %44, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %36
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  call void @evhtp_kv_free(ptr noundef %46)
  br label %47

47:                                               ; preds = %45, %10
  ret void
}

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

!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 40}
!10 = !{!"evhtp_kv_s", !6, i64 0, !6, i64 8, !11, i64 16, !11, i64 24, !7, i64 32, !7, i64 33, !12, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!"", !6, i64 0, !6, i64 8}
!13 = !{!10, !6, i64 48}
!14 = !{!15, !6, i64 8}
!15 = !{!"evhtp_kvs_s", !6, i64 0, !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_kv_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @evhtp_kv_rm_and_free(ptr noundef writeonly %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq ptr %0, null
  %4 = icmp eq ptr %1, null
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %12, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 40
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %.not = icmp eq ptr %7, null
  %8 = getelementptr inbounds i8, ptr %1, i64 48
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = getelementptr inbounds i8, ptr %7, i64 48
  %.sink = select i1 %.not, ptr %10, ptr %11
  store ptr %9, ptr %.sink, align 8, !tbaa !13
  store ptr %7, ptr %9, align 8, !tbaa !13
  tail call void @evhtp_kv_free(ptr noundef nonnull %1)
  br label %12

12:                                               ; preds = %2, %5
  ret void
}

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

!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 40}
!6 = !{!"evhtp_kv_s", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 24, !8, i64 32, !8, i64 33, !11, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"", !7, i64 0, !7, i64 8}
!12 = !{!6, !7, i64 48}
!13 = !{!7, !7, i64 0}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass